Posted October 21, 2023 by Jummit
When analyzing which entities and components I would need to implement the game, something very quickly became apparent: I’d need some kind of state machine to keep track of what can happen when.
Now, in ECS there are multiple ways to achieve this, but I ended up with what I call “Stack-based ECS”:
To explain how it works I’ll use an example from the game:
First, the game is in the “Match” state, which is where a game of Access Battlers happens:
Initially, we are in the setup phase, where the AI starts placing cards:
The stack:
After the AI finishes, the AI state is popped off, and it’s the players turn:
When the player is done, the Match system pops the Setup state, and moves on to the next.
It’s midnight, my goal was to get good regular sleep so I’ve certainly failed at that. But I’d really like to keep these blog posts up, so there you have it!