Kihra Martinez
2 min readMar 8, 2021

--

HW 7 — Make a game using classes

Snake Game

For this assignment I decided to keep the Snake Game concept, but I wanted to add on to it. When I first did the snake game, I couldn’t make it grow so I wanted to try it this time.

  • I started with the assignment and made a grow statement for making the snake. I already had made the body length, but now I had to make it so every time it ate food, it would grow. So, in the eat statement, I made it grow using this.grow and making it return true. It wasn’t too hard and it worked fine when I ran the code. I couldn’t make the snake die when it ran into itself, but It does die when the snake moves back into self.
  • In the past assignment I wasn’t able to make a scoreboard, but this time I was successful, using scoreElement. The only problem is that I couldn’t get the scoreboard to run!! Other than that, there is also a statement when it’s game over, but the score doesn’t work so it says NaN.

--

--