-
Notifications
You must be signed in to change notification settings - Fork 46
/
hud.js
35 lines (28 loc) · 926 Bytes
/
hud.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var score = 0;
var scoreText;
var createHud = function() {
var hudTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI");
// Create a Text Block that can display the current score
scoreText = new BABYLON.GUI.TextBlock();
scoreText.fontFamily = "Comic Sans, Comic Sans MS";
scoreText.color = "white";
scoreText.fontSize = 48;
scoreText.verticalAlignment = BABYLON.GUI.TextBlock.VERTICAL_ALIGNMENT_TOP;
scoreText.horizontalAlignment = BABYLON.GUI.TextBlock.HORIZONTAL_ALIGNMENT_CENTER;
scoreText.width = .5;
scoreText.height = .15;
updateScoreText();
hudTexture.addControl(scoreText);
}
var updateScoreText = function() {
scoreText.text = "Score: " + score;
}
var resetScore = function() {
console.log("Score reset at: " + score);
score = 0;
updateScoreText();
}
var addScore = function(points) {
score += points;
updateScoreText();
}