forked from algorithm0r/Empty--GameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highscore.js
28 lines (23 loc) · 959 Bytes
/
highscore.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
// var easyHighscore = localStorage.getItem("easyHighscore");
// var mediumHighscore = localStorage.getItem("mediumHighscore");
// var hardHighscore = localStorage.getItem("hardHighscore");
var highScore = 0;
function showHighScore(dificulty) {
// if(dificulty.type == 'easy' && easyHighscore != null) {
// highScore = easyHighscore;
// } else if(dificulty.type == 'medium' && mediumHighscore != null) {
// highScore = mediumHighscore;
// } else if(dificulty.type == 'hard' && hardHighscore != null) {
// highScore = hardHighscore;
// }
highScore = localStorage.getItem(dificulty.score);
if(highScore == null || isNaN(highScore)) {
highScore = "...";
}
document.getElementById('bestScore').innerHTML = "Best: " + highScore;
};
function setHighScore(dificulty, time) {
if(highScore == "..." || time < highScore) {
localStorage.setItem(dificulty.score, Math.floor(time));
}
}