Le_Beholder
Member
Hello mercenary person(s); I have money* and a problem.
(*32 monopoly bucks)
I am trying to create puzzle blocks in my game that can be pushed by the player, and only move 16 blocks smoothly at a time.
so far I've managed how to get it to move, and control what direction, what I don't know is how to get it to stop after 16 pixels and make it stop being pushable anymore.
here's my code:
the variables pushleft, pushright, pushup and pushdown are set in the creation code of the object inside the room, 3 are set to false and only one is set to true, given on what direction I want the player to push the block only towards.
the problem is I dont have clue how to make the object stop after 16 pixels...
Any ideas on how to limit it's movement?
(*32 monopoly bucks)
I am trying to create puzzle blocks in my game that can be pushed by the player, and only move 16 blocks smoothly at a time.
so far I've managed how to get it to move, and control what direction, what I don't know is how to get it to stop after 16 pixels and make it stop being pushable anymore.
here's my code:
Code:
if (pushright = true && place_meeting(x-2,y,obj_player)&& obj_player.sprite_index = spr_playerR && keyboard_check(vk_right))
{
move_towards_point(x+16,y,2);
pushright = false;
}
if (pushleft = true && place_meeting(x+2,y,obj_player)&& obj_player.sprite_index = spr_playerL && keyboard_check(vk_left))
{
move_towards_point(x-16,y,2);
pushleft = false;
}
if (pushup = true && place_meeting(x,y+2,obj_player)&& obj_player.sprite_index = spr_playerU && keyboard_check(vk_up))
{
move_towards_point(x,y-16,2);
pushup = false;
}
if (pushdown = true && place_meeting(x,y-2,obj_player)&& obj_player.sprite_index = spr_playerD && keyboard_check(vk_down))
{
move_towards_point(x,y+16,2);
pushdown = false;
}
the problem is I dont have clue how to make the object stop after 16 pixels...
Any ideas on how to limit it's movement?
Last edited: