Drag And Drop Step Event Control questions

S

SunnySunzo

Guest
So I'm using the step event to determine the controls being input into the game not everything is in there yet because I'm transferring across from Drag and Drop coding to executable code blocks.
step controls not working.PNG
My problem is with that mess of a code going on in the "if RELEASE" part of the code, to explain what I've tried to do there:
The motion set is of course to stop the player from moving.
line 21 is intended to check if the player's current sprite is either movement animation and if it's animation is complete
then the following two lines are to change it's sprite to the neutral (standing) animation and to set it's image_speed to my preference.


To explain my sprite naming process quickly "PH" means PlaceHolder.


What I want it to do:
I want it to change to the neutral animation when no buttons are being pressed, but I don't want it to interrupt any animations, I want all animations to process and finish before it's reset to the neutral animation (so things look better, and attacks actually process) when using a keyboard_check(vk_nokey) it would interrupt everything constantly

Thank you in advance.
 
G

Gre_Lor12

Guest
So I'm using the step event to determine the controls being input into the game not everything is in there yet because I'm transferring across from Drag and Drop coding to executable code blocks.
View attachment 2729
My problem is with that mess of a code going on in the "if RELEASE" part of the code, to explain what I've tried to do there:
The motion set is of course to stop the player from moving.
line 21 is intended to check if the player's current sprite is either movement animation and if it's animation is complete
then the following two lines are to change it's sprite to the neutral (standing) animation and to set it's image_speed to my preference.


To explain my sprite naming process quickly "PH" means PlaceHolder.


What I want it to do:
I want it to change to the neutral animation when no buttons are being pressed, but I don't want it to interrupt any animations, I want all animations to process and finish before it's reset to the neutral animation (so things look better, and attacks actually process) when using a keyboard_check(vk_nokey) it would interrupt everything constantly

Thank you in advance.
Hey! Just before I post code snippets or scripts, just so i understand -

When you press no keys you want the animation for when keys are pressed to finish, then to do the 'no key' animation? :D
 
S

SunnySunzo

Guest
Hey! Just before I post code snippets or scripts, just so i understand -

When you press no keys you want the animation for when keys are pressed to finish, then to do the 'no key' animation? :D
Yeah! to help you visualise it, D is to walk right and A is to walk left, when neither are pressed the character is meant to stand still in his "standing" animation.
Which I've successfully done in my code above (if you remove line 21 it works perfectly) however the player can't punch or kick.
 
G

Gre_Lor12

Guest
Well firstly here is a tip:

When using "if" statements, use == instead of =. This is because one equals is SETTING A VALUE whilst two equals is COMPARING A VALUE.

So it just stops the animation right away?

I think I know how to help I just wanted to make sure I was correct
 
S

SunnySunzo

Guest
Whenever attacking animations occur the animation stops short.

I'll try changing == to = in the mean time
 
S

SunnySunzo

Guest
So I was working on this all last night after putting the thread up.
It's still not working properly. This is my working:
step control problems 1.PNG step control problems 2.PNG

I'm starting to think I should just start this code all again from scratch, How would yous do this?
recap: character is to currently walk left, walk right, punch with left arm, punch with right arm, kick with left leg, kick with right leg. each state has it's own animation that I want it to change to.
The release command is meant to reset the sprite back to the default animation (a simple standing breathing animation) but in this current form resets the animation and doesn't allow attacking animations to play.
 

Yal

šŸ§ *penguin noises*
GMC Elder
I'd use a state machine approach... instead of checking lots of variables, I'd check one, named 'state' (e.g. via a switch loop) and run code specific to each possible value it can have. To kick right, set state to a value named state_KickRight, and so on. In the code block for kicking right, you'd change the sprite to the kick animation facing right, in the code block for kicking left you'd change the sprite to the kick animation facing left, and so on for idling and jumping and taking damage etc. Once you start getting more than a handful of states, this approach does WONDERS to keep your code tidy.
 
S

SunnySunzo

Guest
I'd use a state machine approach... instead of checking lots of variables, I'd check one, named 'state' (e.g. via a switch loop) and run code specific to each possible value it can have. To kick right, set state to a value named state_KickRight, and so on. In the code block for kicking right, you'd change the sprite to the kick animation facing right, in the code block for kicking left you'd change the sprite to the kick animation facing left, and so on for idling and jumping and taking damage etc. Once you start getting more than a handful of states, this approach does WONDERS to keep your code tidy.
So you're saying I should give every state a number, for example the idle should be state = 1 and anything above state 1 could take it back to state 1? I like it. Could you teach me more or is there a Game Maker tutorial I can use to learn more?
 
Top