We are going to implement a Snake game in Scala. Please download the code for the game from OOFP-snake and you will need to install the Gradle plugin for VSCode (for Intellij it works out of the box). To run the code from VSCode run it from the Gradle plugin → Tasks → application → run.
All the code you need to implement will be in the src/snake/logic/GameLogic.scala file and you can take a look at the classes that are used in that file.
8.1. Add a field of type Point that represents the snake head that is randomly placed on the grid.
8.2. Add a field that represents the snake body.
8.3. Add a field that represents the apple, the apple needs to be placed randomly on the grid (Hint: make a grid of points and filter out the points that represent the snake, then pick a point randomly from that grid)
8.4. Add a field of type Direction that represents the current direction the snake is taking.
8.5. Implement the getCellType function that takes a point and determinates which point type it is, snake head, snake body, apple or just an empty cell.
8.6. Implement the changeDir that sets the current direction the snake is moving.
8.7. Implement the step function that:
8.8 Run the game and try playing it, use the arrow keys to change the direction the snake moves.
8.9. (Bonus) Implement the setReverse activated by pressing the R key with the following behavior: