Gameplay blocks

The engine gives you the systems. Gameplay blocks give you the parts most games start with, so you don't write a character controller on day one of a jam.

Blocks are a module: a folder of engine-written code that's copied into your project, not linked from the engine. Read them, change them, delete what you don't use. The starting template already has them; any other project adds them with:

Add the blocks to a project
hz/hzbuild module add gameplay_blocks

What's there

Each block's header is its manual, with a usage example at the top: src/gameplay/<block>/<block>.h in your project.

How they fit in

Blocks follow the same shape as the engine. Per-entity blocks are ECS components and systems: you call <block>_init once and <block>_schedule in your frame's scope, and their state is on entities, so you can set them up in the editor too. The few main-lane ones (touch controls, effects) are called before or after the scope.

A player character with a camera
// zero fields take the block's defaults
CharacterTuning tuning = {.walk_speed = 4, .run_speed = 7};
EcsEntity player = character_spawn(world, "Player", spawn_point, &tuning);
// {0}: the default avatar
character_avatar_add(world, player, &(CharacterAvatarDesc){0});

The starting template is the best example: a character, a follow camera, the day and night sky and touch controls, in one file.

Other modules

Add any of them the same way, with hz/hzbuild module add <name>.