rem Main loop time.
Do
`In order for collision to properly work, I'll
`need an old position coordinate.
oxpos#=sprite x(1)
oypos#=sprite y(1)
`Gravity start
grav#=grav#-.1
ypos#=ypos#-grav#
`This will update the sprite's position to where
`it should be.
sprite 1,xpos#,ypos#,1
`Control Schematics-- jumping is handled seperately,
`due to collision detection needing to be done first.
if leftkey()=1
sprite 1,xpos#,ypos#,1
dec xpos#
if sprite mirrored(1)=0 then mirror sprite 1
endif
if rightkey()=1
sprite 1,xpos#,ypos#,1
inc xpos#
if sprite mirrored(1)=1 then mirror sprite 1
endif
`Handling the collision of the Sonic sprite with
`other sprites.
if sprite collision(1,0)<>0
grav#=0
sprite 1,oxpos#,oypos#,1
endif
`Again, updating the ypos# variable, and the sprite
`position.
ypos#=sprite y(1)
sprite 1,xpos#,ypos#,1
`Jumping, all on its lonesome. This needs to be here
`so that the collision detection work can already have
`been done. Otherwise, grav would not be zero.
if spacekey()=1 and grav#=0 then grav#=4
`Animations for various commands.
gosub walking
`Lala, sync time!
sync
Loop
All of that is the collision code I use.