walking animations mouse directioned topdown

kureoni

Member
im not being able to use the sprite_index to change the sprite animation based on the position of the cursor on the y axis
(when the mouse is above the character, we should be able to see him by his back, and when the mouse is under the character, it should be the other way around)
any ideas?
 

kureoni

Member
GML:
var move_left = keyboard_check(ord( "A"));
var move_right = keyboard_check(ord("D"));
var move_down = keyboard_check(ord("S"));
var move_up = keyboard_check(ord("W"));

if (move_left && place_free(x-spd,y)){
    x-=spd;
}
if (move_right && place_free(x+spd,y)){
    x+=spd;
}
if (move_down && place_free(x, y+spd)){
    y+=spd;
}
if (move_up && place_free(x, y-spd)){
    y-=spd;
}


if (mouse_x > x) image_xscale = 3 else image_xscale = -3;{
}


if(x = xprevious){
sprite_index = spr_player
}

if(x != xprevious){
sprite_index = spr_player_walk
}
thats the player's walking code, its a topdown game and the position the sprite faces is directioned by the mouse position
 

DPMlofty

Member
GML:
if(x = xprevious && y = yprevious){
sprite_index = spr_player
}

if(x != xprevious && y = y previous){
sprite_index = spr_player_walk
}

try this, and other thing, you collisions arent the best, u should change it too
 

kureoni

Member
GML:
if(x = xprevious && y = yprevious){
sprite_index = spr_player
}

if(x != xprevious && y = y previous){
sprite_index = spr_player_walk
}

try this, and other thing, you collisions arent the best, u should change it too
i did some sh*t and now it works in the y axis but the x axis stopped working LMAO
lots of stress
 
Top