Files
tower-defense-prototype/game/world.odin
T

45 lines
1.0 KiB
Odin

package game
World :: struct {
gold: int,
base_health: int,
world_map: Map,
path: [dynamic]Vec2,
enemies: [MAX_ENEMIES]Enemy,
towers: [dynamic]Tower,
events: [dynamic]Event,
phase: Game_Phase,
wave: int,
spawner: Wave_Spawner,
projectiles: [MAX_PROJECTILES]Projectile,
selected_tower: Tower_Kind,
}
init_world :: proc() -> World {
world := World {
gold = STARTING_GOLD,
base_health = STARTING_BASE_HEALTH,
phase = .Build,
selected_tower = .Archer,
}
init_map(&world.world_map)
build_path(&world.world_map, &world.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)
}