i am trying to set up a player movement routine where by the player sprite (32x32) moves 1 grid space (32x32) on the press of the arrow keys, but can not move through a solid wall or obstacle, and can push another sprite (32x32)
here is my logic..:
when i add a single direction my logic works perfectly: http://zordorkproductions.com/tests/gridpush.capx
but when i add all 4 directions things goto pot: http://zordorkproductions.com/tests/gridpush1.capx
if anyone can point into the right direction of where i have gone wrong it would be much appreciate.
i have been trying out different things and come up with a routine to push the block around:
this routine works great for 1 movable block but goes wrong when i add extra pushables.. also i can not work out the collision with walls...
please can someone point me in the right direction
OK let me if I can ask my question in a more simple way:
I have a controllable block which is 32px x 32px (sprite2)
I have a obstacle block which is 32px x 32px (sprite3)
I have a pushable block which is 32px x 32px (sprite4)
I am moving sprite2 with:
if cursor key pressed move in that direction by 32px add 1 to movecount (this is working)
Logic I want to include:
1) if sprite 2 is in contact with sprite3 it can push it in the direction of the cursor key (this is working for 1 instance of sprite3, but not for multiple instances of sprite3)
2) sprite2 can not move through sprite4 (not working)
3) sprite2 can not push sprite3 through sprite4 (not yet programed)
4) Sprite2 can not move through sprite3 (not yet programed)
I would really appreciate some input on this
Develop games in your browser. Powerful, performant & highly capable.
The main thing, that even stumped me for a few minutes was the collision box (sprite -> image editor -> collisions).. of course this by default is set to the sprite width and height.. look in here and you'll notice I scaled the collision box down a few pixels (hence the overlapping at offset 5/-5 in the events).
I'm not sure what you wanted if while pushing a block in some direction and another movable block is in the way.. should it push that one too? or stop? well... that's your homework if you need that :}
that hadst even crossed my mind, this gives me something to play around with. Thanks