56 lines
1.1 KiB
Odin
56 lines
1.1 KiB
Odin
package game
|
|
|
|
World :: struct {
|
|
economy: Economy,
|
|
combat: Combat,
|
|
base_health: int,
|
|
world_map: Map,
|
|
path: [dynamic]Vec2,
|
|
events: [dynamic]Event,
|
|
phase: Game_Phase,
|
|
wave: int,
|
|
spawner: Wave_Spawner,
|
|
selected_tower: Tower_Kind,
|
|
}
|
|
|
|
Economy :: struct {
|
|
gold: int,
|
|
}
|
|
|
|
Combat :: struct {
|
|
enemies: [MAX_ENEMIES]Enemy,
|
|
towers: [dynamic]Tower,
|
|
projectiles: [MAX_PROJECTILES]Projectile,
|
|
}
|
|
|
|
init_world :: proc() -> World {
|
|
economy := Economy {
|
|
gold = 100,
|
|
}
|
|
world := World {
|
|
economy = economy,
|
|
base_health = 20,
|
|
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)
|
|
}
|
|
|