From 23ef8bc20310bdfad52b07a3f1e4e61c98896841 Mon Sep 17 00:00:00 2001 From: Schark Date: Wed, 23 Sep 2026 23:40:11 -0400 Subject: Working demogit add README.md src/ --- platformer/src/player.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'platformer/src/player.h') diff --git a/platformer/src/player.h b/platformer/src/player.h index bedfaf4..35e5b6a 100644 --- a/platformer/src/player.h +++ b/platformer/src/player.h @@ -45,4 +45,29 @@ #ifndef PLAYER_H #define PLAYER_H +#include "controls.h" +#include "math3d.h" +#include "physics.h" + +/* SM64-style "actions". Add states here only when a new move needs one; + * see the README roadmap (double jump, long jump, wall kick, ...). */ +typedef enum PlayerState { + PLAYER_IDLE, /* on ground, not moving */ + PLAYER_RUN, /* on ground, moving (walk vs run is just speed) */ + PLAYER_JUMP, /* in air, going up after a jump */ + PLAYER_FALL /* in air, going down (or walked off something) */ +} PlayerState; + +typedef struct Player { + Body body; /* position / velocity / on_ground */ + float facing_yaw; /* radians; facing vector = (sin(yaw), 0, cos(yaw)) */ + float forward_speed; /* ground speed along facing_yaw, m/s (>= 0) */ + PlayerState state; +} Player; + +void player_init(Player *p, Vec3 spawn); +void player_reset(Player *p, Vec3 spawn); +void player_update(Player *p, const Input *in, float camera_yaw, float dt); +const char *player_state_name(PlayerState s); + #endif /* PLAYER_H */ -- cgit v1.2.3-18-g5258