M
Magic-4e
Guest
Hi everyone I am working on a little project here and I have made a fully functional movement controls for the directional keys the only problem is that my animation sprites won't play when I push the buttons.
2 of them work fine(left and right) but the other 2(up and down) are always stuck on the first frame.
I looked over it a couple of times and the 2 sets of code have the exact same code and should work in the same way.
I have tried to run the up and down animation code separately and then they seemed to work and when I place them back where they belong they freeze again.
I just don't understand.
Can somebody help me?
Here is my code for the directional movement:
If you need any more information just let me know.
2 of them work fine(left and right) but the other 2(up and down) are always stuck on the first frame.
I looked over it a couple of times and the 2 sets of code have the exact same code and should work in the same way.
I have tried to run the up and down animation code separately and then they seemed to work and when I place them back where they belong they freeze again.
I just don't understand.
Can somebody help me?
Here is my code for the directional movement:
Code:
if (global.Game_End == 0)
{
if (keyboard_check(vk_left) + keyboard_check(vk_up) + keyboard_check(vk_right) + keyboard_check(vk_down))
{
if (keyboard_check(vk_left) + keyboard_check(vk_right))
{
if (keyboard_check(vk_left))
{
hspeed = -8;
if (sprite_index != IK_links_loop_spr)
{
image_index = 0;
sprite_index = IK_links_loop_spr;
image_speed = 0.5;
Direction = 3;
}
}
if (keyboard_check(vk_right))
{
hspeed = 8;
if (sprite_index != IK_rechts_loop_spr)
{
image_index = 0;
sprite_index = IK_rechts_loop_spr;
image_speed = 0.5;
Direction = 1;
}
}
}
else
{
hspeed = 0;
if (hspeed == 0)
{
if (Direction == 1)
{
sprite_index = IK_rechts_spr;
}
else
{
if (Direction == 2)
{
sprite_index = IK_voorkant_spr;
}
else
{
if (Direction == 3)
{
sprite_index = IK_links_spr;
}
else
{
if (Direction == 4)
{
sprite_index = IK_achterkant_spr;
}
}
}
}
}
}
if (keyboard_check(vk_up) + keyboard_check(vk_down))
{
if (keyboard_check(vk_up))
{
vspeed = -8;
if (sprite_index != IK_achterkant_loop_spr)
{
image_index = 0;
sprite_index = IK_achterkant_loop_spr;
image_speed = 0.5;
Direction = 4;
}
}
if (keyboard_check(vk_down))
{
vspeed = 8;
if (sprite_index != IK_voorkant_loop_spr)
{
image_index = 0;
sprite_index = IK_voorkant_loop_spr;
image_speed = 0.5;
Direction = 2;
}
}
}
else
{
vspeed = 0;
if (hspeed == 0)
{
if (Direction == 1)
{
sprite_index = IK_rechts_spr;
}
else
{
if (Direction == 2)
{
sprite_index = IK_voorkant_spr;
}
else
{
if (Direction == 3)
{
sprite_index = IK_links_spr;
}
else
{
if (Direction == 4)
{
sprite_index = IK_achterkant_spr;
}
}
}
}
}
}
}
else
{
hspeed = 0;
vspeed = 0;
if (Direction == 1)
{
sprite_index = IK_rechts_spr;
}
else
{
if (Direction == 2)
{
sprite_index = IK_voorkant_spr;
}
else
{
if (Direction == 3)
{
sprite_index = IK_links_spr;
}
else
{
if (Direction == 4)
{
sprite_index = IK_achterkant_spr;
}
}
}
}
}
}
else
{
hspeed = 0;
vspeed = 0;
if (Direction == 1)
{
sprite_index = IK_rechts_spr;
}
else
{
if (Direction == 2)
{
sprite_index = IK_voorkant_spr;
}
else
{
if (Direction == 3)
{
sprite_index = IK_links_spr;
}
else
{
if (Direction == 4)
{
sprite_index = IK_achterkant_spr;
}
}
}
}
}