S
Swork1
Guest
I am trying to have 2 blocks able to move right and left without colliding through each other when hitting a wall. The problem is whenever I move right, the left block wont move unless I hit the right key again which leaves a gap between the 2 blocks. (which I don't want).
Starting Position
If I Move Right From the Starting Position
If I Move Left From the Starting Position
Create
Step
Starting Position
If I Move Right From the Starting Position
If I Move Left From the Starting Position
Create
Code:
hsp = 0;
vsp = 0;
grv = 0;
walksp = 96;
Code:
//Get Player Input
key_left = keyboard_check_pressed(vk_left);
key_right = keyboard_check_pressed(vk_right);
key_down = keyboard_check(vk_down);
//Calculates Movement
var move = key_right - key_left;
hsp = move * walksp;
//Horizontal Collison
if (place_meeting(x+hsp,y,ObjectBoundry))
{
hsp = 0;
}
if(place_meeting(x+hsp,y,ObjectBlock_1))
{
hsp = 0;
}
x = x + hsp;