Created
October 2, 2017 07:30
-
-
Save ysfzrn/259119dadb371efdff1be6d3d19dfefc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@action("Did the snake eat the food ?") | |
handleEatFood() { | |
if (this.snake[0].x === this.food.x && this.snake[0].y === this.food.y) { | |
this.score = this.score + 1; | |
this.snake.push({ | |
id: this.snake[this.snake.length - 1].id + 1, | |
x: this.snake[this.snake.length - 1].x, | |
y: this.snake[this.snake.length - 1].y | |
}); | |
if( this.score % 3 === 0 ){ | |
this.intervalRate = this.intervalRate + 5; | |
} | |
this.handleMakeFood(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment