This is a re-make of the classic game Snake.
-
Goal: Get the maximum "points", by eating as many insects as possible without hitting the snake's own body or the walls.
-
Failure State: When the snake hits one of its own nodes or hits a wall, the game is over.
-
The snake is a series of "nodes" which moves on a 2D plane. The board can be represented by a 2D array. Since the project was initially made for Turbo C++ console, I made it with bounds for a standard 25 X 80 console window.
-
The nodes follow the path taken by the head. This makes it incredibly easy to think of it as linked list. The movement is of a node is simply the changing it with the coordinates of the node in front of it. This reduces the problem of updating the position of the snake to just updating the position of the head and propogating the change to the nodes behind it.
-
The snake "eats" the insects to grow in size. Growing the size of the snake is simply linking a new node to the tail node of the snake.
-
The repainting and checking insect collisions are simple event listeners. I created two different event listeners because I have heard it is good practice to not bind the frame refreshing part of a game with the logic of the game. So if you have the right equipment, you run this game in glorious 144 Fps.
- Hide the event listener button
- Make it more feature complete
- Add walls.
- Make it more general, rather than only working on 25 X 80 windows
- Port it out of java?