sprite collision question
Posted: Sat May 23, 2009 2:37 am
I am setting up walls for a 2d sprite to be bound in. The idea is to prevent the sprite from moving through a wall.
If I comment out the final IF block the first part seems to function normally ( when I try to move left through the wall it prevents me from moving left).
However, with the block as is when I try to move left at all I am prevented from moving no matter where the sprite is. Even if I am nowhere near the 196, 280 coords.
what is wrong with this code?
In retrospect this should probably be in the game programming area. If one of the mods wants to move this topic feel free to do so.
Code: Select all
If KeyboardPushed(#PB_Key_A) Or KeyboardPushed(#PB_Key_Left)
Imagex= imagex-3
If SpriteCollision(0, imagex, imagey, 101, 103, 93)
imagex=imagex+3
EndIf
If SpriteCollision(0, imagex, imagey, 103, 196, 280)
imagex=imagex+3
Debug "test"
EndIf
EndIf
However, with the block as is when I try to move left at all I am prevented from moving no matter where the sprite is. Even if I am nowhere near the 196, 280 coords.
what is wrong with this code?
In retrospect this should probably be in the game programming area. If one of the mods wants to move this topic feel free to do so.