diff options
| author | Schark <jordan@schark.online> | 2026-09-29 19:20:15 -0400 |
|---|---|---|
| committer | Schark <jordan@schark.online> | 2026-09-29 19:20:15 -0400 |
| commit | 5f04f3ae87fb307e055d39e81f7c0c841e8a9af8 (patch) | |
| tree | 9842c6c7106b0afc36eb9f7a09c5db4166b0f412 /platformer | |
| parent | 0b99c49ef6ff75e3adfa08cd03dc6bc4b1602742 (diff) | |
| download | gamedev-5f04f3ae87fb307e055d39e81f7c0c841e8a9af8.tar.gz gamedev-5f04f3ae87fb307e055d39e81f7c0c841e8a9af8.zip | |
Slightly alter first jump top speed
Diffstat (limited to 'platformer')
| -rw-r--r-- | platformer/game_feel.md | 11 | ||||
| -rw-r--r-- | platformer/src/config.h | 9 | ||||
| -rw-r--r-- | platformer/src/player.c | 50 |
3 files changed, 60 insertions, 10 deletions
diff --git a/platformer/game_feel.md b/platformer/game_feel.md index e6862a8..6fc4a2e 100644 --- a/platformer/game_feel.md +++ b/platformer/game_feel.md @@ -68,6 +68,16 @@ 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. +- **A normal jump rewards a full run with a little extra speed.** In a normal jump the top speed is + `PLAYER_JUMP_MAX_SPEED` (7 m/s). Up to run speed (6 m/s × stick) the air accelerates as usual; past + it, only at `PLAYER_JUMP_BOOST_ACCEL` (1.5 m/s²), so a full jump from a full run builds evenly: + 6.25 / 6.50 / 6.75 / 7.00 m/s at 0.17 / 0.33 / 0.50 / 0.67 s, landing at 6.97. A short hop lands at + about 6.5, and a standing jump only reaches 6. After landing with the stick held, the extra fades at + `PLAYER_OVERSPEED_DECEL` (2 m/s²): back to 6 m/s in 29 ticks (0.48 s), **never in one step**. + Releasing the stick still uses normal friction (7 → 0 in 0.62 s). Knock-on effects: a skid right + after landing starts from ~7 m/s (a longer slide), and a second jump bleeds 7 → 5 in 0.57 s. + Hopping again just after the 0.2 s window closes keeps you at about 6.5–7 m/s indefinitely (a + bunny hop). That's a speed tech we haven't decided on yet. - **The second jump (SM64's double jump).** Landing any first jump (hop or full) or a retreat jump turns on `heightened_movement` for `PLAYER_SECOND_JUMP_WINDOW` (0.2 s, 12 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 @@ -264,6 +274,7 @@ New automatic camera behaviors should follow the same approach: slow, eased, and | 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 → 0.2 s after landing | 0.2 s | | Second jump from | normal jump landings → also retreat jump landings | both | +| Normal jump top speed | 6 m/s (run speed) → 7 m/s, built at 1.5 m/s², eased back at 2 m/s² after landing | 7 m/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² | | Skid | none (full-speed U-turn) → 18 m/s² even braking, turn at the end (0.33 s) → face the stick at once, glide-then-plant curve (power 2) | 0.5 s | diff --git a/platformer/src/config.h b/platformer/src/config.h index f496ee1..23d85ec 100644 --- a/platformer/src/config.h +++ b/platformer/src/config.h @@ -49,6 +49,12 @@ * 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_JUMP_MAX_SPEED 7.0f m/s top horizontal speed during a normal + * jump (a little past the run speed) + * PLAYER_JUMP_BOOST_ACCEL 1.5f m/s^2 how slowly speed builds past the run + * speed in a normal jump (~7 m/s by landing) + * PLAYER_OVERSPEED_DECEL 2.0f m/s^2 how slowly speed above the run speed + * eases back down on the ground * 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.2f s after landing a jump that the second @@ -169,6 +175,9 @@ #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_JUMP_MAX_SPEED 7.0f /* m/s top horizontal speed in a normal jump; higher = bigger reward for jumping at full run */ +#define PLAYER_JUMP_BOOST_ACCEL 1.5f /* m/s^2 build past run speed in a normal jump; higher = reaches PLAYER_JUMP_MAX_SPEED sooner */ +#define PLAYER_OVERSPEED_DECEL 2.0f /* m/s^2 ease back down to run speed after landing (stick held); lower = keeps the extra speed longer */ #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.2f /* s after landing a normal or retreat 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 */ diff --git a/platformer/src/player.c b/platformer/src/player.c index b4341de..7fe0d76 100644 --- a/platformer/src/player.c +++ b/platformer/src/player.c @@ -39,6 +39,11 @@ * - If mag > 0: facing_yaw = approach_angle(facing_yaw, wish_yaw, * PLAYER_TURN_RATE * dt); forward_speed = approachf(forward_speed, * PLAYER_MAX_SPEED * mag, PLAYER_GROUND_ACCEL * dt) + * - Faster than PLAYER_MAX_SPEED with the stick pushed (landing from a + * normal jump at up to PLAYER_JUMP_MAX_SPEED): ease back down to + * PLAYER_MAX_SPEED at PLAYER_OVERSPEED_DECEL instead, so the extra + * speed fades over ~0.5 s rather than vanishing on landing. + * (Releasing the stick still uses the normal friction.) * - Else: forward_speed = approachf(forward_speed, 0, * PLAYER_GROUND_FRICTION * dt). Accel and friction are low on * purpose: starts build up and stops skid briefly, so the player @@ -96,9 +101,15 @@ * no instant turn from a standstill, and there's NO friction when the * stick is released (you keep your momentum, like SM64). * - Top speed: steering aims for top_speed() * mag, where top_speed() - * is PLAYER_SECOND_JUMP_MAX_SPEED in the second jump, + * is PLAYER_JUMP_MAX_SPEED in a normal jump, + * PLAYER_SECOND_JUMP_MAX_SPEED in the second jump, * PLAYER_RETREAT_JUMP_SPEED in the retreat jump, and - * PLAYER_MAX_SPEED otherwise. While forward_speed is ABOVE it (a + * PLAYER_MAX_SPEED otherwise. + * - Building past run speed: up to PLAYER_MAX_SPEED * mag the air + * accelerates at PLAYER_AIR_ACCEL as usual; beyond it (only a + * normal jump allows that) only at PLAYER_JUMP_BOOST_ACCEL. So a full + * jump taken at a full run gains ~1 m/s by landing: a small, + * gradual reward for jumping, not a burst. 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 @@ -143,7 +154,9 @@ * lands. Pulling the stick back at full run turns the player to * face the stick and slides them backward to a stop over 0.5 s, * and A during that slide launches a 2x-height jump toward the - * stick at 4 m/s; landing it opens the second-jump window too. The player lands cleanly back in IDLE/RUN. + * stick at 4 m/s; landing it opens the second-jump window too. A + * full jump at full run builds gently to ~7 m/s, and that extra + * speed eases back to 6 m/s after landing. The player lands cleanly back in IDLE/RUN. * ============================================================ */ @@ -180,6 +193,7 @@ static Wish compute_wish(const Input *in, float camera_yaw) static float top_speed(const Player *p) { switch (p->jump_kind) { + case JUMP_NORMAL: return PLAYER_JUMP_MAX_SPEED; case JUMP_SECOND: return PLAYER_SECOND_JUMP_MAX_SPEED; case JUMP_RETREAT: return PLAYER_RETREAT_JUMP_SPEED; default: return PLAYER_MAX_SPEED; @@ -204,12 +218,12 @@ 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) +/* Turns toward the stick and changes speed toward target_speed by at most + * `rate`. Shared by ground and air movement; the air passes smaller rates. */ +static void steer(Player *p, Wish wish, float turn_rate, float target_speed, float rate, float dt) { turn(p, wish, turn_rate, dt); - p->forward_speed = approachf(p->forward_speed, top_speed(p) * wish.mag, accel * dt); + p->forward_speed = approachf(p->forward_speed, target_speed, rate * dt); } /* Standing still vs walking vs running is only a matter of speed. */ @@ -312,7 +326,13 @@ static void update_ground(Player *p, const Input *in, Wish wish, float dt) * nudging the stick to adjust your aim still looks smooth. */ if (p->forward_speed == 0.0f && angle_off_facing(p, wish) > deg_to_rad(PLAYER_SNAP_TURN_DEG)) p->facing_yaw = wish.yaw; - steer(p, wish, PLAYER_TURN_RATE, PLAYER_GROUND_ACCEL, dt); + + /* Landed from a normal jump carrying more than run speed: let the + * extra fade slowly instead of vanishing the moment we touch down. */ + if (p->forward_speed > top_speed(p)) + steer(p, wish, PLAYER_TURN_RATE, top_speed(p), PLAYER_OVERSPEED_DECEL, dt); + else + steer(p, wish, PLAYER_TURN_RATE, top_speed(p) * wish.mag, PLAYER_GROUND_ACCEL, dt); } else { p->forward_speed = approachf(p->forward_speed, 0.0f, PLAYER_GROUND_FRICTION * dt); } @@ -379,8 +399,18 @@ static void air_steer(Player *p, Wish wish, float dt) return; } - if (wish.mag > 0.0f) - steer(p, wish, air_turn_rate, PLAYER_AIR_ACCEL, dt); + if (wish.mag <= 0.0f) + return; + + /* Up to what running would give, the air accelerates as usual. Past it + * (only a normal jump's top speed allows that) speed builds slowly: a + * small reward for jumping at full run, not a burst. */ + float target = top_speed(p) * wish.mag; + float run_target = fminf(target, PLAYER_MAX_SPEED * wish.mag); + if (target > run_target && p->forward_speed >= run_target) + steer(p, wish, air_turn_rate, target, PLAYER_JUMP_BOOST_ACCEL, dt); + else + steer(p, wish, air_turn_rate, run_target, PLAYER_AIR_ACCEL, dt); } /* FALL: in the air, going down. Landing hands straight over to the ground |
