Skip to content

Pickups and Stats

Pickups add bonus gameplay progression by modifying player stats at runtime. They connect map symbols, runtime pickup entities, stat effects, sprite visibility, and HUD feedback.

Pickups and stats

Runtime collectibles that update gameplay state before rendering

Pickup symbols are discovered from the bonus map, stored as runtime entities, consumed by proximity checks, then reflected by sprites and HUD panels without rewriting the static map.

01
map-level symbols

Each symbol becomes a typed runtime pickup in app->bonus.pickups.

* Health +HP, clamped to max
) Armor +Armor before HP damage
@ Ammo +Ammo for weapon actions
/ Score +Score progression value
02
runtime storage

Gameplay state is separate from static map text.

typedef struct s_pickup
{
  double x;
  double y;
  int    type;
  int    collected;
} t_pickup;
03
pickups_update()

Executed once per frame before render layers consume the state.

01 skip collected pickups
02 measure player distance
03 apply typed stat effect
04 mark item collected
05 hide from sprite rebuild
04
effect model

Stat gains are type-driven and bounded by bonus constants.

hp    = min(hp + HP_GAIN, HP_MAX);
armor = min(armor + ARMOR_GAIN, ARMOR_MAX);
ammo  = min(ammo + AMMO_GAIN, AMMO_MAX);
score = min(score + SCORE_GAIN, SCORE_MAX);

// damage policy
armor absorbs first, remaining damage hits hp
interactive stat simulation

Collect pickups, apply damage, and observe clamping + collected state.

HP
60
Armor
30
Ammo
45
Score
200

Collect a pickup to apply its stat effect.

post-update guarantees

After the pickup update step, every consumer sees coherent state.

map.grid is not mutatedstats stay clampedHUD reads post-update valuescollected pickups stop rendering

Pickups are represented by bonus sprite/tile markers in map content:

  • * for health
  • @ for ammo
  • ) for armor
  • / for score

During initialization, these symbols are discovered and stored in app->bonus.pickups through bonus_pickups_rebuild(...), separate from static map text. Each runtime pickup stores its world position, type, and collected flag.

Every frame, the pickup update path checks active pickups against the player position. If the player is inside pickup radius, the typed effect is applied, the pickup is marked collected, and the sprite layer is rebuilt only when the active pickup set actually changes.

Bonus stats are stored in app->bonus.stats:

  • hp
  • armor
  • ammo
  • score

Stat gains and maximum values are controlled by bonus constants. Health, armor, and ammo are clamped to their configured maxima. Damage handling consumes armor first, then applies any remaining damage to health.

Pickups integrate with:

  • sprites, because active pickups become renderable sprite entities
  • HUD, because stat values are displayed in screen-space panels
  • frame update order, because pickup effects are applied before rendering
  • cleanup, because pickup arrays are owned by the bonus runtime context

After the pickup update step:

  • collected pickups are no longer active gameplay pickups
  • stats remain within configured bounds
  • HUD reads post-update values
  • sprite rebuilding/rendering reflects collected state
  • map.grid remains unchanged
  • srcs_bonus/pickups/pickups_api.c
  • srcs_bonus/pickups/pickups_update.c
  • srcs_bonus/pickups/pickups_effects.c
  • srcs_bonus/pickups/pickups_sprites.c
  • srcs_bonus/hud/hud_status.c
  • include/structs_bonus.h
  • include/defines_bonus.h