Nimbin[12]?Games / Entropie / entropie/src/world/chips.h

Entropie git · main

Entropie festival game; first steps

sdl c game entropie cmake · first commit 2026-10-10 · last commit 2026-11-02 (18 hours ago) · synced 10 hours ago

C 88.5% Markdown 9.1% GLSL 2.3%
git clone https://git.christianimmanuel.de/games/Entropie.gitwget https://git.christianimmanuel.de/games/Entropie/archive/Entropie.tar.gz
entropie/src/world/chips.h 1.5 KB · 50 lines raw
#ifndef WORLD_CHIPS_H
#define WORLD_CHIPS_H

/*
 * Bits that fly off work: wood chips off the axe (they land and lie a while)
 * and sawdust out of the chainsaw (it drifts down and is gone); puffs of
 * cigarette smoke.
 */

#include <stdbool.h>

#include "math/linalg.h"
#include "render/mesh.h"
#include "render/renderer.h"
#include "world/terrain.h"

#define CHIP_MAX 400

typedef struct {
    Vec3  p, v;
    float life;     /* seconds left */
    float size;
    float angle, spin;
    Vec3  color;
    bool  dust;
    bool  smoke;    /* a puff of smoke: drifts up, grows, gone */
    bool  down;     /* lying on the ground */
} Chip;

typedef struct {
    Chip     chips[CHIP_MAX];
    int      next;
    unsigned rng;
    Mesh     mesh;  /* a small white block (tinted per chip) ... */
    Mesh     puff;  /* ... and a ball for smoke */
} Chips;

void Chips_init(Chips *c);
void Chips_destroy(Chips *c);
/* n bits from at, flying out along dir (roughly); dust: sawdust, else wood chips. */
void Chips_spray(Chips *c, Vec3 at, Vec3 dir, int n, bool dust);
/* A little puff of smoke at at (breathed out along dir, or off a cigarette's tip: small). */
void Chips_puff(Chips *c, Vec3 at, Vec3 dir, bool small);
/* Smoke off a fire (a big soft puff, rising). */
void Chips_smoke(Chips *c, Vec3 at);
/* wind: m/s the air moves (smoke and dust go with it). */
void Chips_update(Chips *c, const Terrain *terrain, Vec3 wind, float dt);
void Chips_draw(const Chips *c, Renderer *renderer);

#endif /* WORLD_CHIPS_H */