Refactor world gold and combat

This commit is contained in:
2026-06-26 20:41:39 -07:00
parent e75dd82a76
commit 4d9c52c56a
7 changed files with 45 additions and 34 deletions
+7 -7
View File
@@ -20,8 +20,8 @@ Projectile_Mode :: enum {
acquire_projectile :: proc(world: ^World) -> ^Projectile {
for i in 0 ..< MAX_PROJECTILES {
if !world.projectiles[i].active {
return &world.projectiles[i]
if !world.combat.projectiles[i].active {
return &world.combat.projectiles[i]
}
}
@@ -30,7 +30,7 @@ acquire_projectile :: proc(world: ^World) -> ^Projectile {
enemy_still_on_map :: proc(world: ^World, slot: int) -> (^Enemy, bool) {
if slot < 0 || slot >= MAX_ENEMIES do return nil, false
e := &world.enemies[slot]
e := &world.combat.enemies[slot]
if !e.active do return nil, false
if len(world.path) == 0 do return nil, false
if e.path_index >= len(world.path) do return nil, false
@@ -68,7 +68,7 @@ spawn_ballistic :: proc(world: ^World, from, dir: Vec2, damage: int, splash: f32
hit_enemy_at :: proc(world: ^World, pos: Vec2, damage: int) -> bool {
for i in 0 ..< MAX_ENEMIES {
e := &world.enemies[i]
e := &world.combat.enemies[i]
if !e.active do continue
if distance(pos, e.position) <= PROJECTILE_HIT_RADIUS {
apply_tower_hit(world, e, damage)
@@ -80,7 +80,7 @@ hit_enemy_at :: proc(world: ^World, pos: Vec2, damage: int) -> bool {
update_projectiles :: proc(world: ^World, dt: f32) {
for i in 0 ..< MAX_PROJECTILES {
p := &world.projectiles[i]
p := &world.combat.projectiles[i]
if !p.active do continue
switch p.mode {
@@ -132,7 +132,7 @@ update_ballistic_projectile :: proc(world: ^World, p: ^Projectile, dt: f32) {
render_projectiles :: proc(world: ^World) {
for i in 0 ..< MAX_PROJECTILES {
p := world.projectiles[i]
p := world.combat.projectiles[i]
if !p.active do continue
color := rl.GOLD
radius: f32 = 4
@@ -149,7 +149,7 @@ apply_splash_damage :: proc(world: ^World, center: Vec2, damage: int, radius: f3
hit_any := false
for i in 0 ..< MAX_ENEMIES {
e := &world.enemies[i]
e := &world.combat.enemies[i]
if !e.active do continue
if distance(center, e.position) <= radius {
apply_tower_hit(world, e, damage)