Added a winning score to levels.

This commit is contained in:
2026-09-15 05:41:41 +02:00
parent 0000ca4f12
commit 106f8195e2
+2 -3
View File
@@ -15,6 +15,7 @@ Level :: struct {
wait_time: f32,
score_player: int,
score_enemy: int,
score_win: int,
}
FIELD_BORDER :: 3
@@ -50,6 +51,7 @@ init_level :: proc() -> Level {
wait_time = SERVE_WAIT_TIME,
score_player = 0,
score_enemy = 0,
score_win = 2,
}
}
@@ -89,17 +91,14 @@ render_hud :: proc(level: Level) {
opp_box := rl.Rectangle{(VIEWPORT_W - 5 - opp_size.x), 5, (opp_size.x), (opp_size.y)}
opp_pos := rl.Vector2{opp_box.x, opp_box.y}
rl.DrawTextEx(font, "COMPUTER", opp_pos, 20, 2, rl.WHITE)
// rl.DrawRectangleLinesEx(opp_box, 1.0, rl.RED)
// score box
// DYNAMIC SCORE BOX
// Format the score dynamically into a C-string allocated on the temp allocator
score_text := fmt.ctprintf("%d : %d", level.score_player, level.score_enemy)
score_size := rl.MeasureTextEx(font, score_text, 20, 2)
score_box := rl.Rectangle{(VIEWPORT_W / 2 - score_size.x / 2), 5, (score_size.x), (score_size.y)}
score_pos := rl.Vector2{score_box.x, score_box.y}
rl.DrawTextEx(font, score_text, score_pos, 20, 2, rl.WHITE)
// rl.DrawRectangleLinesEx(score_box, 1.0, rl.RED)
// game name
// rl.DrawRectangleLines(VIEWPORT_W / 2 - 50, VIEWPORT_H - 50, 100, 50, rl.RED)