Added a winning score to levels.
This commit is contained in:
@@ -15,6 +15,7 @@ Level :: struct {
|
|||||||
wait_time: f32,
|
wait_time: f32,
|
||||||
score_player: int,
|
score_player: int,
|
||||||
score_enemy: int,
|
score_enemy: int,
|
||||||
|
score_win: int,
|
||||||
}
|
}
|
||||||
|
|
||||||
FIELD_BORDER :: 3
|
FIELD_BORDER :: 3
|
||||||
@@ -50,6 +51,7 @@ init_level :: proc() -> Level {
|
|||||||
wait_time = SERVE_WAIT_TIME,
|
wait_time = SERVE_WAIT_TIME,
|
||||||
score_player = 0,
|
score_player = 0,
|
||||||
score_enemy = 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_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}
|
opp_pos := rl.Vector2{opp_box.x, opp_box.y}
|
||||||
rl.DrawTextEx(font, "COMPUTER", opp_pos, 20, 2, rl.WHITE)
|
rl.DrawTextEx(font, "COMPUTER", opp_pos, 20, 2, rl.WHITE)
|
||||||
// rl.DrawRectangleLinesEx(opp_box, 1.0, rl.RED)
|
|
||||||
|
|
||||||
// score box
|
// score box
|
||||||
// DYNAMIC SCORE BOX
|
|
||||||
// Format the score dynamically into a C-string allocated on the temp allocator
|
// 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_text := fmt.ctprintf("%d : %d", level.score_player, level.score_enemy)
|
||||||
score_size := rl.MeasureTextEx(font, score_text, 20, 2)
|
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_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}
|
score_pos := rl.Vector2{score_box.x, score_box.y}
|
||||||
rl.DrawTextEx(font, score_text, score_pos, 20, 2, rl.WHITE)
|
rl.DrawTextEx(font, score_text, score_pos, 20, 2, rl.WHITE)
|
||||||
// rl.DrawRectangleLinesEx(score_box, 1.0, rl.RED)
|
|
||||||
|
|
||||||
// game name
|
// game name
|
||||||
// rl.DrawRectangleLines(VIEWPORT_W / 2 - 50, VIEWPORT_H - 50, 100, 50, rl.RED)
|
// rl.DrawRectangleLines(VIEWPORT_W / 2 - 50, VIEWPORT_H - 50, 100, 50, rl.RED)
|
||||||
|
|||||||
Reference in New Issue
Block a user