refactor base health
This commit is contained in:
+1
-1
@@ -94,7 +94,7 @@ update_enemies :: proc(world: ^World, dt: f32) {
|
||||
if !e.active do continue
|
||||
|
||||
if e.path_index >= len(world.world_map.path) {
|
||||
world.base_health -= 1
|
||||
world.player.base_health -= 1
|
||||
e.active = false
|
||||
continue
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ render_overlay :: proc(world: ^World) {
|
||||
rl.DrawText(gold, OVERLAY_PADDING, OVERLAY_PADDING, 18, OVERLAY_GOLD_COLOR)
|
||||
x += rl.MeasureText(gold, font_size) + gap
|
||||
|
||||
hp := fmt.ctprintf("Health: %d", world.base_health)
|
||||
hp := fmt.ctprintf("Health: %d", world.player.base_health)
|
||||
rl.DrawText(hp, x, y, font_size, OVERLAY_TEXT_COLOR)
|
||||
x += rl.MeasureText(hp, font_size) + gap
|
||||
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ update_phase :: proc(world: ^World) {
|
||||
}
|
||||
|
||||
check_end :: proc(world: ^World) {
|
||||
if world.base_health <= 0 {
|
||||
if world.player.base_health <= 0 {
|
||||
world.phase = .Game_Over
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -3,7 +3,7 @@ package game
|
||||
World :: struct {
|
||||
economy: Economy,
|
||||
combat: Combat,
|
||||
base_health: int,
|
||||
player: Player,
|
||||
world_map: Map,
|
||||
events: [dynamic]Event,
|
||||
phase: Game_Phase,
|
||||
@@ -11,6 +11,10 @@ World :: struct {
|
||||
selected_tower: Tower_Kind,
|
||||
}
|
||||
|
||||
Player :: struct {
|
||||
base_health: int,
|
||||
}
|
||||
|
||||
Map :: struct {
|
||||
current_map: World_Map,
|
||||
path: [dynamic]Vec2,
|
||||
@@ -35,9 +39,13 @@ init_world :: proc() -> World {
|
||||
economy := Economy {
|
||||
gold = 100,
|
||||
}
|
||||
|
||||
player := Player {
|
||||
base_health = 20,
|
||||
}
|
||||
world := World {
|
||||
economy = economy,
|
||||
base_health = 20,
|
||||
player = player,
|
||||
phase = .Build,
|
||||
selected_tower = .Archer,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user