36 lines
593 B
Odin
36 lines
593 B
Odin
package game
|
|
|
|
import "core:fmt"
|
|
import rl "vendor:raylib"
|
|
World :: struct {
|
|
gold: int,
|
|
base_health: int,
|
|
world_map: Map,
|
|
path: [dynamic]Vec2,
|
|
enemies: [MAX_ENEMIES]Enemy,
|
|
}
|
|
|
|
init_world :: proc() -> World {
|
|
world := World {
|
|
gold = 100,
|
|
base_health = 20,
|
|
}
|
|
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 rl.IsKeyPressed(.G) {
|
|
world.gold += 10
|
|
}
|
|
|
|
if rl.IsKeyPressed(.SPACE) {
|
|
spawn_group(world, 3)
|
|
}
|
|
|
|
update_enemies(world, dt)
|
|
}
|
|
|