diff options
| author | Schark <jordan@schark.online> | 2026-09-23 23:09:55 -0400 |
|---|---|---|
| committer | Schark <jordan@schark.online> | 2026-09-23 23:09:55 -0400 |
| commit | dab65412376d1b73381446f969c1461c24169811 (patch) | |
| tree | 27adfec438a9bd9f3c96a740ab54016df5f68b80 /platformer/src/controls.h | |
| parent | af03f388cbcff795158ea8345b5c876470229e8b (diff) | |
| download | gamedev-dab65412376d1b73381446f969c1461c24169811.tar.gz gamedev-dab65412376d1b73381446f969c1461c24169811.zip | |
Base prompts
Diffstat (limited to '')
| -rw-r--r-- | platformer/src/controls.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/platformer/src/controls.h b/platformer/src/controls.h new file mode 100644 index 0000000..dbbe936 --- /dev/null +++ b/platformer/src/controls.h @@ -0,0 +1,46 @@ +/* + * ============================================================ + * FILE: controls.h + * + * PURPOSE: Defines `Input`, the one abstract snapshot of what the player + * is asking for this tick. Gameplay code reads Input and never + * reads a raw device, so the player and camera don't care whether + * a gamepad or the keyboard produced it. + * + * FITS IN: main.c calls controls_poll() once per fixed tick and passes the + * Input to player_update() and camera_update(). + * + * INTERFACE: Use these exact names: + * + * typedef struct Input { + * Vec2 move; left stick after the deadzone. Length is 0..1. + * +x = right, +y = FORWARD (stick pushed up). + * Vec2 look; right stick after the deadzone. Length is 0..1. + * +x = orbit camera right, +y = tilt camera up. + * bool jump_held; A is down this tick + * bool jump_pressed; A went down THIS tick (true for one tick only) + * bool reset_pressed; Back/Select went down this tick (one tick only) + * bool quit_pressed; Start (or Esc) went down this tick (one tick only) + * bool using_gamepad; true if a gamepad produced this Input (debug info) + * } Input; + * + * void controls_init(void); call after window_init() + * void controls_poll(Input *out); call once per FIXED TICK (not once per + * frame). The "pressed" edges are + * worked out tick-to-tick, so a press + * is never lost or counted twice. + * + * Include <stdbool.h> and "math3d.h" (for Vec2). + * + * CONVENTIONS: Include guard: CONTROLS_H. + * + * NOT IN SCOPE: Rebinding, multiple players, mouse look, rumble. + * + * DONE WHEN: player.c and camera.c can be written against Input alone, + * without including GLFW. + * ============================================================ + */ +#ifndef CONTROLS_H +#define CONTROLS_H + +#endif /* CONTROLS_H */ |
