add ice towers - no projectiles, no button
This commit is contained in:
+14
-3
@@ -1,6 +1,7 @@
|
||||
package game
|
||||
|
||||
import "core:fmt"
|
||||
import "core:sys/posix"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
Enemy :: struct {
|
||||
@@ -9,7 +10,8 @@ Enemy :: struct {
|
||||
max_health: int,
|
||||
active: bool,
|
||||
path_index: int,
|
||||
speed: f32,
|
||||
base_speed: f32,
|
||||
slow_timer: f32,
|
||||
}
|
||||
|
||||
acquire_enemy :: proc(world: ^World) -> ^Enemy {
|
||||
@@ -33,7 +35,8 @@ spawn_enemy :: proc(world: ^World, health: int, speed: f32) {
|
||||
position = world.path[0],
|
||||
health = health,
|
||||
max_health = health,
|
||||
speed = speed,
|
||||
base_speed = speed,
|
||||
slow_timer = 0,
|
||||
path_index = 1,
|
||||
active = true,
|
||||
}
|
||||
@@ -59,7 +62,12 @@ update_enemies :: proc(world: ^World, dt: f32) {
|
||||
}
|
||||
|
||||
target := world.path[e.path_index]
|
||||
move_toward(&e.position, target, e.speed, dt)
|
||||
move_speed := e.base_speed
|
||||
if e.slow_timer > 0 {
|
||||
move_speed *= ICE_SLOW_FACTOR
|
||||
e.slow_timer -= dt
|
||||
}
|
||||
move_toward(&e.position, target, move_speed, dt)
|
||||
|
||||
dx := target.x - e.position.x
|
||||
dy := target.y - e.position.y
|
||||
@@ -83,6 +91,9 @@ render_enemies :: proc(world: ^World) {
|
||||
e := world.enemies[i]
|
||||
if !e.active do continue
|
||||
rl.DrawCircle(i32(e.position.x), i32(e.position.y), 11, rl.MAROON)
|
||||
if e.slow_timer > 0 {
|
||||
rl.DrawCircleLines(i32(e.position.x), i32(e.position.y), 14, rl.SKYBLUE)
|
||||
}
|
||||
rl.DrawText(
|
||||
fmt.ctprintf("%d", e.health),
|
||||
i32(e.position.x) - 4,
|
||||
|
||||
Reference in New Issue
Block a user