zampa
Member
So i have a moving wall object in my game that follows a path, said walls move other objects along it's path.
I need that if the player collides with let's say the bottom part of the wall (while the wall moves down) to still be able to move normally left and right, and it kinda does it.
See when i launch the game the first time the collision work perfectly:
es: the wall moves to the right i am able to move up and down with no problem
but at the first "turn" the wall makes it doesn't work anymore, even if it moves right again (the direction that previously worked) it kinda stutters, (like it stops for 1-2 frames)
It's highly probable that it has to do with other parts of the code, but could you take a look at the code and see if there is anything wrong that i do not see?
thanks
I need that if the player collides with let's say the bottom part of the wall (while the wall moves down) to still be able to move normally left and right, and it kinda does it.
See when i launch the game the first time the collision work perfectly:
es: the wall moves to the right i am able to move up and down with no problem
but at the first "turn" the wall makes it doesn't work anymore, even if it moves right again (the direction that previously worked) it kinda stutters, (like it stops for 1-2 frames)
It's highly probable that it has to do with other parts of the code, but could you take a look at the code and see if there is anything wrong that i do not see?
thanks
Code:
var next_x = x+(wall_hspd*wall_move_spd);
var next_y = y+(wall_vspd*wall_move_spd);
if(place_meeting(next_x,next_y,obj_parent_object))
{
var n_bbox_right = bbox_right + wall_hspd;
var n_bbox_left = bbox_left + wall_hspd;
var n_bbox_top = bbox_top + wall_vspd;
var n_bbox_bottom = bbox_bottom + wall_vspd;
#region // move wall close to object
if(place_meeting(next_x,y,obj_parent_object))
{
while(!place_meeting(x+sign(wall_hspd),y,obj_parent_object)) x += wall_hspd;
}
if(place_meeting(x,next_y,obj_parent_object))
{
while(!place_meeting(x,y+sign(wall_vspd),obj_parent_object)) y += wall_vspd;
}
#endregion
#region // move objects away from wall
if(wall_hspd != 0)
{
collision_rectangle_list(n_bbox_left,n_bbox_top,n_bbox_right,n_bbox_bottom,obj_parent_object,true,true,lst_wall_collision,false);
var list_len = ds_list_size(lst_wall_collision);
while(list_len >0)
{
var check_obj = ds_list_find_value(lst_wall_collision,list_len-1);
check_obj.x += wall_hspd*wall_move_spd;
list_len--;
}
ds_list_clear(lst_wall_collision);
}
if(wall_vspd != 0)
{
collision_rectangle_list(n_bbox_left,n_bbox_top,n_bbox_right,n_bbox_bottom,obj_parent_object,false,true,lst_wall_collision,false);
var list_len = ds_list_size(lst_wall_collision);
while(list_len >0)
{
var check_obj = ds_list_find_value(lst_wall_collision,list_len-1);
check_obj.y += wall_vspd*wall_move_spd;
list_len--;
}
ds_list_clear(lst_wall_collision);
}
#endregion
}