Been trying to figure out how to make my character collide with a sprite, got it to work with one problem.. When you collide with another sprite you will go in 6 pixels, then when you let go of whatever key you\'re holding you snap back to the edge..
`Player Keys Routine
Player:
rem - Down Key Loop -
if downkey()=1 then image=9001
while downkey()>0
sleep 72
gosub Render_Sprite_Tile_Map
if downkey()<>1 then image=9004
if leftkey()=1 then playerX#=playerX#-3
if rightkey()=1 then playerX#=playerX#+3
image=image-1 : IF image<9001 THEN image=9004
sprite PlayerSprite,playerX#-ScrnXoff,playerY#-ScrnYoff,image
set sprite PlayerSprite, 1, 1
playerY#=playerY#+6 : if playerY#>TileHeight*(MapHeight-1)-32 then playerY#=TileHeight*(MapHeight-1)-32 : image=9001
endwhile
rem - Up Key Loop -
if upkey()=1 then image=9005
while upkey()>0
sleep 72
gosub Render_Sprite_Tile_Map
if upkey()=0 then image=9008
if leftkey()=1 then playerX#=playerX#-3
if rightkey()=1 then playerX#=playerX#+3
image=image-1 : IF image<9005 THEN image=9008
sprite PlayerSprite,playerX#-ScrnXoff,playerY#-ScrnYoff,image
set sprite PlayerSprite, 1, 1
playerY#=playerY#-6 : IF playerY#<-32 THEN playerY#=-32 : image=9005
endwhile
rem - Right Key Loop -
if rightkey()=1 then image=9009
while rightkey()>0
sleep 72
gosub Render_Sprite_Tile_Map
if rightkey()<>1 then image=9012
if upkey()=1 then playerY#=playerY#-3
if downkey()=1 then playerY#=playerY#+3
image=image-1 : IF image<9009 THEN image=9012
sprite PlayerSprite,playerX#-ScrnXoff,playerY#-ScrnYoff,image
set sprite PlayerSprite, 1, 1
playerX#=playerX#+6 : if playerX#>TileWidth*(MapWidth-1) then playerX#=TileWidth*(MapWidth-1) : image=9012
endwhile
rem - Left Key Loop -
if leftkey()=1 then image=9013
while leftkey()>0
sleep 72
gosub Render_Sprite_Tile_Map
if leftkey()<>1 then image=9016
if upkey()=1 then playerY#=playerY#-3
if downkey()=1 then playerY#=playerY#+3
image=image-1 : IF image<9013 THEN image=9016
sprite PlayerSprite,playerX#-ScrnXoff,playerY#-ScrnYoff,image
set sprite PlayerSprite, 1, 1
playerX#=playerX#-6 : IF playerX#<0 THEN playerX#=0 : image=9013
endwhile
return
I know this problem has something to do with this walking system, since whenever you press a key you automatically go in the direction 6 pixels. I was wondering how I could re-do this walking system to work better with sprite collisions.
If you have X-ray vision, can you see through your own eyelids?