#Problem rotating player object

4 messages · Page 1 of 1 (latest)

old anvil
#

I am trying to make my player object rotate as I move but it moves for a little bit and then stops, I'm able to jump and move while jumping but that's it. My collision mask for the object is a rectangle.

//Create
hsp = 0;
vsp = 0;
grv = 0.1;
walkspd = 2;

//Step
key_left= keyboard_check(ord("A"));
key_right= keyboard_check(ord("D"));
key_jump= keyboard_check_pressed(ord("W"));


var move = key_right - key_left;

hsp = move * walkspd;

vsp = vsp + grv;

if (place_meeting(x,y+1,oWall)) and (key_jump){
        vsp = -7;
}

if (place_meeting(x+hsp,y,oWall)){
    while (!place_meeting(x+sign(hsp),y,oWall)){
        x += sign(hsp);        
    }
    hsp = 0;
    }
if hsp != 0{
    if hsp <= 1 {
        image_angle += 2;    
    }


    if hsp >= -1 {
        image_angle -= 2;    
    }
}
x += hsp;

if (place_meeting(x,y+vsp,oWall)){
    while (!place_meeting(x,y+sign(vsp),oWall)){
        y += sign(vsp);        
    }
    vsp = 0;
    }
y += vsp;

if (keyboard_check(ord("R"))){
    room_restart();    
}```
fringe blaze
#

The thing you don't wanna do is change image_angle, because it affects your collision mask.

#

Make a custom angle variable and use that instead.

#

Feed it to draw_sprite_ext() in the Draw event.