#region //move crates var _x_speed = lengthdir_x(speed_, direction_); var _y_speed = lengthdir_y(speed_, direction_); //check for moveable crates if (place_meeting(x + sign(_x_speed), y, o_crate) || place_meeting(x , y + sign(_y_speed), o_crate) || place_meeting(x + sign(_x_speed), y + sign(_y_speed), o_crate)) { // Push slowly by clamping the speed to 1 _x_speed = clamp(_x_speed, -1, 1); _y_speed = clamp(_y_speed, -1, 1); //if the crate is to the side with (instance_place(x + sign(_x_speed), y , o_crate)) { _y_speed = 0; //xcollision if ( place_meeting(x+_x_speed*3, y, o_solid)) { _x_speed = 0; } else x += sign(_x_speed); if ( place_meeting(x, y, o_solid)) { x -= sign(_x_speed); } depth = -y; //creates smoke particles can be removed if not necessary if(x != xprevious) instance_create_layer(random_range(bbox_left, bbox_right), bbox_bottom, "Instances", o_new_particle); } //if the crate is above or below with (instance_place(x , y + sign(_y_speed), o_crate)) { _x_speed = 0; //ycollision if ( place_meeting(x, y + _y_speed *3, o_solid)) { _y_speed = 0; } else y += sign(_y_speed); if ( place_meeting(x, y, o_solid)) { y -= sign(_y_speed); } depth = -y; //creates smoke particles this can be removed if not necessary if(y != yprevious) instance_create_layer(random_range(bbox_left, bbox_right), bbox_bottom, "Instances", o_new_particle); } } #endregion