summaryrefslogtreecommitdiff
path: root/platformer/src/world.h
diff options
context:
space:
mode:
authorSchark <jordan@schark.online>2026-09-29 22:28:37 -0400
committerSchark <jordan@schark.online>2026-09-29 22:28:37 -0400
commitfdc8c951fc72d9dc4c8faa58a21b2b9de0599698 (patch)
treeedd9934a43429508acb9ec37da71eb172dc788e9 /platformer/src/world.h
parentadb6a882870464490a8026aed1f66b21b0e72477 (diff)
downloadgamedev-fdc8c951fc72d9dc4c8faa58a21b2b9de0599698.tar.gz
gamedev-fdc8c951fc72d9dc4c8faa58a21b2b9de0599698.zip
Implemented no-panning zones
Diffstat (limited to 'platformer/src/world.h')
-rw-r--r--platformer/src/world.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/platformer/src/world.h b/platformer/src/world.h
index 6cd1ce0..4cfcf71 100644
--- a/platformer/src/world.h
+++ b/platformer/src/world.h
@@ -29,6 +29,14 @@
* BoxStyle style; how it's drawn; BOX_STYLE_PLATFORM (0) by default
* } Box;
*
+ * typedef enum ZoneKind {
+ * ZONE_LOCKED_PAN the camera doesn't swing behind a player in it
+ * } ZoneKind;
+ * typedef struct Zone { Box bounds; ZoneKind kind; } Zone;
+ * A zone is NOT solid: the player walks in and out freely, and no
+ * collision query ever sees it. It only changes how things behave
+ * while the player is inside.
+ *
* void world_init(void);
* Builds the level (level_build() in level.c).
* void world_update(float dt);
@@ -60,6 +68,10 @@
* Vec3 world_spawn_point(void);
* Where the player starts / resets to (level_spawn_point()). The
* area around it is kept clear of platforms.
+ * int world_zone_count(void);
+ * Zone world_zone(int i); 0 <= i < world_zone_count() (render.c draws them)
+ * bool world_in_zone(Vec3 point, ZoneKind kind);
+ * True if the point is inside any zone of that kind (edges count).
* float world_half_extent(void);
* Returns WORLD_HALF_EXTENT (so render.c doesn't need config
* knowledge of the world's shape).
@@ -97,6 +109,18 @@ typedef struct Box {
BoxStyle style; /* how it's drawn; BOX_STYLE_PLATFORM unless the level says otherwise */
} Box;
+/* What a zone does to a player inside it. */
+typedef enum ZoneKind {
+ ZONE_LOCKED_PAN /* the camera doesn't swing behind the player (it still tilts) */
+} ZoneKind;
+
+/* A region of the level that changes behavior inside it. NOT solid: the
+ * player passes in and out freely, and collision never sees it. */
+typedef struct Zone {
+ Box bounds;
+ ZoneKind kind;
+} Zone;
+
void world_init(void);
void world_update(float dt);
Vec3 world_box_moved(int i);
@@ -107,6 +131,9 @@ float world_ceiling_above(Vec3 head, float half_width);
bool world_find_overlap(Vec3 feet, float half_width, float height, Box *hit);
Vec3 world_clamp_to_bounds(Vec3 p);
Vec3 world_spawn_point(void);
+int world_zone_count(void);
+Zone world_zone(int i);
+bool world_in_zone(Vec3 point, ZoneKind kind);
float world_half_extent(void);
#endif /* WORLD_H */