Tower Blocks: Episode 1 - Building the 3D Scene

Published on

Welcome to the first episode of our Tower Blocks remake using C and Raylib. In this first part we focus on setting the stage for everything to come: creating a clean and minimal 3D environment with blocks, a movable camera and basic input handling.


What We Covered

This foundational work gives us a visually engaging stack of blocks and a working 3D scene that is interactive right out of the gate.


Design Insights

A 3D Game Doesn’t Have to Be Complex

One of the goals of this series is to show how you can build meaningful and visual gameplay without needing a full engine. Raylib gives you a simple 3D API that’s ideal for building things step by step.

Stacking is Visually Rewarding

Even with no animations, physics or scoring, the act of stacking blocks and watching them climb the screen feels satisfying. That’s a signal we are on the right track and a good foundation for expanding mechanics.


Implementation Highlights

Block Struct

We use a basic struct to represent a block’s position, size and color:

typedef struct {
    Vector3 position;
    Vector3 size;
    Color color;
} Block;

Each new block is based on a default_block, with its Y-position offset by its index in the stack and its color slightly adjusted.

Dynamic Block Array

We use stb_ds.h to maintain a dynamically growing array of placed blocks:

Block *placed_blocks = nullptr;
arrpush(placed_blocks, newBlock);

Camera Tracking

Each time a block is added we reposition the camera to track the top of the tower:

camera->position.y = 50 + 2 * placed_blocks_count;
camera->target.y = 2 * placed_blocks_count;

This gives the impression of infinite vertical growth.


What’s Next?

In the next episode we will give the player something to do. We’ll introduce the moving block mechanic.

From here the project becomes a lot more dynamic and game-like.

Project Code

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