From fdc8c951fc72d9dc4c8faa58a21b2b9de0599698 Mon Sep 17 00:00:00 2001 From: Schark Date: Tue, 29 Sep 2026 22:28:37 -0400 Subject: Implemented no-panning zones --- platformer/src/world.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'platformer/src/world.h') 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 */ -- cgit v1.2.3-18-g5258