44 lines
840 B
Odin
44 lines
840 B
Odin
package game
|
|
|
|
import rl "vendor:raylib"
|
|
|
|
Command_Kind :: enum {
|
|
None,
|
|
Place_Tower,
|
|
Start_Wave,
|
|
}
|
|
|
|
Command :: struct {
|
|
kind: Command_Kind,
|
|
gx: int,
|
|
gy: int,
|
|
}
|
|
|
|
gather_commands :: proc(world: ^World) -> Command {
|
|
overlay_cmd := poll_overlay_command()
|
|
if overlay_cmd.kind != .None do return overlay_cmd
|
|
|
|
if world.phase == .Build && rl.IsKeyPressed(.N) {
|
|
return Command{kind = .Start_Wave}
|
|
}
|
|
|
|
if world.phase == .Build && rl.IsMouseButtonPressed(.LEFT) {
|
|
mouse := rl.GetMousePosition()
|
|
gx, gy := screen_to_grid(mouse.x, mouse.y)
|
|
return Command{kind = .Place_Tower, gx = gx, gy = gy}
|
|
}
|
|
|
|
return Command{kind = .None}
|
|
}
|
|
|
|
execute_command :: proc(world: ^World, cmd: Command) {
|
|
switch cmd.kind {
|
|
case .None:
|
|
case .Place_Tower:
|
|
try_place_tower(world, cmd.gx, cmd.gy, .Archer)
|
|
case .Start_Wave:
|
|
start_wave(world)
|
|
}
|
|
}
|
|
|