summaryrefslogtreecommitdiff
path: root/platformer/src/render.c
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/render.c
parent5f04f3ae87fb307e055d39e81f7c0c841e8a9af8 (diff)
downloadgamedev-21404c26d3907cefa524878fb031e7a2022fb3d7.tar.gz
gamedev-21404c26d3907cefa524878fb031e7a2022fb3d7.zip
Game world test with updated movement
Diffstat (limited to '')
-rw-r--r--platformer/src/render.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/platformer/src/render.c b/platformer/src/render.c
index 127806b..782c653 100644
--- a/platformer/src/render.c
+++ b/platformer/src/render.c
@@ -43,7 +43,11 @@
* 5. Platforms: each world_box() is the cube scaled to the box. Draw it
* face by face with a fixed brightness per face (top brightest, bottom
* darkest, sides in between and different from each other) times the
- * platform's color from a small palette. WHY: with no lighting, a
+ * platform's color from a small palette, or COLOR_WALL_HANG for boxes
+ * with allows_wall_hang, so hangable walls read at a glance. Boxes with
+ * a BoxStyle other than PLATFORM use COLOR_CLIFF (rock) or COLOR_WATER;
+ * hangable rock is COLOR_CLIFF_HANG, a violet-tinted rock, so the
+ * "violet grabs" rule still reads on terrain. WHY: with no lighting, a
* one-color box is a flat silhouette and you can't tell its top from its
* sides, which makes jumps impossible to judge. Per-face shading is
* the cheapest way to read shape, and it needs no lighting code.
@@ -53,7 +57,7 @@
* stops z-fighting with the ground. Comment WHY the shadow exists:
* in SM64 the blob under Mario is the main cue for where you'll land.
* Without it, jumps in 3D are very hard to judge.
- * floor_y = world_floor_below(body.pos, body.half_width): the surface
+ * floor_y = world_floor_below(body.pos, body.half_width, NULL): the surface
* the player would land on, whether that's the ground or a platform.
* 7. Player box:
* model = translate(body.pos) * rotate_y(facing_yaw)
@@ -124,6 +128,10 @@ static const float COLOR_GRID_MAJOR[4] = { 0.62f, 0.82f, 0.55f, 1.0f };
static const float COLOR_SHADOW[4] = { 0.12f, 0.16f, 0.12f, 1.0f };
static const float COLOR_PLAYER[4] = { 0.85f, 0.15f, 0.15f, 1.0f };
static const float COLOR_NOSE[4] = { 1.00f, 0.85f, 0.20f, 1.0f };
+static const float COLOR_WALL_HANG[3] = { 0.58f, 0.46f, 0.78f }; /* violet: sides you can hang on */
+static const float COLOR_CLIFF[3] = { 0.52f, 0.47f, 0.42f }; /* warm grey rock */
+static const float COLOR_CLIFF_HANG[3] = { 0.56f, 0.48f, 0.62f }; /* violet-tinted rock: hangable terrain */
+static const float COLOR_WATER[3] = { 0.22f, 0.45f, 0.72f }; /* river blue */
static const float COLOR_HUD_TEXT[4] = { 1.00f, 1.00f, 1.00f, 1.0f };
static const float COLOR_HUD_SHADOW[4] = { 0.00f, 0.00f, 0.00f, 1.0f };
@@ -402,10 +410,25 @@ static void draw_platform(Mat4 vp, Box box, const float rgb[3])
}
}
+/* Hangable walls get their own color, so you can tell which ones grab;
+ * cliffs and water get theirs; everything else cycles the palette by index. */
+static const float *box_color(Box box, int index)
+{
+ if (box.allows_wall_hang)
+ return box.style == BOX_STYLE_CLIFF ? COLOR_CLIFF_HANG : COLOR_WALL_HANG;
+ switch (box.style) {
+ case BOX_STYLE_CLIFF: return COLOR_CLIFF;
+ case BOX_STYLE_WATER: return COLOR_WATER;
+ default: return PLATFORM_PALETTE[index % PLATFORM_PALETTE_SIZE];
+ }
+}
+
static void draw_platforms(Mat4 vp)
{
- for (int i = 0; i < world_box_count(); i++)
- draw_platform(vp, world_box(i), PLATFORM_PALETTE[i % PLATFORM_PALETTE_SIZE]);
+ for (int i = 0; i < world_box_count(); i++) {
+ Box box = world_box(i);
+ draw_platform(vp, box, box_color(box, i));
+ }
}
/* The drop shadow. In SM64 the blob under Mario is the main cue for where
@@ -415,7 +438,7 @@ static void draw_platforms(Mat4 vp)
static void draw_shadow(Mat4 vp, const Player *player)
{
Vec3 pos = player->body.pos;
- float floor_y = world_floor_below(pos, player->body.half_width);
+ float floor_y = world_floor_below(pos, player->body.half_width, NULL);
float r = PLAYER_HALF_WIDTH * SHADOW_RADIUS_SCALE;
Mat4 model = mat4_mul(mat4_translate(vec3_make(pos.x, floor_y + SHADOW_LIFT, pos.z)),
mat4_scale(vec3_make(r, 1.0f, r)));