G
GuyAkiba
Guest
So, I have a movement system similar to the one HeartBeast taught in his rpg tutorial only with eight directions and corresponding sprites. When the character is walking diagonally and then I let go of the two directional keys, the character will always idle animate either one of the directions let go but not the diagonal direction in between. You would have to time the two button release PERFECTLY which is dang near impossible. Basically, you'll never see the diagonal idle sprites we worked so hard on.
Do you guys have any ideas to mend this problem? Maybe something with an alarm? Please help...
Do you guys have any ideas to mend this problem? Maybe something with an alarm? Please help...
///Initialize The Player
event_inherited();
face = DOWN;
can_move = true;
spd = 2;
hspd = 0;
vspd = 0;
xaxis = 0;
yaxis = 0;
len = 0;
dir = 0;
state = scr_move_state;
//--------ANIMATION STUFF
// create the sprite array to handle animation (uses MACROS)
movement = IDLE;
//IDLE
sprite[RIGHT, IDLE] = spr_right;
sprite[RIGHTUP, IDLE] = spr_rightUp;
sprite[UP, IDLE] = spr_up;
sprite[UPLEFT, IDLE] = spr_rightUp;
sprite[LEFT, IDLE] = spr_right;
sprite[LEFTDOWN, IDLE] = spr_downRight;
sprite[DOWN, IDLE] = spr_down;
sprite[DOWNRIGHT, IDLE] = spr_downRight;
//MOVING
sprite[RIGHT, MOVE] = s_charRightRun;
sprite[RIGHTUP, MOVE] = s_charRightUpRun;
sprite[UP, MOVE] = s_charUpRun;
sprite[UPLEFT, MOVE] = s_charRightUpRun;
sprite[LEFT, MOVE] = s_charRightRun;
sprite[LEFTDOWN, MOVE] = s_charDownRightRun;
sprite[DOWN, MOVE] = s_charDownRun;
sprite[DOWNRIGHT, MOVE] = s_charDownRightRun;
event_inherited();
face = DOWN;
can_move = true;
spd = 2;
hspd = 0;
vspd = 0;
xaxis = 0;
yaxis = 0;
len = 0;
dir = 0;
state = scr_move_state;
//--------ANIMATION STUFF
// create the sprite array to handle animation (uses MACROS)
movement = IDLE;
//IDLE
sprite[RIGHT, IDLE] = spr_right;
sprite[RIGHTUP, IDLE] = spr_rightUp;
sprite[UP, IDLE] = spr_up;
sprite[UPLEFT, IDLE] = spr_rightUp;
sprite[LEFT, IDLE] = spr_right;
sprite[LEFTDOWN, IDLE] = spr_downRight;
sprite[DOWN, IDLE] = spr_down;
sprite[DOWNRIGHT, IDLE] = spr_downRight;
//MOVING
sprite[RIGHT, MOVE] = s_charRightRun;
sprite[RIGHTUP, MOVE] = s_charRightUpRun;
sprite[UP, MOVE] = s_charUpRun;
sprite[UPLEFT, MOVE] = s_charRightUpRun;
sprite[LEFT, MOVE] = s_charRightRun;
sprite[LEFTDOWN, MOVE] = s_charDownRightRun;
sprite[DOWN, MOVE] = s_charDownRun;
sprite[DOWNRIGHT, MOVE] = s_charDownRightRun;
///Move The Player In The Step Event
depth = -y;
if(instance_exists(obj_textbox)) {
image_speed = 0;
exit;
}
script_execute(state);
sprite_index = sprite[face, movement];
// Check if can move
if (instance_exists(o_transition)) or (instance_exists(o_menu)) {
can_move = false;
image_speed = 0;
} else {
can_move = true;
}
depth = -y;
if(instance_exists(obj_textbox)) {
image_speed = 0;
exit;
}
script_execute(state);
sprite_index = sprite[face, movement];
// Check if can move
if (instance_exists(o_transition)) or (instance_exists(o_menu)) {
can_move = false;
image_speed = 0;
} else {
can_move = true;
}
///scr_move_state
if (can_move) {
if (len == 0) {
movement = IDLE;
} else {
movement = MOVE;
}
var plusx = 0;
var plusy = 0;
// Get Direction
dir = round(point_direction(0, 0, o_input.xaxis, o_input.yaxis)/45)*45;
//Remove the "round(/45)*45" above to get full 360 degree turns
// Get The Length
if (o_input.xaxis == 0 and o_input.yaxis == 0) {
len = 0;
} else {
len = spd;
scr_get_face(dir);
}
// Get The Hspd And Vspd
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);
// Move player object
phy_position_x += hspd;
phy_position_y += vspd;
// Control The Sprite's speed and frame
image_speed = sign(len)*.2;
if (len == 0) {image_index = 0;}
// Mirror side-moving sprites
if (hspd != 0) {
image_xscale = sign(hspd);
}
}
// Create checker
if (o_input.action_key) {
var check = instance_create(x,y,o_checker);
check.phy_rotation = face*-45;
}
if (can_move) {
if (len == 0) {
movement = IDLE;
} else {
movement = MOVE;
}
var plusx = 0;
var plusy = 0;
// Get Direction
dir = round(point_direction(0, 0, o_input.xaxis, o_input.yaxis)/45)*45;
//Remove the "round(/45)*45" above to get full 360 degree turns
// Get The Length
if (o_input.xaxis == 0 and o_input.yaxis == 0) {
len = 0;
} else {
len = spd;
scr_get_face(dir);
}
// Get The Hspd And Vspd
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);
// Move player object
phy_position_x += hspd;
phy_position_y += vspd;
// Control The Sprite's speed and frame
image_speed = sign(len)*.2;
if (len == 0) {image_index = 0;}
// Mirror side-moving sprites
if (hspd != 0) {
image_xscale = sign(hspd);
}
}
// Create checker
if (o_input.action_key) {
var check = instance_create(x,y,o_checker);
check.phy_rotation = face*-45;
}
///scr_get_face();
var dir = argument[0];
face = round(dir/45);
if (face == 8) {
face = RIGHT;
}
var dir = argument[0];
face = round(dir/45);
if (face == 8) {
face = RIGHT;
}
Last edited by a moderator: