summaryrefslogtreecommitdiff
path: root/platformer/src/player.h
diff options
context:
space:
mode:
authorSchark <jordan@schark.online>2026-09-29 21:02:22 -0400
committerSchark <jordan@schark.online>2026-09-29 21:02:22 -0400
commit21404c26d3907cefa524878fb031e7a2022fb3d7 (patch)
tree38b2bb26d6d0c05447213edca4911ccc3887f474 /platformer/src/player.h
parent5f04f3ae87fb307e055d39e81f7c0c841e8a9af8 (diff)
downloadgamedev-21404c26d3907cefa524878fb031e7a2022fb3d7.tar.gz
gamedev-21404c26d3907cefa524878fb031e7a2022fb3d7.zip
Game world test with updated movement
Diffstat (limited to '')
-rw-r--r--platformer/src/player.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/platformer/src/player.h b/platformer/src/player.h
index 4d8fdc6..e6fd033 100644
--- a/platformer/src/player.h
+++ b/platformer/src/player.h
@@ -16,8 +16,9 @@
* 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)
- * PLAYER_SKID on ground, braking after pulling the stick back at
+ * PLAYER_SKID, on ground, braking after pulling the stick back at
* full run; retreating_movement is on
+ * PLAYER_WALL_HANG in air, clinging to a hangable wall and sliding down
* } PlayerState;
*
* typedef enum JumpKind { which jump the player is in the air from
@@ -35,9 +36,10 @@
* float forward_speed; ground speed along facing_yaw, m/s (>= 0)
* PlayerState state;
* bool heightened_movement; on for PLAYER_SECOND_JUMP_WINDOW s after
- * landing a normal or retreat jump, and for the whole
- * second jump. While on, A gives the second
- * jump. Later moves will read it too.
+ * landing a normal or retreat jump, and for the
+ * whole second jump, retreat jump, wall hang
+ * and every wall jump. On the ground, A gives the second
+ * jump; in the air, it lets the player wall hang.
* float heightened_timer; s left before heightened_movement ends
* (not counted down during the second jump)
* bool retreating_movement; on for the whole skid (PLAYER_SKID) and
@@ -49,6 +51,15 @@
* float skid_speed; forward_speed when the skid began
* float skid_yaw; direction the skid slides (the old run
* direction; the player already faces the stick)
+ * float wall_time; s since the current wall hang began
+ * float wall_jump_yaw; where a wall jump from this hang launches: the
+ * approach direction mirrored off the wall
+ * bool has_last_wall; a wall was jumped off since the last landing
+ * Vec3 last_wall_normal; that wall's surface: which way it faces...
+ * float last_wall_plane; ...and where its face lies along that
+ * direction. That surface can't be hung on
+ * again until the player lands (no climbing
+ * one wall, even one built from several boxes)
* } Player;
*
* void player_init(Player *p, Vec3 spawn);
@@ -61,8 +72,8 @@
*
* CONVENTIONS: Include guard: PLAYER_H.
*
- * NOT IN SCOPE: Health, animation, extra moves beyond the second jump and the
- * skid's retreat jump (see the README roadmap).
+ * NOT IN SCOPE: Health, animation, extra moves beyond the second jump, the
+ * skid's retreat jump and the wall hang (see the README roadmap).
*
* DONE WHEN: main.c and render.c compile against this header alone.
* ============================================================
@@ -77,13 +88,15 @@
/* SM64-style "actions". Add states here only when a new move needs one;
* see the README roadmap (triple jump, long jump, wall kick, ...). The second
* and retreat jumps didn't need one: they're a JUMP with a different launch
- * (see JumpKind). The skid did, because it follows its own ground rules. */
+ * (see JumpKind). The skid and wall hang did, because each follows its own
+ * movement rules. */
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) */
- PLAYER_SKID /* on ground, braking after pulling back at full run */
+ PLAYER_SKID, /* on ground, braking after pulling back at full run */
+ PLAYER_WALL_HANG /* in air, clinging to a hangable wall and sliding down */
} PlayerState;
/* Which jump the player is in the air from. It decides the top speed in the
@@ -107,6 +120,11 @@ typedef struct Player {
float skid_time; /* s since the current skid began */
float skid_speed; /* forward_speed when the skid began */
float skid_yaw; /* direction the skid slides; facing_yaw already points at the stick */
+ float wall_time; /* s since the current wall hang began */
+ float wall_jump_yaw; /* a wall jump's launch direction: the approach mirrored off the wall */
+ bool has_last_wall; /* a wall was jumped off since the last landing... */
+ Vec3 last_wall_normal; /* ...facing this way... */
+ float last_wall_plane; /* ...with its face here along that direction; no regrab until landing */
} Player;
void player_init(Player *p, Vec3 spawn);