Hello, DeeTox here.
I recently started working on a Game Maker project I named "Woody's Adventure" (mentioned it during my introduction) and I now face a bit of a problem with getting a 3 stepped attack to work smoothly. Right now I have been able to jump through the steps from step one to step three in the attack, but I don't think I've used the best solution.
I have 3 individual sprites representing the different steps in the attack.
spr_atk_r_1, spr_atk_r_2, and spr_atk_r_3. These sprites have 8 subimages each (don't know if this really matters to you), and what I want to do is when I hit "z" (the attack button) he goes from standing still to the first step (spr_atk_r_1), after 5 of the subimages I want it to go to the second step if "z" is hit again. After another 5 subimages on the spr_atk_r_2 I want it to go to the third step if "z" is hit.
Here's the code that takes me through the steps like I want, but not in the smoothest way:
var atk;
atk=0;
if keyboard_check_pressed(ord('Z'))
{
atk=1;
sprite_index=spr_atk_r_1;
image_index=0;
image_speed=0.4;
alarm+=1;
if keyboard_check_pressed(ord('Z')) and atk==1 and alarm>=1
{
atk=2;
sprite_index=spr_atk_r_2;
image_index=0;
image_speed=0.4;
if keyboard_check_pressed(ord('Z')) and atk==2 and alarm>=2
{
atk=3;
sprite_index=spr_atk_r_3;
image_index=0;
image_speed=0.4;
}
}
}
My question is; Are there any other way to solve this with less code and better result?