Legacy GM In-air rotation and set angle when landing

B

BandiPat

Guest
While I do have in-air rotation down, I'm still trying to figure out how to keep the nearest angle when landing.

Code:
//In-air rotation
if (!place_meeting(x,y+1,obj_wall) &&
    !place_meeting(x+1,y,obj_wall) &&
    !place_meeting(x-1,y,obj_wall) &&
    !place_meeting(x,y-1,obj_wall) &&
    !place_meeting(x+1,y+1,obj_wall) &&
    !place_meeting(x-1,y+1,obj_wall) &&
    !place_meeting(x-1,y-1,obj_wall) &&
    !place_meeting(x+1,y-1,obj_wall))
    {
        if key_right
            {
            image_angle -= 6;
            }
       if -key_left
            {
            image_angle += 6;
            }
    }
else if image_angle < 135
        {
        image_angle = 90;
        }
else if image_angle >135
        {
        image_angle = 180;
        }
      
else if image_angle <225
        {
        image_angle = 180;
        }
else if image_angle >225
        {
        image_angle = 270;
        }

else if image_angle <45
        {
        image_angle = 0;
        }
else if image_angle >45
        {
        image_angle = 90;
        }
What I'm trying to do is, let's say the player lands on the ground or hits a wall and the closest angle is at 90. So then the player object would stay at an angle of 90 until the angle needs to be changed again.
Being kind of a nooblewt at more advanced code like this, I tried doing the above code but only angle 270 seems to work as I intended it to. I also can't figure out going from 270 to 0, simply because I would have to use "image_angle<225" twice as far as I can think, and I know that would botch it up even more.
 
Top