HTML5 collision problems

V4NTT4BL4CK

Member
when my player collides with X walls, he gets stuck there and can't go back.

this is my code:

HTML:
#region
{
sprite_index = spr_1;


var sp = keyboard_check(ord("A")) - keyboard_check(ord("D"))
if (sp != 0) {
    if (place_free(x + Sprite4 * 5, y))

x -= sp * 5;
if (place_meeting(x+sp,y,obj_wall))
{
while (!place_meeting(x+sign(sp),y,obj_wall))
{
x = x + sign(sp);
}
sp = 0;
}
x = x + sp;



sprite_index = Sprite4;
}

if (Sprite4 != 0)


var sp = keyboard_check(vk_left) - keyboard_check(vk_right)
if (sp != 0) {
    if (place_free(x + Sprite4 * 5, y))

x -= sp * 5;
if (place_meeting(x+sp,y,obj_wall))
{
while (!place_meeting(x+sign(sp),y,obj_wall))
{
x = x + sign(sp);
}
sp = 0;
}
x = x + sp;

sprite_index = Sprite4;
}
}
#endregion
I tried too many tutorials and forums but got nothing, I don't know if I have to remove or add something in my code
 
Last edited:

curato

Member
if I am understanding correctly where you have if (place_free(x + Sprite4 * 5, y)) should be if (place_free(x + sp * 5, y))

I think maybe the type ahead might have caught you.
 
Top