Skip to content

Challenge 2 Tasks Completed#10

Open
sowmen wants to merge 3 commits intorecruit-org:mainfrom
sowmen:main
Open

Challenge 2 Tasks Completed#10
sowmen wants to merge 3 commits intorecruit-org:mainfrom
sowmen:main

Conversation

@sowmen
Copy link
Copy Markdown

@sowmen sowmen commented Mar 7, 2022

Tasks Completed:

  1. Currently when the snake eats a food, it doesn't change its size. Its size should increase by one every time it eats a food.
  2. Currently it is possible to change direction to the opposite direction. Make it so that the snake can only change direction in a right angle. e.g: It will not possible to change from left direction to right, but will be possible to change from left to top or bottom.
  3. Make it so that the snake dies and the game resets whenever the snake touches itself.
    When the snake crosses the grid boundary, make it reappear from the opposite direction.
  4. Currently there is only one food in the grid and it stays there until the snake eats it. Make it so that
    • there is a new food every 3 seconds
    • each food should disappear after 10 seconds

};


if(snake.map((part) => newHead.x==part.x && newHead.y==part.y)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can simply take advantage of the isSnake method to check this

});
}

const timer = setInterval(deleteFood, 10 * 1000);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are removing a food every 10 secs, how do you make sure every of them stays on the grid for exactly 10s?
1st food appears on 0s
2nd food appears on 3s
3rd food appears on 6s...
1st food gets removed on 10s
2nd food gets removed on 20s -> but shouldn't it get removed on 13s?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants