Skip to content

Commit

Permalink
Merge attempt 4
Browse files Browse the repository at this point in the history
  • Loading branch information
gamalielhere committed Feb 3, 2016
1 parent 93a6b80 commit c1eb192
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(document).ready(function() {
// $(document).ready(function() {
// CANVAS PART
var canvas = $("#canvas")[0];
var canvasContext = canvas.getContext("2d");
Expand Down Expand Up @@ -88,6 +88,7 @@ $(document).ready(function() {
location.reload(true);
});


function snakeMake(){
var length = 10;
snake = [];
Expand Down Expand Up @@ -144,18 +145,18 @@ $(document).ready(function() {
die.play();
}
var storedHighscore = 0;
localStorage.setItem("highscore", highscore);
$(".currentScore").text("Your score: " + score);
if(score > highscore) {
highscore ++;
if (score > storedHighscore && localStorage.highscore !== undefined) {
localStorage.highscore = storedHighscore;
} else if(score > storedHighscore && localStorage.highscore === undefined){
storedHighscore++;
localStorage.highscore = storedHighscore;
}
}
$("#highScore").text(highscore);
localStorage.setItem("highscore", highscore);
$(".currentScore").text("Your score: " + score);
if(score > highscore) {
highscore ++;
if (score > storedHighscore && localStorage.highscore !== undefined) {
localStorage.highscore = storedHighscore;
} else if(score > storedHighscore && localStorage.highscore === undefined){
storedHighscore++;
localStorage.highscore = storedHighscore;
}
}
$("#highScore").text(highscore);

if(newX === food.x && newY === food.y){
tail = {x: newX, y: newY};
Expand Down Expand Up @@ -220,4 +221,4 @@ $(document).ready(function() {
direction = "down";
}
});
});
// });

0 comments on commit c1eb192

Please sign in to comment.