draw overlay + move gold to overlay in pure raylib

This commit is contained in:
2026-06-18 01:09:17 -07:00
parent c8d191e7c7
commit 75c29a4d5e
4 changed files with 21 additions and 1 deletions
+1
View File
@@ -18,6 +18,7 @@ run :: proc() {
rl.ClearBackground(rl.Color{34, 139, 34, 255})
render_world(&world)
render_overlay(&world)
rl.EndDrawing()
}
+8
View File
@@ -1,5 +1,7 @@
package game
import rl "vendor:raylib"
MAP_W :: 30 // map width in tiles
MAP_H :: 20 // map height in tiles
TILE_SIZE :: 32 // size of tiles in pixels
@@ -17,3 +19,9 @@ MAX_PROJECTILES :: 64
PROJECTILE_SPEED :: 280 // pixels per second
PROJECTILE_HIT_RADIUS :: 10
OVERLAY_BAR_H :: 28
OVERLAY_PADDING :: 6
OVERLAY_BAR_COLOR :: rl.Color{20, 24, 20, 200}
OVERLAY_GOLD_COLOR :: rl.Color{255, 215, 80, 255}
-1
View File
@@ -4,7 +4,6 @@ import "core:fmt"
import rl "vendor:raylib"
render_hud :: proc(world: ^World) {
rl.DrawText(fmt.ctprintf("Gold: %d", world.gold), 10, 10, 22, rl.BLACK) // Gold HUD
rl.DrawText(fmt.ctprintf("Base HP: %d", world.base_health), 10, 32, 22, rl.BLACK) // HP HUD
rl.DrawText(fmt.ctprintf("Enemies: %d", active_enemy_count(world)), 10, 54, 22, rl.BLACK)
rl.DrawText(fmt.ctprintf("Wave: %d / %d", world.wave, MAX_WAVES), 10, 76, 22, rl.BLACK)
+12
View File
@@ -0,0 +1,12 @@
package game
import "core:fmt"
import rl "vendor:raylib"
render_overlay :: proc(world: ^World) {
rl.DrawRectangle(0, 0, SCREEN_W, OVERLAY_BAR_H, OVERLAY_BAR_COLOR)
gold := fmt.ctprintf("Gold: %d", world.gold)
rl.DrawText(gold, OVERLAY_PADDING, OVERLAY_PADDING, 18, OVERLAY_GOLD_COLOR)
}