Combat Prototype 0.5.0 - Combos, HitLag and Design Epiphany
Alright...I started working on a feature update, to add a combo counter and a hit lag to the game. But in the mean time I had an epiphany about the classes I was creating. So...really I want to talk about that!😎
Due to the classes being self contained and each has a single responsibility, they could be used in many different ways together, due to a lack of hard coupling.
There is a principle in Object Oriented Design that states: favour composition over inheritance. And Godot's design is really focused on composition, especially on aggregation. And seems like my architecture for the combat system is following this principle very well so far.
Sandboxing with Nodes
I have this idea in my mind that I really want to achieve with game development:
What if we could just focus on matching the pieces together and create something completely new from what we have at our disposal?
When I was younger I played a lot with LEGO, I still do actually 😅
Anyway, and the thing that I liked to do the most was just setting up a context, and start to fit pieces one with the other building monsters, heroes, dungeons...then I picked a sheet of paper and started to design RPGs etc...
When I started understanding how Godot works and how Object Oriented Design works, I started to plan on doing the same thing: small pieces that together build a whole game system.
Yesterday I was implementing the HitLag, a node that freezes the player when a Hit lands on an opponent, to give some impact to the hit, and during that I realized that the Attack class could be used together with the Jump to make a Shoryuken attack. But all of sudden I realized that it was way more than that, every piece of my system can be mixed and matched together to create even more complex behaviors, without any headache. So I started to design this Shoryuken Attack:
I instanced an Attack, on the Player's scene. Then I defined the duration and the cooldown of that Attack. Then I added a HitBox to define the area of effect of that Attack, using a PolygonShape2D node. The HitBox asks for a Hit resource, so I created one with an abusibe amount of damage. The Shoryuken is a mix of a jump and an upper punch, so I also added a Jump as child of this Attack, with different settings from the normal Jump that the player executes when pressing the jump action.
Here is the video where I explain the Hitbox, the Hurtbox, the Attack and the Guard classes:
Finally the pieces were halfway together. I just needed a way to activate this attack and to create the sequence of events that would happen when it executes. To do that I created a new SpecialMove setting the sequence of actions to be ⬆⬆⬇⬇⬅➡👊 (up, up, down, down, left, right and attack). Then I added a new ActionChainSolver to try to solve ActionChains with that specific combination of inputs.
Then all I had to do was connecting some signals, mainly the ActionBuffer's action_chain_changed to that ActionChainSolver and also the Attack's started to the HitBox and to the Jump, with that there was some other signal connections to disable some movement during the execution of the Shoryuken.
Check out the video where I explain how this SpecialMoves are cast through the ActionBuffer and the ActionChainSolvers:
When I finished designing this I realized that...there was no limits for further Attacks creation, this is the whole pipeline already, of course I can make some other stuff, like using AnimationPlayer nodes to have a time accuracy of the events, but...things are really coming together and I'm amused and very proud and happy with the way things are going!
The next task to close the whole Combat Prototype is the Combo class, which will make use of the HitCounter and the HitBox's landed signal to create a chain of Attacks, which will be all its children. Anyway, I already have a nice design to implement that, the future is bright, and that's why I don't stop saying: keep developing. No matter what are the challenges you are facing. That's it, until the next time! 🐷