Day 22

YES I FINALLY FIXED IT YEEEESSS
I finally fixed the problem I've been trying to fix for weeks :))))

The problem was (if you haven't been reading my past posts) is that my character wouldn't wall jump properly after i implemented sprites into the game and after i fixed that my character wouldn't animate when I move. I asked everywhere online and they gave me some tips and code and none if it worked. Then I sat there and asked my self "Why doesn't this work" so I looked through my code and tried editing everything through trial and error and i finally fixed it. I used "else if" statements instead of just "if" statements.

THIS IS MY CODE

//Defining facingright variable
if (move = 1) {
    facingright = 1
}
if (move = -1) {
    facingright = 0
}

//Animation

    //Run Right
if (grounded) and (facingright) and (move = 1) {
    sprite_index = spr_player_run_right;
    image_speed = 0.1;
}
    //Run Left
else if (grounded) and (!facingright) and (move = -1) {
    sprite_index = spr_player_run_left;
    image_speed = 0.1;
}
    //Jump and idle right
else if (facingright) {
    sprite_index = spr_player_idle_right;
}
    //Jump and idle left
else if (!facingright) {
    sprite_index = spr_player_idle_left;
}

And that fixed it :)

Tomorrow I will work on probably making sprites for the ground etc.

No comments:

Post a Comment