In Episode 5 we introduced custom lighting shaders to give our blocks depth and style. This time we are focusing on something more subtle but equally impactful: what happens after the game ends.
Instead of immediately resetting the game, we add a new state where the tower gracefully collapses piece by piece, giving the player a moment to breathe and reflect… and giving the game a satisfying rhythm between rounds.
What We Covered
- Introduced a new
RESETTING_STATEbetween Game Over and restart - Added a
Removalstruct to each block to track its animation state - Applied staggered animation delays so blocks collapse from top to bottom
- Shrunk and rotated each block using
MatrixScaleandMatrixRotate - Cleaned up removed blocks once they’re done animating
- Deferred game reset until collapse animation is complete
Design Insights
Why Animate Game Reset?
Previously, the game instantly reset when the player clicked after losing. It felt jarring. Now:
- The blocks visually leave the scene
- The player gets a soft moment of feedback
- The pacing feels more intentional and polished
These transitions, even if simple, greatly improve how finished the game feels.
Staggered Collapse for Extra Satisfaction
Each block gets a delay based on its position in the stack:
block->removal.delay = * 0.05;
This creates a downward ripple: the higher blocks vanish first, the base vanishes last.
Implementation Highlights
New Removal Struct
typedef struct Removal;
Each block now tracks its own shrinking/rotation animation.
Animate on Game Over
When the player clicks after losing, we move into RESETTING_STATE and call:
;
This sets up each block’s removal delay.
Animate + Delete Over Time
Each frame, we update:
block->removal.scale = 1.0 - t;
block->removal.rotation = t * 7;
If t > 0.9, we remove the block from the array.
What’s Next?
Episode 7 will be our last one where we will introduce sounds to our game.
We are already in a phase where small additions make a big difference. The game’s core is stable and we are making it shine.
Project Code
You will find the complete source code here: tower-blocks