I
ivoslobodjanac
Guest
Hello everyone I was following the tutorial on how to make a 2d plataformer. The thing is after writing the code I rund the game and whenever I touch a wall the game stops and freezes any help would be appreciated. Here is the line of code
Code:
key_left = keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
key_down = keyboard_check(vk_down);
key_up = keyboard_check(vk_up);
key_jump = keyboard_check_pressed(vk_space);
// calculate movement
var move= key_right - key_left;
hsp = move * walksp;
// Collition
if (place_meeting(x+hsp,y,obj_wall))
{
while (!place_meeting(x+sign(hsp),y,obj_wall))
{
x = x sign(hsp);
}
hsp = 0;
}
x = x + (hsp);