So, I am making a script similar to Legacy of Goku's movement system. I just have one problem: I always face down when I do not press a key. I think it may have to do with the if-branches, but I do not know why. Here is the script:
CODE
/*
-Legacy of Goku-
-Walk System-
HOW TO USE:
log_walk(character name, character walk speed, stand_down, stand_up, stand_left, stand_right);
WHAT EACH ONE MEANS:
Character Name = Put the character name following your naming system (within a string and don't add 'spr_').
Character Walk Speed = How many pixels your character moves per step.
Stand_Down (Temporary Possibly) = Character standing still (down).
Stand_Up (Temporary Possibly) = Character standing still (up).
Stand_Left (Temporary Possibly) = Character standing still (left).
Stand_Right (Temporary Possibly) = Character standing still (right).
*/
direction_choice = 1;
//Put a keyboard check
if keyboard_check(vk_left) && !keyboard_check(vk_right){
if !(keyboard_check(vk_down) && keyboard_check(vk_up)){
//if image_speed = .06666666667{
if xprevious = x && yprevious = y{
execute_string('sprite_index = ' + 'spr_' + argument0 + '_walk' + '_l');
}
//}
direction_choice = 3;
image_speed = .2;
x -= argument1;
}
}
if keyboard_check(vk_right) && !keyboard_check(vk_left){
if !(keyboard_check(vk_down) && keyboard_check(vk_up)){
//if image_speed = .06666666667{
if xprevious = x && yprevious = y{
execute_string('sprite_index = ' + 'spr_' + argument0 + '_walk' + '_r');
}
//}
direction_choice = 4;
image_speed = .2;
x += argument1;
}
}
if keyboard_check(vk_down) && !keyboard_check(vk_up){
if !(keyboard_check(vk_left) && keyboard_check(vk_right)){
//if image_speed = .06666666667{
if xprevious = x && yprevious = y{
execute_string('sprite_index = ' + 'spr_' + argument0 + '_walk' + '_d');
}
//}
direction_choice = 1;
image_speed = .2;
y += argument1;
}
}
if keyboard_check(vk_up) && !keyboard_check(vk_down){
if !(keyboard_check(vk_left) && keyboard_check(vk_right)){
//if image_speed = .06666666667{
if xprevious = x && yprevious = y{
execute_string('sprite_index = ' + 'spr_' + argument0 + '_walk' + '_u');
}
//}
direction_choice = 2;
image_speed = .2;
y -= argument1;
}
}
//Check to see if no key is pressed.
if xprevious = x && yprevious = y{
image_speed = .06666666667;
if direction_choice = 2{
//execute_string('sprite_index = ' + 'spr_' + argument0 + '_stand' + '_u');
sprite_index = argument3;
}
if direction_choice = 3{
//execute_string('sprite_index =' + 'spr_' + argument0 + '_stand' + '_l');
sprite_index = argument4;
}
if direction_choice = 4{
//execute_string('sprite_index = ' + 'spr_' + argument0 + '_stand' + '_r');
sprite_index = argument5;
}
if direction_choice = 1{
//execute_string('sprite_index = ' + 'spr_' + argument0 + '_stand' + '_d');
sprite_index = argument2;
}
}
Here is the player's create event:
CODE
//sound_loop(bgm_westcity);
walk_speed = 4;
image_speed = .06666666667;
Here is the player's step event:
CODE
log_walk('gohan',walk_speed,spr_gohan_stand_d,spr_gohan_stand_u,spr_gohan_stand_l,spr_gohan_
stand_r);
Here is an image of the player (Gohan) walking:

Please help. ;-;
This post has been edited by Zinx_therpgmaker: Nov 7 2012, 12:25 PM