So here's the code I'm working on. At the moment jumping and suck work. I'm trying to figure out the easiest way to make it to add more floors above and below and have the character fall down to these levels. Any hints would be most appreciated.
sync on
sync rate 30
SET DISPLAY MODE 1024, 768, 32, 1, 1, 0
backdrop on
color backdrop rgb(0,0,0)
//////////variables//////////////
charxpos# =(screen width()-50)/2
charypos# =400
floorypos# =445
gravity# = -0.40
going_right=1
going_left=0
fallspeed# = 6
////////////////////////////////
LOAD IMAGE "media\floortile.png",1 //background floors
LOAD IMAGE "media\level1walls.png",4 //background walls
CREATE ANIMATED SPRITE 2, "media\alucard.png", 16, 2, 2 //running
CREATE ANIMATED SPRITE 3, "media\alucard.png", 16, 2, 2 //idle
sprite 1,charxpos#,floorypos#,1 //floor
sprite 2, charxpos#,charypos#, 2 //running right
sprite 3, charxpos#,charypos#, 2 //idle
sprite 4, charxpos#,floorypos#, 4 //walls
set sprite 1, 1, 1
set sprite 4, 0, 1
////MAIN LOOP////
DO
set sprite priority 2,1
set sprite priority 3,1
gosub _check_sprite_visible
gosub _mirrorsprites
gosub _movement
//gosub _collision
SPRITE 1, charxpos#, floorypos#, 1
SPRITE 4, charxpos#, floorypos#-190, 4
SYNC
LOOP
END
_check_sprite_visible:
if rightkey()=0 and leftkey()=0
SHOW SPRITE 3
HIDE SPRITE 2
else
SHOW SPRITE 2
HIDE SPRITE 3
endif
return
_mirrorsprites:
if rightkey()=1 and going_left=1
MIRROR SPRITE 2
MIRROR SPRITE 3
endif
if leftkey()=1 and going_right = 1
MIRROR SPRITE 2
MIRROR SPRITE 3
endif
return
_movement:
////jumping////
if state =0 and spacekey() = 1
state =1
jumpspeed# = 6
endif
if state = 1
inc floorypos#,jumpspeed#
inc jumpspeed#,gravity#
if floorypos# <= 444
state = 0
floorypos# = 445
endif
endif
////end of jumping////
////move right////
if rightkey()=1 or leftkey()=1
if rightkey()=1
going_right=1
going_left=0
inc charxpos#, -4
play sprite 2,1,16,40
endif
////move left////
if leftkey()=1
going_right=0
going_left=1
inc charxpos#, 4
play sprite 2,1,16,40
endif
else
play sprite 3,17,21,100
endif
return
_collision:
if sprite hit(2,1)=1
return
endif
if sprite hit(3,1)=1
return
endif
if sprite hit(2,1)=0 //if were not on the floor
inc floorypos#,fallspeed#
inc jumpspeed#,gravity#
if floorypos# + 50 > 400
floorypos# = 445
endif
endif
if sprite hit(3,1)=0 //if were not on the floor
inc floorypos#,fallspeed#
inc jumpspeed#,gravity#
if floorypos# + 50 > 400
floorypos# = 400
endif
endif
return