• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Game freezes



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

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);