diff options
| author | iamcheeseman <[hidden email]> | 2026-01-13 22:28:59 -0500 |
|---|---|---|
| committer | iamcheeseman <[hidden email]> | 2026-01-13 22:28:59 -0500 |
| commit | 0bf86ef7b8f0ecad958f3fb592ceaf3d2f30336a (patch) | |
| tree | acc7ee1c60579b5547ee23e5311446d588075b20 /src/world.odin | |
| parent | e5319f53de9f5f8ba4cb67e1302ebc3d7036135c (diff) | |
add support for tiled objects
Diffstat (limited to 'src/world.odin')
| -rw-r--r-- | src/world.odin | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/world.odin b/src/world.odin index 3248d65..4f3ee7f 100644 --- a/src/world.odin +++ b/src/world.odin @@ -1,16 +1,28 @@ package demonchime -import "core:log" - import rl "vendor:raylib" +Object_Spawner :: proc(Object_Resource) + current_room: Room_Position_Resource +object_spawners := [Object_Type]Object_Spawner{ + .PLAYER_SPAWN = player_spawn_object_spawner, +} + +@(private = "file") +spawn_objects :: proc(room_id: Room_Id) { + room := get_room(room_id) + + for obj in room.objects { + object_spawners[obj.type](obj) + } +} + open_room_at :: proc(pos: [2]i32) -> bool { pos := pos pos += {current_room.x, current_room.y} - log.debug("trying to change room...", pos) for room_pos in world { if room_pos.id == current_room.id { continue @@ -21,6 +33,7 @@ open_room_at :: proc(pos: [2]i32) -> bool { pos.y >= room_pos.y && pos.y <= room_pos.y + room_pos.height { current_room = room_pos + spawn_objects(current_room.id) return true } } @@ -31,6 +44,7 @@ open_room :: proc(id: Room_Id) -> bool { for room_pos in world { if room_pos.id == id { current_room = room_pos + spawn_objects(current_room.id) return true } } |
