• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Animation[Solved]

W

White_heart_of_Blood

Guest
I have this script and it's not working PLs help me
The script is in my player movement script witch is in my players
step event.
sc_animation:
Code:
// Left or Right
if (xprevious < x) {
    image_speed = 1;
    sprite_index = sp_player_right;
} else if (xprevious > x) {
    image_speed = 1;
    sprite_index = sp_player_left;
} else if (xprevious == x) {
    image_speed = 0;
    image_index = 0;
}

// Up or Down
if (yprevious < y) {
    image_speed = 1;
    sprite_index = sp_player_down;
} else if (yprevious > y) {
    image_speed = 1;
    sprite_index = sp_player_up;
} else if (yprevious == y) {
    image_speed = 0;
    image_index = 0;
}
sc_movement:
Code:
sc_input();

// Moving Right
if (r_key) {
    hspd = spd;
    direc = 0;
}

// Moving Left
if (l_key) {
    hspd = -spd;
    direc = 1;
}

// Moving down
if (d_key) {
    vspd = spd;
    direc = 3;
}

// Moving up
if (u_key) {
    vspd = -spd;
    direc = 4;
}

// Check for !moving right or left
if ((!r_key && !l_key) or (r_key && l_key)) {
    hspd = 0;
}

// Check for !moving up or down
if ((!d_key && !u_key) or (d_key && u_key)) {
    vspd = 0;
}

// Horizontal Colliosins
if (place_meeting(x+hspd, y, ob_soild)) {
    while (!place_meeting(x+sign(hspd), y, ob_soild)) {
        x += sign(hspd);
    }
    hspd = 0;
}

// Move Horizontal
x += hspd;

// Vertical Colliosins
if (place_meeting(x, y+vspd, ob_soild)) {
    while (!place_meeting(x, y+sign(vspd), ob_soild)) {
        y += sign(vspd);
    }
    vspd = 0;
}

// Move Vertical
y += vspd;

sc_player_animation();
Thats all the code that envoles the movement/animation
pls help me I be a noob
 
Last edited by a moderator:
W

White_heart_of_Blood

Guest
I was just wonding if I did somthing wrong or not?
 
W

White_heart_of_Blood

Guest
Update I got it to go to one frame doesn't animate after that. Help?
Code:
// Animation
if (x != xprevious || y != yprevious) {
    image_index = 1;
    if (xprevious > x) {
        sprite_index = sp_player_left;
    } else if (xprevious < x) {
        sprite_index = sp_player_right;
    }
    
    if (yprevious > y) {
        sprite_index = sp_player_up;
    } else if (yprevious < y) {
        sprite_index = sp_player_down;
    }
} else if (xprevious = x and yprevious = y) {
    image_speed = 0;
    image_index = 0;
}
 
Top