A
anthropus
Guest
Hi all, im making a top down (non-commercial) fan game (realtime final fantasy 3/6!) to learn gml and have fun.
I'm trying to make the player have a legend of zelda link to the past style of movement where if link is facing up or down and walks diagonally he keeps the walking up/down sprite, and if hes facing left or right and walks diagonally he keeps the left/right walking sprite.
EDIT: like this
END EDIT
So in my move state/script i added this code, but even with it the game itself plays as if this code does not exist at all--it changes nothing that I can see.
here the the whole move script
If I remove the "currently_facing" part of the code (see below), then what you would expect to happen happens--when walking diagonally up and to the left, the walking up sprite plays, but I only want that sprite to play if the player is facing up or is already walking up (i dont want this to happen if they are facing left or right or if they are walking to the left or right).
The variable "currently_facing" is set in the create event and uses an enumerator (for the different directions), and that variable works fine in my idle state/script so i dont think theres a problem with the variable itself. but when i put that variable in my code the code seems to be rendered non-functional.
I can show more code if needed, i just didnt want to overload this post with code
PLEASE HELP! I've been racking my brains to days!
I'm trying to make the player have a legend of zelda link to the past style of movement where if link is facing up or down and walks diagonally he keeps the walking up/down sprite, and if hes facing left or right and walks diagonally he keeps the left/right walking sprite.
EDIT: like this
So in my move state/script i added this code, but even with it the game itself plays as if this code does not exist at all--it changes nothing that I can see.
Code:
if (if currently_facing==facing.upward && up && right)
{
sprite_index=sp_celes_walk_up;
image_speed=img_spd;
currently_facing=facing.upward;
}
Code:
//MOVEMENT
img_spd = .3;
spd=2;
//make the player cast magic
if (spell_button) {current_state=celes_state.cast_magic}
//move the player
if (up)
{
vspd=-spd;
sprite_index=sp_celes_walk_up;
image_speed=img_spd;
currently_facing=facing.upward;
}
if (down)
{
vspd=spd;
sprite_index=sp_celes_walk_down;
image_speed=img_spd;
currently_facing=facing.downward;
}
if (left)
{
hspd=-spd;
sprite_index=sp_celes_walk_left;
image_speed=img_spd;
currently_facing=facing.leftward;
}
if (right)
{
hspd=spd;
sprite_index=sp_celes_walk_right;
image_speed=img_spd;
currently_facing=facing.rightward;
}
//make player not move if no input
if (!up && !down) {vspd=0;}
if (!left && !right) {hspd=0;}
//stop animation for idle
if (!up && !down && !left && !right)
{
current_state=celes_state.idle;
}
//make walk up and sprite play
//for when moving diagonally if previously
//moving up and down
if (currently_facing==facing.upward && up && right)
{
sprite_index=sp_celes_walk_up;
image_speed=img_spd;
}
scr_collision();
If I remove the "currently_facing" part of the code (see below), then what you would expect to happen happens--when walking diagonally up and to the left, the walking up sprite plays, but I only want that sprite to play if the player is facing up or is already walking up (i dont want this to happen if they are facing left or right or if they are walking to the left or right).
Code:
if (up && right)
{
sprite_index=sp_celes_walk_up;
image_speed=img_spd;
currently_facing=facing.upward;
}
The variable "currently_facing" is set in the create event and uses an enumerator (for the different directions), and that variable works fine in my idle state/script so i dont think theres a problem with the variable itself. but when i put that variable in my code the code seems to be rendered non-functional.
I can show more code if needed, i just didnt want to overload this post with code
PLEASE HELP! I've been racking my brains to days!
Last edited by a moderator: