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
- Set up a 3D orthographic camera
- Drew a single cube using
DrawCube()andDrawCubeWires() - Created a simple
Blockstruct to represent stackable game blocks - Implemented input handling to spawn new blocks
- Automatically adjusted the camera upward as the stack grows
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 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;
;
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.
- The block will slide in from one side
- We will alternate movement direction along X and Z axes
- The player will time their placement with a press
- We will start building toward actual gameplay
From here the project becomes a lot more dynamic and game-like.
Project Code
You will find the complete source code here: tower-blocks