refactor gold rewards and tower cost; fix wave test leak
This commit is contained in:
@@ -16,8 +16,6 @@ MAX_ENEMIES :: 64
|
||||
MAX_WAVES :: 5
|
||||
MAX_TOWERS :: 32
|
||||
|
||||
TOWER_COST :: 50
|
||||
|
||||
MAX_PROJECTILES :: 64
|
||||
PROJECTILE_SPEED :: 280 // pixels per second
|
||||
PROJECTILE_HIT_RADIUS :: 10
|
||||
|
||||
@@ -28,6 +28,7 @@ Enemy_Def :: struct {
|
||||
speed_per_wave: f32,
|
||||
color: rl.Color,
|
||||
draw_radius: f32,
|
||||
gold_reward: int,
|
||||
}
|
||||
|
||||
ENEMY_DEF: [Enemy_Kind]Enemy_Def = {
|
||||
@@ -38,6 +39,7 @@ ENEMY_DEF: [Enemy_Kind]Enemy_Def = {
|
||||
speed_per_wave = 5,
|
||||
color = rl.MAROON,
|
||||
draw_radius = 11,
|
||||
gold_reward = 5,
|
||||
},
|
||||
.Runner = {
|
||||
base_health = 10,
|
||||
@@ -46,6 +48,7 @@ ENEMY_DEF: [Enemy_Kind]Enemy_Def = {
|
||||
speed_per_wave = 3,
|
||||
color = rl.ORANGE,
|
||||
draw_radius = 11,
|
||||
gold_reward = 5,
|
||||
},
|
||||
.Tank = {
|
||||
base_health = 50,
|
||||
@@ -54,6 +57,7 @@ ENEMY_DEF: [Enemy_Kind]Enemy_Def = {
|
||||
speed_per_wave = 2,
|
||||
color = rl.DARKGREEN,
|
||||
draw_radius = 14,
|
||||
gold_reward = 10,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -102,13 +102,8 @@ update_homing_projectile :: proc(world: ^World, p: ^Projectile, dt: f32) {
|
||||
move_toward(&p.position, target.position, p.speed, dt)
|
||||
|
||||
if distance(p.position, target.position) <= PROJECTILE_HIT_RADIUS {
|
||||
target.health -= p.damage
|
||||
p.active = false
|
||||
|
||||
if target.health <= 0 {
|
||||
target.active = false
|
||||
push_event(world, .Enemy_Killed, gold_reward = 5)
|
||||
}
|
||||
apply_tower_hit(world, target, p.damage)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ TOWER_ARCHETYPES: [Tower_Kind]Tower_Archetype = {
|
||||
range = 100,
|
||||
damage = 12,
|
||||
fire_rate = 0.45,
|
||||
cost = TOWER_COST,
|
||||
cost = 50,
|
||||
footprint_w = 1,
|
||||
footprint_h = 2,
|
||||
max_upgrade = 1,
|
||||
@@ -144,7 +144,7 @@ apply_tower_hit :: proc(world: ^World, target: ^Enemy, damage: int) {
|
||||
target.health -= damage
|
||||
if target.health <= 0 {
|
||||
target.active = false
|
||||
push_event(world, .Enemy_Killed, gold_reward = 5)
|
||||
push_event(world, .Enemy_Killed, gold_reward = ENEMY_DEF[target.kind].gold_reward)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -133,8 +133,9 @@ test_update_phase_from_build_phase :: proc(t: ^testing.T) {
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_udpate_phase_from_combat_phase :: proc(t: ^testing.T) {
|
||||
test_update_phase_from_combat_phase :: proc(t: ^testing.T) {
|
||||
world := World{}
|
||||
defer delete(world.events)
|
||||
world.phase = .Combat
|
||||
|
||||
update_phase(&world)
|
||||
|
||||
Reference in New Issue
Block a user