From 0729384898303eff90a9f675af9bf6114035f2e2 Mon Sep 17 00:00:00 2001 From: codegirl-007 Date: Sat, 20 Jun 2026 22:05:11 -0700 Subject: [PATCH] add end screens --- game/endscreen.odin | 29 +++++++++++++++++++++++++++++ game/hud.odin | 8 -------- game/overlay.odin | 4 ++++ 3 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 game/endscreen.odin diff --git a/game/endscreen.odin b/game/endscreen.odin new file mode 100644 index 0000000..135e8d1 --- /dev/null +++ b/game/endscreen.odin @@ -0,0 +1,29 @@ +package game + +import "core:fmt" +import rl "vendor:raylib" + +draw_end_screen :: proc(world: ^World) { + title: cstring = "GAME OVER" + title_color := rl.RED + sub: cstring = "Press close to quit" + sub_color := OVERLAY_TEXT_COLOR + + if world.phase == .Victory { + title = "VICTORY!" + title_color = rl.GREEN + sub = fmt.ctprintf("You survived %d waves!", MAX_WAVES) + } + + + rl.DrawRectangle(0, 0, SCREEN_W, SCREEN_H, rl.Color{0, 0, 0, 140}) + + title_font: i32 = 40 + tw := rl.MeasureText(title, title_font) + rl.DrawText(title, (SCREEN_W - tw) / 2, SCREEN_H / 2 - 50, title_font, title_color) + + sub_font: i32 = 18 + sw := rl.MeasureText(sub, sub_font) + rl.DrawText(sub, (SCREEN_W - sw) / 2, SCREEN_H / 2 + 10, sub_font, sub_color) +} + diff --git a/game/hud.odin b/game/hud.odin index ad0f436..928080a 100644 --- a/game/hud.odin +++ b/game/hud.odin @@ -7,13 +7,5 @@ render_hud :: proc(world: ^World) { 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) - switch world.phase { - case .Build: - case .Combat: - case .Game_Over: - rl.DrawText("GAME_OVER", 260, 280, 40, rl.RED) - case .Victory: - rl.DrawText("Victory!", 260, 280, 40, rl.GREEN) - } } diff --git a/game/overlay.odin b/game/overlay.odin index 20cc9a9..cc3cebb 100644 --- a/game/overlay.odin +++ b/game/overlay.odin @@ -18,5 +18,9 @@ render_overlay :: proc(world: ^World) { hp := fmt.ctprintf("Health: %d", world.base_health) rl.DrawText(hp, x, y, font_size, OVERLAY_TEXT_COLOR) + + if world.phase == .Game_Over || world.phase == .Victory { + draw_end_screen(world) + } }