Kamaki,
Place the code below into your editor and run it. It is an example of a jumpable and moveable sprite. Enjoy. Study the code.
REM << make and position character sprite
ink rgb(255,255,255),0
box 0,0,50,50
get image 1,0,0,50,50
charxpos# = (screen width() - 50) / 2
charypos# = 400
cls
sprite 1,charxpos#,charypos#,1
REM << draw ground and print instructions to screen
ink rgb(0,255,0),0
line 0,450,screen width() - 1,450
ink rgb(255,0,0),0
center text screen width() / 2,5,"USE ARROW KEYS TO MOVE CHARACTER AND PRESS SPACEKEY TO JUMP"
REM << set gravity(gravity is set to positive value because in 2D positive is downward)
gravity# = 0.40
REM <<<<<<<<<<<<<<<<<<<<<<<< MAIN LOOP >>>>>>>>>>>>>>>>>>>>>>>>>>>
repeat
REM << activate jump sequence if character is on ground
if state = 0 and spacekey() = 1
state = 1
REM << jumpspeed is set to negative because in 2D negative is upwards
jumpspeed# = -6
endif
REM << jump sequence
if state = 1
inc charypos#,jumpspeed#
inc jumpspeed#,gravity#
REM << if bottom(charypos# + charheight{50}) of character goes below ground then reposition him above ground and reset jump state
if charypos# + 50 > 450
state = 0
charypos# = 400
endif
endif
REM << move character
if rightkey() = 1 then inc charxpos#,2
if leftkey() = 1 then dec charxpos#,2
REM << update sprite image
sprite 1,charxpos#,charypos#,1
sync
until mouseclick() = 1
cls
sync
end
+NanoBrain+