clean up get_archtype for towers and build_controls_layout function, replacing with constants

This commit is contained in:
2026-06-28 00:42:53 -07:00
parent 3026aeadc2
commit d29b4f07ea
3 changed files with 35 additions and 39 deletions
+3 -9
View File
@@ -79,18 +79,12 @@ TOWER_ARCHETYPES: [Tower_Kind]Tower_Archetype = {
}
tower_stats_at_level :: proc(tower: Tower) -> (damage: int, range: f32) {
arch := get_archetype(tower.kind)
arch := TOWER_ARCHETYPES[tower.kind]
damage = arch.damage + tower.upgrade_level * arch.damage_per_level
range = arch.range + f32(tower.upgrade_level) * arch.range_per_level
return
}
get_archetype :: proc(kind: Tower_Kind) -> Tower_Archetype {
return TOWER_ARCHETYPES[kind]
}
find_target_slot :: proc(tower: Tower, world: ^World) -> int {
best_slot: int = -1
best_dist: f32 = 999999
@@ -120,7 +114,7 @@ update_towers :: proc(world: ^World, dt: f32) {
slot := find_target_slot(t^, world)
if slot < 0 do continue
arch := get_archetype(t.kind)
arch := TOWER_ARCHETYPES[t.kind]
damage, _ := tower_stats_at_level(t^)
switch t.kind {
@@ -169,7 +163,7 @@ enemy_at_slot :: proc(world: ^World, slot: int) -> ^Enemy {
render_towers :: proc(world: ^World) {
for t in world.towers {
archetype := get_archetype(t.kind)
archetype := TOWER_ARCHETYPES[t.kind]
pixel_width := f32(archetype.footprint_w * TILE_SIZE)
pixel_height := f32(archetype.footprint_h * TILE_SIZE)
color := rl.Color{255, 203, 0, 255}