ssbmDao / SimpleFightingGame

A simplistic fighting game
MIT License
0 stars 0 forks source link

Generalized characters to a Fighter scene. Generalized input handling… #2

Closed godofgrunts closed 3 years ago

godofgrunts commented 3 years ago

…. Finished basic controls.

Switched from AnimatedSprite to AnimationPlayer as I needed more control with the animations. This also gives us the benefit of syncing sound and using the more robust AnimationPlayer API for other things if we need too.

Added a enum STATE machine. Only has ATTACK, GUARD, and FREE right now. Hit stun or Block stun are possible candidates.

I'm using a very simple state machine to prevent the player from moving when attacking or guarding. When attacking, we yield to the animation player and wait for the animation is done before we give control back to the player (so they can't move while attacking).

When guarding, the player is unable to move until they release guard.

Added a facing variable because I was running into issues with the raycast flipping the left player when the game started. Now it checks which way the character is facing (default to right) and flips only if the raycast and the facing are different.

Figured out a neat way to generalize the inputs using match by exporting a variable called "player_number". I set the left player to "1" and the right player to "2".