Let's give you a chance to dive deeply into working with events by building a Snake game. If you never played it (likely many years ago in your childhood), check out the Wikipedia Page for Snake. Basically, it's a snake that you have to move around the board and which grows longer with each piece of food it eats. You lose if it gets so big it hits itself or if it goes off the board.
If you think about what's required to make a game like this work, it's all well within your grasp -- you'll have to set up a grid and listen for user input events to determine where to turn the snake, then add some logic around how it gets larger by "feeding". This is where things start getting really fun!
render()function on page load.
[20,20]and an initial direction to the right (
r). Also include a variable to represent the current snake, which will be an array of coordinate pairs (so an array of arrays, e.g.
console.log()to track this so you know you're doing it right.
setTimeout()to perform a new "turn".
move()function which moves the snake one square in the current direction of travel for each turn.
move()function (if you need to) to account for a snake of multiple units length. This is why you need to think of the snake as an array of coordinate pairs.
Submit a link below to the github repo with your files in it by using a pull request. See the section on Contributing for how. Please include your partner's github handle somewhere in the description if you had one and they would like attribution.
This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something
From the creators of The Odin Project...