Skip to content

Instantly share code, notes, and snippets.

@eamonnmcevoy
Created September 9, 2018 20:38
Show Gist options
  • Save eamonnmcevoy/0bc5f0b9e9cd19773e465e0ccc8eeeac to your computer and use it in GitHub Desktop.
Save eamonnmcevoy/0bc5f0b9e9cd19773e465e0ccc8eeeac to your computer and use it in GitHub Desktop.
class Game {
constructor(grid, snake) {
...
this.score = 0;
}
async run() {
...
while (true) {
...
if(this.food) {
...
if(this.snake.collision(this.snake.head, this.food)) {
...
this.score++;
document.getElementById("score").innerHTML = `Points: ${game.score}`;
}
}
}
}
}
...
document.getElementById("score").innerHTML = `Points: ${game.score}`;
game.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment