summaryrefslogtreecommitdiff
path: root/platformer/src/player.h
diff options
context:
space:
mode:
authorSchark <jordan@schark.online>2026-09-23 23:40:11 -0400
committerSchark <jordan@schark.online>2026-09-23 23:40:11 -0400
commit23ef8bc20310bdfad52b07a3f1e4e61c98896841 (patch)
tree007cc1d6d73ebb38d2e06422d4050f769dd65535 /platformer/src/player.h
parentdab65412376d1b73381446f969c1461c24169811 (diff)
downloadgamedev-23ef8bc20310bdfad52b07a3f1e4e61c98896841.tar.gz
gamedev-23ef8bc20310bdfad52b07a3f1e4e61c98896841.zip
Working demogit add README.md src/
Diffstat (limited to '')
-rw-r--r--platformer/src/player.h25
1 files changed, 25 insertions, 0 deletions
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 */