var i,move_check,h_spd,v_spd;
h_spd=0;
v_spd=0;
if keyboard_check(vk_up) v_spd -= 5;
if keyboard_check(vk_down) v_spd += 5;
if keyboard_check(vk_right) h_spd += 5;
if keyboard_check(vk_left) h_spd -= 5;
for (i = abs(h_spd); i > 0; i -= 1;)
{
move_check = sign(h_spd) * i;
if !place_meeting(x + move_check, y, obj_Wall) {x += move_check; break;}
if !place_meeting(x + move_check, y-i, obj_Wall) y -= i/2;
if !place_meeting(x + move_check, y+i, obj_Wall) y += i/2;
}
for (i = abs(v_spd); i > 0; i -= 1;)
{
move_check = sign(v_spd) * i;
if !place_meeting(x, y + move_check, obj_Wall) {y += move_check; break;}
if !place_meeting(x-i, y + move_check, obj_Wall) x -= i/2;
if !place_meeting(x+i, y + move_check, obj_Wall) x += i/2;
}This works great when colliding with the object obj_Wall, but how do I add other objects to collide with? If I add them directly to the end of the current code it messes everything up, making the player go too fast and not stop when colliding with anything.
I greatly appreciate anyone who can help me. I'm using GM 8.0 by the way



Find content
Male











