summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchark <jordan@schark.online>2026-09-29 18:46:53 -0400
committerSchark <jordan@schark.online>2026-09-29 18:46:53 -0400
commit923b5928eeafd9bf969b95c4d49699d280b1ce0f (patch)
tree0210db826b4cbdfc91704dc6655652b96cbd36b4
parent25992eb0baa1be5b49e8732e4b63734cdafe3b80 (diff)
downloadgamedev-923b5928eeafd9bf969b95c4d49699d280b1ce0f.tar.gz
gamedev-923b5928eeafd9bf969b95c4d49699d280b1ce0f.zip
Double jump foundation
-rw-r--r--platformer/README.md4
-rw-r--r--platformer/game_feel.md30
-rw-r--r--platformer/src/config.h12
-rw-r--r--platformer/src/main.c12
-rw-r--r--platformer/src/player.c136
-rw-r--r--platformer/src/player.h18
6 files changed, 183 insertions, 29 deletions
diff --git a/platformer/README.md b/platformer/README.md
index 73fd75f..33d509c 100644
--- a/platformer/README.md
+++ b/platformer/README.md
@@ -91,7 +91,7 @@ The game is designed for a gamepad (Xbox-style layout names; GLFW maps other pad
| Left stick | move (tilt amount = speed, relative to the camera) |
| Right stick | orbit camera (around the player; their spot on screen is kept) |
| Right stick click | recenter: swing the camera behind the player, centered |
-| A (south button) | jump (hold longer to jump higher) |
+| A (south button) | jump (hold longer to jump higher); press again within 0.3 s of landing for a second jump 1.75× as high |
| Back / Select | reset player to spawn |
| Start | quit |
@@ -188,7 +188,7 @@ Suggested fill-in order (each step can be compiled before moving on):
- Richer level geometry: slopes, moving platforms, step-up onto small ledges, hand-built or loaded levels
- Camera collision (the camera can currently pass through tall platforms)
- Loading levels
-- SM64-style extra moves: double/triple jump, long jump, wall kick, ground pound
+- SM64-style extra moves: triple jump, long jump, wall kick, ground pound (the second jump exists)
- Character model and animation
- Audio
- On-screen text/HUD beyond the FPS counter in the top-right corner
diff --git a/platformer/game_feel.md b/platformer/game_feel.md
index 166d476..c6c8201 100644
--- a/platformer/game_feel.md
+++ b/platformer/game_feel.md
@@ -68,6 +68,26 @@ and eased, not snappier.
is the continuous-physics figure) and a tap gives about 0.72 m. Level geometry is sized against 2.33 m.
- **A jump pressed on the landing tick is never lost.** The FALL state hands off to the ground
logic on the same tick it detects landing.
+- **The second jump (SM64's double jump).** Landing any first jump, hop or full, turns on
+ `heightened_movement` for `PLAYER_SECOND_JUMP_WINDOW` (0.3 s, 18 ticks counting the landing tick).
+ Pressing A while it's on launches at `PLAYER_SECOND_JUMP_VELOCITY` (18.41 m/s): a full second jump
+ reaches **4.08 m** (1.75× the first, measured at 60 Hz, 54 ticks of airtime), and tapping A gives
+ about 1.4 m. `heightened_movement` stays on for the whole second jump, whatever its length, and turns
+ off when it lands, so the second jump can't chain into another.
+- **The second jump trades speed for height.** Until it lands, the top speed is
+ `PLAYER_SECOND_JUMP_MAX_SPEED` (5 m/s) instead of 6. Taking off at a full run bleeds the extra
+ speed off gradually at `PLAYER_SECOND_JUMP_SLOWDOWN` (3.5 m/s²), reaching 5 m/s after 19 ticks (0.32 s)
+ of the 0.90 s jump. While the player is over the cap, the stick only turns them; the bleed happens
+ whatever the stick does. A full-speed second jump covers about 4.8 m (it was 5.4 m uncapped).
+ **Don't bleed at `PLAYER_AIR_ACCEL`:** the first version did (6 → 4 m/s in 0.25 s), and it felt like
+ hitting a wall of syrup right at takeoff. After landing, normal ground accel brings 6 m/s back in about 0.23 s. There's
+ no extra state for this: `jump_number == 2` already means "in the second jump", and `top_speed()`
+ in `player.c` reads it. Walking off an edge and landing
+ also turns it off. A press on the landing tick already counts.
+- **`heightened_movement` is a named player state on purpose.** It's a field on `Player`, separate
+ from the IDLE/RUN/JUMP/FALL action, because later moves are meant to key off it. The title bar
+ shows `| heightened` while it's on (the title refreshes every 0.25 s, so the 0.3 s window may
+ blink briefly or not show at all; the second jump itself always shows it).
- **SM64-style circling is intentional.** Controls stay purely camera-relative even while the camera
swings on its own, so holding the stick sideways during a camera swing makes the player run a
wide arc (about 12 m radius, 24 m across, at 6 m/s). The user explicitly chose this over locking the stick direction.
@@ -157,7 +177,8 @@ New automatic camera behaviors should follow the same approach: slow, eased, and
- **The level is a test space**, like SM64's pre-level sandbox: flat ground plus 40 seeded-random box
platforms (`WORLD_SEED`, so every run is the same layout). Spawn is kept clear (4 m).
- **Heights are sized to the jump:** ground blocks top out at 2.0 m (below the 2.33 m jump); floating
- slabs sit at 2.6–4.2 m, reached by jumping from a block. Only 9 of 16 floating slabs have a block close
+ slabs sit at 2.6–4.2 m, reached by jumping from a block. The 4.08 m second jump can reach 14 of
+ the 16 slabs straight from the ground; the two with tops at 4.11 m and 4.17 m still need a block. Only 9 of 16 floating slabs have a block close
enough to jump from; reachability isn't guaranteed yet. That count was made at a 9 m/s run. At 6 m/s a
full running jump covers only about 4.0 m horizontally (it was about 6 m), so fewer slabs may be
reachable now.
@@ -179,7 +200,8 @@ New automatic camera behaviors should follow the same approach: slow, eased, and
- **The camera tracks every full jump vertically.** The running bound's vertical span (0.22 of the
window) is smaller than a full jump on screen (about 0.38), so the camera rises and falls with each
jump. SM64's approach, framing vertically against the ground under the player rather than their
- airborne height, was offered but not yet decided.
+ airborne height, was offered but not yet decided. The 4.08 m second jump makes this 1.75× as
+ noticeable.
- **Holding sideways never reaches the back quarter.** With circling, the player's "right" turns
with the camera, so the swing chases forever. It only settles when the player steers to hold a line.
- **The starting pitch (20°) differs from the auto-tilt target (15°),** so every session begins with a
@@ -216,6 +238,10 @@ New automatic camera behaviors should follow the same approach: slow, eased, and
| Ground accel | 30 → 12 → 7 → 8.4 m/s² (0.30 → 0.60 → 0.72 s to top speed; the last step kept 0.72 s at 6 m/s) | 8.4 m/s² |
| Ground friction | 40 → 16 → 9.5 → 11.3 m/s² (0.23 → 0.45 → 0.53 s stop; the last step kept 0.53 s at 6 m/s) | 11.3 m/s² |
| Air accel | 30% of ground accel → its own constant, value kept | 9 m/s² |
+| Second jump height | 2× (19.66 m/s) → 1.75× (18.41 m/s), sets `heightened_movement` | 18.41 m/s |
+| Second jump window | 0.5 s → 0.3 s after landing | 0.3 s |
+| Second jump top speed | 6 m/s (same as running) → 4 → 5 m/s until it lands (4 felt a tad harsh) | 5 m/s |
+| Second jump slowdown | air accel 9 m/s² (0.25 s, "wall of syrup") → own rate 3.5 m/s² (0.60 s) | 3.5 m/s² |
| Standstill turn | turn rate → instant at speed 0 → instant only past 90° (ground only) | > 90° instant |
---
diff --git a/platformer/src/config.h b/platformer/src/config.h
index 8816e98..c767709 100644
--- a/platformer/src/config.h
+++ b/platformer/src/config.h
@@ -49,6 +49,14 @@
* PLAYER_AIR_ACCEL 9.0f m/s^2 speeding up toward target speed in air
* PLAYER_JUMP_VELOCITY 14.0f m/s upward at jump start (~2.4 m apex)
* PLAYER_JUMP_CUT 0.50f vel.y multiplier when A released while rising
+ * PLAYER_SECOND_JUMP_VELOCITY 18.41f m/s upward at second-jump start (1.75x
+ * the first jump's height, ~4.1 m apex)
+ * PLAYER_SECOND_JUMP_WINDOW 0.3f s after landing a jump that the second
+ * jump is available (heightened_movement)
+ * PLAYER_SECOND_JUMP_MAX_SPEED 5.0f m/s top horizontal speed during the second
+ * jump (it trades speed for height)
+ * PLAYER_SECOND_JUMP_SLOWDOWN 3.5f m/s^2 how fast speed above that top speed
+ * bleeds off in the air (gradual on purpose)
*
* Physics
* GRAVITY 40.0f m/s^2 (stronger than real 9.8 on purpose:
@@ -146,6 +154,10 @@
#define PLAYER_AIR_ACCEL 9.0f /* m/s^2 toward target speed in air; higher = more steerable jumps */
#define PLAYER_JUMP_VELOCITY 14.0f /* m/s upward at jump start; higher = taller jumps (~2.4 m apex at 14) */
#define PLAYER_JUMP_CUT 0.50f /* vel.y multiplier on early A release; lower = shorter taps */
+#define PLAYER_SECOND_JUMP_VELOCITY 18.41f /* m/s upward for the second jump; tuned to 1.75x the first jump's height (4.08 m at 60 Hz) */
+#define PLAYER_SECOND_JUMP_WINDOW 0.3f /* s after landing a jump that A gives the second jump; higher = more forgiving timing */
+#define PLAYER_SECOND_JUMP_MAX_SPEED 5.0f /* m/s top horizontal speed until the second jump lands; lower = more vertical, less distance */
+#define PLAYER_SECOND_JUMP_SLOWDOWN 3.5f /* m/s^2 bleed from run speed down to that top speed; lower = more gradual, higher = more abrupt */
/* ---- Physics ----------------------------------------------------------- */
#define GRAVITY 40.0f /* m/s^2; stronger than real 9.8 on purpose, real gravity feels floaty */
diff --git a/platformer/src/main.c b/platformer/src/main.c
index 0435737..61972cc 100644
--- a/platformer/src/main.c
+++ b/platformer/src/main.c
@@ -61,9 +61,10 @@
*
* - Debug readout for tuning (a few times per second, not every frame):
* window_set_title() with something like
- * "platformer | RUN | speed 7.42 m/s | y 1.83 | pad"
- * using player_state_name(), forward_speed, body.pos.y and
- * input.using_gamepad. This is our "HUD" until text rendering exists.
+ * "platformer | RUN | speed 7.42 m/s | y 1.83 | pad | heightened"
+ * using player_state_name(), forward_speed, body.pos.y,
+ * input.using_gamepad, and "| heightened" only while
+ * player.heightened_movement is on. This is our "HUD" until text rendering exists.
*
* - Shutdown in reverse order: render_shutdown() -> window_shutdown().
*
@@ -98,12 +99,13 @@
static void update_debug_title(const Player *player, const Input *input)
{
char title[128];
- snprintf(title, sizeof title, "%s | %s | speed %.2f m/s | y %.2f | %s",
+ snprintf(title, sizeof title, "%s | %s | speed %.2f m/s | y %.2f | %s%s",
WINDOW_TITLE,
player_state_name(player->state),
player->forward_speed,
player->body.pos.y,
- input->using_gamepad ? "pad" : "keyboard");
+ input->using_gamepad ? "pad" : "keyboard",
+ player->heightened_movement ? " | heightened" : "");
window_set_title(title);
}
diff --git a/platformer/src/player.c b/platformer/src/player.c
index cbb2c1c..88df0c4 100644
--- a/platformer/src/player.c
+++ b/platformer/src/player.c
@@ -14,7 +14,8 @@
* IMPLEMENT:
* - player_init / player_reset: body.pos = spawn, vel = 0, on_ground = true,
* body.half_width = PLAYER_HALF_WIDTH, body.height = PLAYER_HEIGHT,
- * facing_yaw = 0, forward_speed = 0, state = PLAYER_IDLE.
+ * facing_yaw = 0, forward_speed = 0, state = PLAYER_IDLE,
+ * heightened_movement = false, heightened_timer = 0, jump_number = 0.
*
* - player_update(p, in, camera_yaw, dt). Use one static helper per state
* (update_idle / update_run / update_jump / update_fall), dispatched by a
@@ -43,18 +44,45 @@
* - State: forward_speed > 0 -> RUN, otherwise IDLE.
*
* C. Jump (from IDLE / RUN): if in->jump_pressed and body.on_ground:
- * body.vel.y = PLAYER_JUMP_VELOCITY; on_ground = false; state = JUMP.
+ * on_ground = false; state = JUMP, and then either
+ * - heightened_movement on: the SECOND jump, SM64's double jump.
+ * body.vel.y = PLAYER_SECOND_JUMP_VELOCITY (1.75x the height);
+ * jump_number = 2. heightened_movement stays on for the whole jump,
+ * however long it lasts. Until it lands, the top speed is
+ * PLAYER_SECOND_JUMP_MAX_SPEED instead of PLAYER_MAX_SPEED (see D).
+ * - otherwise a normal jump: body.vel.y = PLAYER_JUMP_VELOCITY;
+ * jump_number = 1.
+ *
+ * C2. heightened_movement: landing from a normal jump (jump_number == 1,
+ * short hop or full) turns it on with heightened_timer =
+ * PLAYER_SECOND_JUMP_WINDOW. Landing any other way (from the second
+ * jump, or after walking off an edge) turns it off. Every tick,
+ * unless the player is in the second jump, the timer counts down and
+ * it turns off at 0. WHY a named state rather than a private "can
+ * double jump" flag: later moves will key off it too.
*
* D. Air movement (JUMP / FALL): the same as B, but the turn rate is
* multiplied by PLAYER_AIR_CONTROL, accel is PLAYER_AIR_ACCEL, there's
* no instant turn from a standstill, and there's NO friction when the
* stick is released (you keep your momentum, like SM64).
- * - Variable jump height: in JUMP, if !in->jump_held and vel.y > 0,
+ * - Top speed: steering aims for top_speed() * mag, where top_speed()
+ * is PLAYER_SECOND_JUMP_MAX_SPEED while jump_number == 2 and
+ * PLAYER_MAX_SPEED otherwise. While forward_speed is ABOVE it (a
+ * full run into the second jump), the stick only turns: the extra
+ * speed bleeds off at PLAYER_SECOND_JUMP_SLOWDOWN, whatever the
+ * stick does. So a 6 m/s run into the second jump eases down to
+ * 5 m/s over ~0.3 s. WHY a separate, gentle rate: slowing at
+ * PLAYER_AIR_ACCEL (~0.25 s) felt like hitting a wall of syrup
+ * right at takeoff. 6 m/s only comes back (through normal ground
+ * accel) after landing. WHY no new state:
+ * jump_number == 2 already means "in the second jump".
+ * - Variable jump height (both jumps): in JUMP, if !in->jump_held and vel.y > 0,
* multiply vel.y by PLAYER_JUMP_CUT ONCE (don't repeat it every tick;
* either switch to FALL right away or keep a flag). Comment WHY: tapping A
* gives a hop, holding it gives a full jump.
* - JUMP -> FALL when vel.y <= 0.
- * - FALL -> IDLE/RUN when body.on_ground (landing).
+ * - FALL -> IDLE/RUN when body.on_ground (landing; apply C2 first, so
+ * an A press on the landing tick already gets the second jump).
* - If the player is on the ground state-wise but body.on_ground is false
* (walked off a platform edge) -> FALL.
*
@@ -68,7 +96,7 @@
* accelerations in m/s^2, and every one of them multiplies by dt.
* No magic numbers; everything comes from config.h.
*
- * NOT IN SCOPE: Double/triple jump, long jump, wall kick, ground pound,
+ * NOT IN SCOPE: Triple jump, long jump, wall kick, ground pound,
* skidding/turnaround, slopes, coyote time, jump buffering.
* Leave a short comment at the state enum pointing to the
* README roadmap as the place to grow.
@@ -77,8 +105,10 @@
* PLAYER_MAX_SPEED after a noticeable build-up. Turning is quick but
* not instant while moving, and instant for big turns from a standstill. Letting go
* of the stick skids the player to a short, smooth stop. A tap of A
- * gives a short hop and holding A gives a full ~2.4 m jump. The
- * player lands cleanly back in IDLE/RUN.
+ * gives a short hop and holding A gives a full ~2.4 m jump. Pressing
+ * A within 0.3 s of landing gives a second jump 1.75x as high, with
+ * heightened_movement on from that landing until the second jump
+ * lands. The player lands cleanly back in IDLE/RUN.
* ============================================================
*/
@@ -109,12 +139,25 @@ static Wish compute_wish(const Input *in, float camera_yaw)
return wish;
}
+/* The fastest the player may go right now. The second jump trades
+ * horizontal speed for its extra height, until it lands. */
+static float top_speed(const Player *p)
+{
+ return p->jump_number == 2 ? PLAYER_SECOND_JUMP_MAX_SPEED : PLAYER_MAX_SPEED;
+}
+
+/* Turns the facing toward the stick, at most turn_rate. */
+static void turn(Player *p, Wish wish, float turn_rate, float dt)
+{
+ p->facing_yaw = approach_angle(p->facing_yaw, wish.yaw, turn_rate * dt);
+}
+
/* Turns toward the stick and speeds up toward a speed set by how far it's
* pushed. Shared by ground and air movement; the air passes smaller rates. */
static void steer(Player *p, Wish wish, float turn_rate, float accel, float dt)
{
- p->facing_yaw = approach_angle(p->facing_yaw, wish.yaw, turn_rate * dt);
- p->forward_speed = approachf(p->forward_speed, PLAYER_MAX_SPEED * wish.mag, accel * dt);
+ turn(p, wish, turn_rate, dt);
+ p->forward_speed = approachf(p->forward_speed, top_speed(p) * wish.mag, accel * dt);
}
/* Standing still vs walking vs running is only a matter of speed. */
@@ -123,6 +166,47 @@ static PlayerState grounded_state(const Player *p)
return p->forward_speed > 0.0f ? PLAYER_RUN : PLAYER_IDLE;
}
+/* C. Leaving the ground. While heightened_movement is on (just after landing
+ * a normal jump), A gives the higher second jump instead, like SM64's
+ * double jump. heightened_movement stays on through the whole second jump. */
+static void start_jump(Player *p)
+{
+ if (p->heightened_movement) {
+ p->body.vel.y = PLAYER_SECOND_JUMP_VELOCITY;
+ p->jump_number = 2;
+ } else {
+ p->body.vel.y = PLAYER_JUMP_VELOCITY;
+ p->jump_number = 1;
+ }
+ p->body.on_ground = false;
+ p->state = PLAYER_JUMP;
+}
+
+/* C2. Touching down. Landing a normal jump (a hop or a full one) opens the
+ * short window for the second jump; landing any other way closes it, so
+ * the second jump can't chain into another one. */
+static void land(Player *p)
+{
+ if (p->jump_number == 1) {
+ p->heightened_movement = true;
+ p->heightened_timer = PLAYER_SECOND_JUMP_WINDOW;
+ } else {
+ p->heightened_movement = false;
+ }
+ p->jump_number = 0;
+}
+
+/* C2. The window after landing runs out on its own. It doesn't during the
+ * second jump: heightened_movement lasts as long as that jump does. */
+static void count_down_heightened(Player *p, float dt)
+{
+ if (!p->heightened_movement || p->jump_number == 2)
+ return;
+ p->heightened_timer -= dt;
+ if (p->heightened_timer <= 0.0f)
+ p->heightened_movement = false;
+}
+
/* B + C. IDLE and RUN: full control, friction when the stick is released,
* and the only place a jump can start. */
static void update_ground(Player *p, const Input *in, Wish wish, float dt)
@@ -147,27 +231,38 @@ static void update_ground(Player *p, const Input *in, Wish wish, float dt)
}
p->state = grounded_state(p);
- if (in->jump_pressed) {
- p->body.vel.y = PLAYER_JUMP_VELOCITY;
- p->body.on_ground = false;
- p->state = PLAYER_JUMP;
- }
+ if (in->jump_pressed)
+ start_jump(p);
}
/* D. Air movement: weaker steering, and NO friction when the stick is
* released, so you keep your momentum like in SM64. */
static void air_steer(Player *p, Wish wish, float dt)
{
+ float air_turn_rate = PLAYER_TURN_RATE * PLAYER_AIR_CONTROL;
+
+ /* Faster than the top speed allows (a full run into the second jump):
+ * shed the extra slowly, whatever the stick says, so takeoff doesn't feel
+ * like hitting a wall. The stick can still turn. */
+ if (p->forward_speed > top_speed(p)) {
+ if (wish.mag > 0.0f)
+ turn(p, wish, air_turn_rate, dt);
+ p->forward_speed = approachf(p->forward_speed, top_speed(p),
+ PLAYER_SECOND_JUMP_SLOWDOWN * dt);
+ return;
+ }
+
if (wish.mag > 0.0f)
- steer(p, wish,
- PLAYER_TURN_RATE * PLAYER_AIR_CONTROL, PLAYER_AIR_ACCEL, dt);
+ steer(p, wish, air_turn_rate, PLAYER_AIR_ACCEL, dt);
}
/* FALL: in the air, going down. Landing hands straight over to the ground
- * logic on the same tick, so a jump pressed on the landing tick isn't lost. */
+ * logic on the same tick, so a jump pressed on the landing tick isn't lost
+ * (and already counts as the second jump). */
static void update_fall(Player *p, const Input *in, Wish wish, float dt)
{
if (p->body.on_ground) {
+ land(p);
p->state = grounded_state(p);
update_ground(p, in, wish, dt);
return;
@@ -188,7 +283,8 @@ static void update_jump(Player *p, const Input *in, Wish wish, float dt)
air_steer(p, wish, dt);
/* Variable jump height: letting go of A while rising cuts the upward speed.
- * Tapping A gives a short hop, holding it gives the full jump. Switching to
+ * Tapping A gives a short hop, holding it gives the full jump (for the
+ * second jump too). Switching to
* FALL right away makes sure the cut happens only once. */
if (!in->jump_held) {
p->body.vel.y *= PLAYER_JUMP_CUT;
@@ -206,6 +302,9 @@ void player_init(Player *p, Vec3 spawn)
p->facing_yaw = 0.0f;
p->forward_speed = 0.0f;
p->state = PLAYER_IDLE;
+ p->heightened_movement = false;
+ p->heightened_timer = 0.0f;
+ p->jump_number = 0;
}
void player_reset(Player *p, Vec3 spawn)
@@ -216,6 +315,7 @@ void player_reset(Player *p, Vec3 spawn)
void player_update(Player *p, const Input *in, float camera_yaw, float dt)
{
Wish wish = compute_wish(in, camera_yaw);
+ count_down_heightened(p, dt);
/* IDLE and RUN share one helper: they differ only in speed. */
switch (p->state) {
diff --git a/platformer/src/player.h b/platformer/src/player.h
index 35e5b6a..5f8d963 100644
--- a/platformer/src/player.h
+++ b/platformer/src/player.h
@@ -25,6 +25,15 @@
* which matches mat4_rotate_y in math3d.h.
* 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 jump, and for the whole
+ * second jump. While on, A gives the second
+ * jump. Later moves will read it too.
+ * float heightened_timer; s left before heightened_movement ends
+ * (not counted down during the second jump)
+ * int jump_number; which jump the player is in the air from:
+ * 0 = none (walked off an edge, or grounded),
+ * 1 = a normal jump, 2 = the second jump
* } Player;
*
* void player_init(Player *p, Vec3 spawn);
@@ -37,7 +46,8 @@
*
* CONVENTIONS: Include guard: PLAYER_H.
*
- * NOT IN SCOPE: Health, animation, extra moves (see README roadmap).
+ * NOT IN SCOPE: Health, animation, extra moves beyond the second jump (see the
+ * README roadmap).
*
* DONE WHEN: main.c and render.c compile against this header alone.
* ============================================================
@@ -50,7 +60,8 @@
#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, ...). */
+ * see the README roadmap (triple jump, long jump, wall kick, ...). The second
+ * jump didn't need one: it's a JUMP with a higher launch (see jump_number). */
typedef enum PlayerState {
PLAYER_IDLE, /* on ground, not moving */
PLAYER_RUN, /* on ground, moving (walk vs run is just speed) */
@@ -63,6 +74,9 @@ typedef struct Player {
float facing_yaw; /* radians; facing vector = (sin(yaw), 0, cos(yaw)) */
float forward_speed; /* ground speed along facing_yaw, m/s (>= 0) */
PlayerState state;
+ bool heightened_movement; /* second jump available (or in progress); later moves read it too */
+ float heightened_timer; /* s left before heightened_movement ends; paused during the second jump */
+ int jump_number; /* airborne from: 0 = no jump (walked off an edge), 1 = normal, 2 = second */
} Player;
void player_init(Player *p, Vec3 spawn);