wave spawner, game phases, making game window larger
This commit is contained in:
+12
-6
@@ -5,7 +5,7 @@ import rl "vendor:raylib"
|
||||
Command_Kind :: enum {
|
||||
None,
|
||||
Place_Tower,
|
||||
Spawn_Test,
|
||||
Start_Wave,
|
||||
}
|
||||
|
||||
Command :: struct {
|
||||
@@ -15,14 +15,20 @@ Command :: struct {
|
||||
}
|
||||
|
||||
gather_commands :: proc(world: ^World) -> Command {
|
||||
if rl.IsMouseButtonPressed(.LEFT) {
|
||||
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}
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(.SPACE) {
|
||||
return Command{kind = .Spawn_Test}
|
||||
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}
|
||||
@@ -31,10 +37,10 @@ gather_commands :: proc(world: ^World) -> Command {
|
||||
execute_command :: proc(world: ^World, cmd: Command) {
|
||||
switch cmd.kind {
|
||||
case .None:
|
||||
case .Spawn_Test:
|
||||
spawn_group(world, 3)
|
||||
case .Place_Tower:
|
||||
try_place_tower(world, cmd.gx, cmd.gy, .Archer)
|
||||
case .Start_Wave:
|
||||
start_wave(world)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user