Files
tower-defense-prototype/game/world.odin
T
2026-06-27 00:38:22 -07:00

72 lines
1.3 KiB
Odin

package game
World :: struct {
economy: Economy,
combat: Combat,
player: Player,
world_map: Map,
events: [dynamic]Event,
phase: Game_Phase,
wave: Wave,
selected_tower: Tower_Kind,
}
Player :: struct {
base_health: int,
}
Map :: struct {
current_map: World_Map,
path: [dynamic]Vec2,
}
Economy :: struct {
gold: int,
}
Combat :: struct {
enemies: [MAX_ENEMIES]Enemy,
towers: [dynamic]Tower,
projectiles: [MAX_PROJECTILES]Projectile,
}
Wave :: struct {
current_wave: int,
spawner: Wave_Spawner,
}
init_world :: proc() -> World {
economy := Economy {
gold = 100,
}
player := Player {
base_health = 20,
}
world := World {
economy = economy,
player = player,
phase = .Build,
selected_tower = .Archer,
}
init_map(&world.world_map.current_map)
build_path(&world.world_map.current_map, &world.world_map.path)
return world
}
// update world, never draw
update_world :: proc(world: ^World, dt: f32) {
if world.phase == .Game_Over || world.phase == .Victory do return
cmd := gather_commands(world)
execute_command(world, cmd)
update_wave(world, dt)
update_enemies(world, dt)
update_projectiles(world, dt)
update_towers(world, dt)
update_phase(world)
process_events(world)
check_end(world)
}