Skip to content

Commit

Permalink
Fix JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
szokeasaurusrex committed Oct 5, 2014
1 parent 297ecc4 commit e9d4303
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
24 changes: 13 additions & 11 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function key(type, event) {
function gameOver() {
cancelAnimationFrame(mov);
var message;
var oldHighScore = JSON.parse(localStorage.highScore);//start here
function popup(beat) {
function highScore(name) {
this.score = score;
Expand All @@ -65,17 +64,20 @@ function gameOver() {
message = 'Because you haven\'t played before, your score for this game is the new local high score.';
popup(true);
}
else if (oldHighScore.score > score) {
message = 'You failed to beat high score, ' + oldHighScore.name + '\'s high score of ' + oldHighScore.score + ' points!';
popup(false);
}
else if (oldHighScore.score < score) {
message = 'You beat ' + oldHighScore.name + '\'s high score of ' + oldHighScore.score + ' points!';
popup(true);
}
else {
message = 'You tied the local high score!';
popup(false);
var oldHighScore = JSON.parse(localStorage.highScore);
if (oldHighScore.score > score) {
message = 'You failed to beat high score, ' + oldHighScore.name + '\'s high score of ' + oldHighScore.score + ' points!';
popup(false);
}
else if (oldHighScore.score < score) {
message = 'You beat ' + oldHighScore.name + '\'s high score of ' + oldHighScore.score + ' points!';
popup(true);
}
else {
message = 'You tied the local high score!';
popup(false);
}
}
location.reload();
}
Expand Down
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<!-- Ignore this-->
<!DOCTYPE html>
<html>
<head>
Expand Down

0 comments on commit e9d4303

Please sign in to comment.