summaryrefslogtreecommitdiff
path: root/platformer/src/world.c
diff options
context:
space:
mode:
authorSchark <jordan@schark.online>2026-09-29 23:36:45 -0400
committerSchark <jordan@schark.online>2026-09-29 23:36:45 -0400
commit8af1210d45c3fa3f41a174d2906ab597dcc22f1c (patch)
tree43f1a9814faae852af943f71de53d4ca38dc6cd2 /platformer/src/world.c
parentfdc8c951fc72d9dc4c8faa58a21b2b9de0599698 (diff)
downloadgamedev-master.tar.gz
gamedev-master.zip
Final state of the game day 3HEADmaster
Diffstat (limited to 'platformer/src/world.c')
-rw-r--r--platformer/src/world.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/platformer/src/world.c b/platformer/src/world.c
index c999f41..4c088aa 100644
--- a/platformer/src/world.c
+++ b/platformer/src/world.c
@@ -29,7 +29,9 @@
* WORLD_NO_CEILING.
* world_find_overlap: the first box that overlaps the body's full volume
* (footprint AND height range).
- * - Zones (level_build_zones()): stored separately from the boxes, so no
+ * - world_object_at(point, radius, hit): the first object (never a zone)
+ * that, grown by `radius` on every side, contains the point.
+ * - Zones (level_build_zones()): stored separately from the objects, so no
* collision query ever sees them. world_in_zone(point, kind): is the point
* inside (edges count) any zone of that kind.
* - world_clamp_to_bounds, world_spawn_point (level_spawn_point()),
@@ -176,6 +178,20 @@ Vec3 world_spawn_point(void)
return level_spawn_point();
}
+bool world_object_at(Vec3 point, float radius, Box *hit)
+{
+ for (int i = 0; i < s_box_count; i++) {
+ Box b = s_boxes[i];
+ if (point.x > b.min.x - radius && point.x < b.max.x + radius &&
+ point.y > b.min.y - radius && point.y < b.max.y + radius &&
+ point.z > b.min.z - radius && point.z < b.max.z + radius) {
+ *hit = b;
+ return true;
+ }
+ }
+ return false;
+}
+
int world_zone_count(void)
{
return s_zone_count;