# Gameplay blocks

> A character controller, cameras, enemies, effects, HUD and multiplayer, as code you own and change.

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

- **character**: a capsule that walks, runs, jumps and swims, with moving platforms, step-up, and an animated avatar. You write its `CharacterInput`, it does the rest.
- **camera_rig**: third-person follow, orbit and first-person cameras. **camera_shake** on top.
- **stalker**: an enemy that sees and hears targets, investigates, chases and searches, walking the navmesh.
- **stamina**: a run meter.
- **vfx**: effects made of particles, a flash of light, a trail and a decal, played as one.
- **world_ui** and **hud**: name tags, prompts, popups, a minimap, banners and toasts.
- **touch_controls**: a thumbstick and buttons for phones.
- **day_night**: a day and night cycle that moves the sun and moon and sets the sky, light and fog.
- **mesh_builder** and **scatter**: build simple shapes in code and scatter thousands of them, with colliders.
- **multiplayer**: players join a session and show up with their names.
- **sim_run**: run your game with no window, as fast as the CPU goes, for tests and tuning.

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

- **art_styles**: complete looks (toon, painterly, PSX, neon, lo-fi, ...) that set lighting, sky, fog, post and surface shaders in a few calls.
- **active_ragdoll**: physics-driven characters that keep their balance and react to hits.
- **editor_utils**: pieces for building your own editors and tools.

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