News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Sprite based animation and jumping with running

Started by LemonWizard, September 27, 2012, 01:03:26 AM

Previous topic - Next topic

LemonWizard

Well... here is something a bit uglier coded but it works and looks kinda cool.
I plan to turn this into a full fledged game so don't steal it. but feel free to use it or play around with it just dont take credit
Who knows you might come up with a cool platformer out of it yea? Because it's fairly basic. it's one of the most basic things I've made in a while.
JUMP N SHOOT MAN!! haha jk jk

<Controls>
UP=jump
Left=Run
Right=Run

Here's the code:

PlayBASIC Code: [Select]
; PROJECT : The_Project
; AUTHOR : Laptop
; CREATED : 9/26/2012
; EDITED : 9/26/2012
; ---------------------------------------------------------------------
runframe=1
leapframe=1
jumping=false
landed=true
falling=false
jumpstarted=false


stickmany#=getscreenheight()-200-64
stickmanx#=0

dim stickmanrunningright(8)
dim stickmanrunningleft(8)
for temp=1 to 8

stickmanrunningright(temp)=loadnewfximage("frame"+str$(temp+8)+".png")
imagemaskcolour stickmanrunningright(temp), rgb(255, 255, 255)
stickmanrunningleft(temp)=newfximage(getimagewidth(stickmanrunningright(temp)), getimageheight(stickmanrunningright(temp)))
rendertoimage stickmanrunningright(temp)
getimage stickmanrunningleft(temp), 0, 0, getimagewidth(stickmanrunningright(temp)), getimageheight(stickmanrunningright(temp))
mirrorimage stickmanrunningleft(temp), 1, 0
imagemaskcolour stickmanrunningleft(temp), rgb(255, 255, 255)

next temp

dim stickmanleapleft(8)
dim stickmanleapright(8)
for temp=1 to 8

stickmanleapright(temp)=loadnewfximage("frame"+str$(temp)+".png")
imagemaskcolour stickmanleapright(temp), rgb(255, 255, 255)
stickmanleapleft(temp)=newfximage(getimagewidth(stickmanleapright(temp)), getimageheight(stickmanleapright(temp)))
rendertoimage stickmanleapright(temp)
getimage stickmanleapleft(temp), 0, 0, getimagewidth(stickmanleapright(temp)), getimageheight(stickmanleapright(temp))
mirrorimage stickmanleapleft(temp), 1, 0
imagemaskcolour stickmanleapleft(temp), rgb(255, 255, 255)
next temp



rendertoscreen

stickframetimer=timer()+8
leapframetimer=timer()+8

fallspeed#=0.10
maxfallspeed#=2

main:
;;




keypressed=false



select facing
case 1
if jumpstarted=false
drawimage stickmanrunningright(frame), stickmanx#, stickmany#, 1
endif
case 2
if jumpstarted=false
drawimage stickmanrunningleft(frame), stickmanx#, stickmany#, 1
endif

endselect




select facing
case 1
if jumpstarted=true
drawimage stickmanleapright(leapframe), stickmanx#, stickmany#, 1
endif
case 2
if jumpstarted=true
drawimage stickmanleapleft(leapframe), stickmanx#, stickmany#, 1
endif
endselect






;stickmanx=mousex()
;stickmany=mousey()

print stickmanx
print stickmany
print jumptime
print "landed "+str$(landed)
print "jumping "+str$(jumping)
;box stickmanx, stickmany, stickmanx+30, stickmany+30 ,1


if rightkey()
stickmanx#=stickmanx#+1
keypressed=true
facing=1
endif

if leftkey()
stickmanx#=stickmanx#-1
keypressed=true
facing=2
endif




if timer()>stickframetimer
if keypressed=true
frame=frame+1
if frame>8 then frame=1
stickframetimer=timer()+8
endif
endif


if landed=true
if falling=false
if jumping=false
if upkey()
jumping=true
jumptime=125
falling=false
landed=false
jumpstarted=true
leapframe=1
endif
endif
endif
endif



if jumping=true

if leapframe>5
Login required to view complete source code


Here's all the frame images in a zip file along with the source and the compiled exe.
MAY RUN FAST so your better off just trying the code and using the SETFPS command.

enjoy! AND PLEASE comment and stuff. I mean really!! I see like 20 downloads on some of my files and no comments. or anything, sometimes. :(


LemonWizard

*points to the amount of downloads on the file*
*points to the words asking for people to comment *

*points to the lack of commentary on the demo*

*annoyed stare at readers*
Please comment on anything you download. It doesn't take that long.

OldNESJunkie

Sorry, meant to post earlier, but got a little crazy at work so....
Anyways, pretty good start to me it seems. I love the stick figure games, so hopefully you make this into a complete game.

stevmjon

hey lemonwizard

it is fun to make your character run around and jump.

change line 98 to :  Print stickmanx#
change line 99 to : Print stickmany#

use cos to change the jump so it is not so linear. keep this growing, so the community can see your progress.

   stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.