Tower Blocks: Episode 2 - Core Game Mechanics

Published on

In Episode 1 we built a basic 3D scene with stackable blocks. This time we take a huge leap forward and implement the core game mechanics by adding animated block movement, placement logic and a simple win/loss system.

This is where it truly starts to feel like a game.


What We Covered


Design Insights

The Core Loop

At the heart of Tower Blocks is the challenge of timing your placement. That means we need:

This episode introduces all of that, laying the groundwork for later polish like animations, lighting and sound.

Alternating Axis = Instant Variety

By alternating between X and Z axis movement we make each block a bit trickier to align. A small detail with a big impact on gameplay feel.


Implementation Highlights

Movement Struct

We defined a Movement struct to encapsulate axis, direction and speed:

typedef struct {
    float speed;
    Direction direction;
    Axis axis;
} Movement;

Each moving block gets a direction (FORWARD or BACKWARD) and axis (X or Z), and moves between set bounds.

Placement Logic

When the player places a block:

bool PlaceBlock(Game *game) {
    // calculate overlap
    // snap or trim if needed
    // return false if missed
}

Basic UI Overlays

We introduced READY_STATE, PLAYING_STATE and GAME_OVER_STATE and use them to:

What’s Next?

In Episode 3 we will focus on polish:

This is where the project goes from working to fun.

Project Code

You will find the complete source code here: tower-blocks