1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

"Hotline miami" styled doors without physics

Discussion in 'Programming' started by Jdown79, May 24, 2018.

  1. Jdown79

    Jdown79 Member

    Joined:
    Aug 21, 2016
    Posts:
    69
    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?
     
  2. Niels

    Niels Member

    Joined:
    Jun 22, 2016
    Posts:
    828
    Don't think hotline Miami uses physics either.
     
  3. flerpyderp

    flerpyderp Member

    Joined:
    Apr 26, 2018
    Posts:
    209
    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.
     
  4. Jdown79

    Jdown79 Member

    Joined:
    Aug 21, 2016
    Posts:
    69
    @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?
     
  5. Jdown79

    Jdown79 Member

    Joined:
    Aug 21, 2016
    Posts:
    69
    //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?
     
  6. flerpyderp

    flerpyderp Member

    Joined:
    Apr 26, 2018
    Posts:
    209
    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;
    
     
    Alex.Memerony likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice