Skip to content

Instantly share code, notes, and snippets.

@ysfzrn
Created October 2, 2017 07:30
Show Gist options
  • Save ysfzrn/259119dadb371efdff1be6d3d19dfefc to your computer and use it in GitHub Desktop.
Save ysfzrn/259119dadb371efdff1be6d3d19dfefc to your computer and use it in GitHub Desktop.
@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