commands, towers, etc
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package game
|
||||
|
||||
import rl "vendor:raylib"
|
||||
Command_Kind :: enum {
|
||||
None,
|
||||
Place_Tower,
|
||||
}
|
||||
|
||||
Command :: struct {
|
||||
kind: Command_Kind,
|
||||
gx: int,
|
||||
gy: int,
|
||||
}
|
||||
|
||||
gather_commands :: proc(world: ^World) -> Command {
|
||||
if 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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user