From 8af1210d45c3fa3f41a174d2906ab597dcc22f1c Mon Sep 17 00:00:00 2001 From: Schark Date: Tue, 29 Sep 2026 23:36:45 -0400 Subject: Final state of the game day 3 --- platformer/src/level.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'platformer/src/level.c') diff --git a/platformer/src/level.c b/platformer/src/level.c index 3ae45be..34e03c3 100644 --- a/platformer/src/level.c +++ b/platformer/src/level.c @@ -89,6 +89,10 @@ * choice ("how do I get up there?") instead of one correct jump after * another, and the route makes sure a way up always exists. * + * 4. Two test staircases east of spawn, 0.2 m steps (under STEP_HEIGHT): + * stairwell 1 (z -2..2) has 40 steps 0.5 m deep (20 m long, 8 m tall); + * stairwell 2 (z 4..8) has 100 steps 0.12 m deep (12 m long, 20 m tall): + * the shallowest steps the step-up can take at full speed, for fun. * - level_build_zones(): TEST_ZONES, hand-placed. One locked-pan zone covers the * whole cliff and its climb band (south and east faces, out to where the * climb platforms reach), from the ground up to exactly CLIFF_TOP, so the @@ -900,6 +904,40 @@ static void add_crossing(void) } } +/* ---- 4. The staircase -------------------------------------------------- */ + +/* Two test staircases east of spawn, side by side, each 4 m wide. Every step + * is lower than STEP_HEIGHT (0.25 m), so the player walks up them, never + * jumping. */ +#define STAIR_START_X 32.0f /* m, both staircases' bottom step starts here */ +#define STAIR_WIDTH 4.0f /* m */ +#define STAIR_RISE 0.2f /* m high per step (under STEP_HEIGHT) */ +/* Stairwell 1: 40 steps 0.5 m deep: 20 m long, 8 m tall. */ +#define STAIR1_Z -2.0f /* m, its south edge */ +#define STAIR1_RUN 0.5f +#define STAIR1_COUNT 40 +/* Stairwell 2 (for fun): 100 steps as shallow as the step-up allows: 12 m + * long, 20 m tall. WHY 0.12 m: the step-up/down handles one stair per tick, + * and the fastest the player moves in a tick is 7 m/s / 60 = 0.117 m. A + * shallower step gets crossed two at a time and blocks the climb (tested: + * 0.10 m fails running down at 7 m/s, 0.11 m and up work). */ +#define STAIR2_Z 4.0f +#define STAIR2_RUN 0.12f +#define STAIR2_COUNT 100 + +/* One staircase rising toward +x: `count` steps `run` deep and STAIR_RISE + * high, each a box from the ground up to its step. */ +static void add_staircase(float south_z, float run, int count) +{ + for (int i = 0; i < count; i++) { + float x = STAIR_START_X + run * (float)i; + Box step = { { x, 0.0f, south_z }, + { x + run, STAIR_RISE * (float)(i + 1), south_z + STAIR_WIDTH }, + false, BOX_STYLE_PLATFORM }; + add_box(step, no_motion()); + } +} + /* ---- Zones ------------------------------------------------------------- */ /* Non-solid regions (see world.h). Bounds: min corner, max corner; the Box's @@ -932,6 +970,8 @@ int level_build(LevelBox *out, int capacity) add_rock_pillars(); add_scatter(); add_crossing(); + add_staircase(STAIR1_Z, STAIR1_RUN, STAIR1_COUNT); /* last, so the cliff course's boxes keep their order */ + add_staircase(STAIR2_Z, STAIR2_RUN, STAIR2_COUNT); return s_count; } -- cgit v1.2.3-18-g5258