"Hotline miami" styled doors without physics

J

Jdown79

Guest
Hey guys, Just wondering the best way on how to tackle the "physics" door style without physics enabled.
I was going to try a while collision, move image_angle, but I don't imagine it would work (currently at work)
Has anyone succeeded in this? any references or documents you can recommend?

Niels

Member
Don't think hotline Miami uses physics either.

flerpyderp

Member
The angle of the door changes at a set rate each time the player collides with it, and gradually slows to a halt. What direction it swings in depends on the player's coordinates relative to the current angle of the door. If it swings all the way open and hits the wall, it swings in the other direction at a slightly reduced speed. If it reaches closed position while below a certain speed, the door remains closed instead of continuing to change angle.

Also note, probably not desired behaviour, but since the doors in Hotline Miami behave this way - you can trap the door between the player and a wall and remain stationary, and the door will continue to bounce between them until the player moves.

J

Jdown79

Guest
@Niels Oh really? I thought it was physics based. I guess thats a good thing for me haha.

So origin point for door as the hinge point, on collision with player, change image_angle with a force multiplier that slowly decreases?

J

Jdown79

Guest
//create
force_multi = 15;
force_slow = 1;
force = 0;

//step
if (place_meeting(x,y,obj_player.x,obj_player.y) && !place_meeting(x-force_multi,y,obj_wall.x,obj_wall.y))
{
force = force_multi;
force -= force_slow;

image_angle -= force;
}
if force <= 0 { force = 0};
So I've just written this up, haven't tested as im at work, but is this along the lines of what I should be trying?

flerpyderp

Member
//create
force_multi = 15;
force_slow = 1;
force = 0;

//step
if (place_meeting(x,y,obj_player.x,obj_player.y) && !place_meeting(x-force_multi,y,obj_wall.x,obj_wall.y))
{
force = force_multi;
force -= force_slow;

image_angle -= force;
}
if force <= 0 { force = 0};
So I've just written this up, haven't tested as im at work, but is this along the lines of what I should be trying?
Along the lines, but this won't be functional. You're using four arguments for the function place_meeting when it only takes three. The variable "force" only decreases by "force_slow" while a collision is true, as does the image_angle change.

Just a basic idea, excluding collision with the wall and the specifics regarding what direction the door should swing in:

Create:
Code:
``````force = 0;
force_multi = 15;
force_slow = 0.87;

dir = 1;``````
Step:
Code:
``````if (place_meeting(x,y,obj_player))
{
//Include code regarding player coordinates relative to the door to set the variable "dir" to 1 or -1

force = force_multi * dir;
}

force *= force_slow;
image_angle += force;``````