Making a block pushable in 4 directions
#1
Posted 15 May 2012 - 07:43 AM
when my player_block collides with push_block I want the push_block to move in the direction player_block is moving
#2
Posted 15 May 2012 - 08:40 AM
// collision with player_block
x += player_block.x - player_block.xprevious;
y += player_block.y - player_block.yprevious;
Edited by M.D.Simmo, 16 May 2012 - 06:13 AM.
#3
Posted 15 May 2012 - 09:53 AM
it is a static block I want it to move with the player_block if the player is pushing into it
#4
Posted 15 May 2012 - 10:21 AM
Nope this push_block is not moving nor does it have an animation
it is a static block I want it to move with the player_block if the player is pushing into it
sorry, when I asked about the push_block, I meant the player_block.
I've fixed the code to be correct and should work for the situation.
#5
Posted 16 May 2012 - 04:15 AM
But if only it moved smoothly and not like in a jolty motion
#6
Posted 16 May 2012 - 06:29 AM
But if only it moved smoothly and not like in a jolty motion
if your push/player block uses vspeeds and hspeeds to move around, this code makes it a little more smooth.
// step event of push_block
if (place_meeting(x,y,obj_push)) {
hspeed = obj_push.hspeed;
vspeed = obj_push.vspeed;
} else {
speed *= 0.9;
if (speed < 1) {
speed = 0;
}
}(The push_block and player_blocks may need to be switched around)
Edited by M.D.Simmo, 16 May 2012 - 06:32 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











