add end screens
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user