A retro Snake game built entirely in Java. Lets you adjust speed, alter board dimensions, and toggle collisions and randomly spawning mines!
Java.Snake.Demo.mp4
- Download Snake.zip from the release.
- Right-click the downloaded zip file and select Extract All... to unzip the folder.
- Open the newly unzipped folder, look for SnakeGame.exe, and double-click it to launch the game!
- Speed Adjustments: SLOW (200ms delay), MEDIUM (120ms delay), FAST (70ms delay)
- Board Dimensions: 10x10, 15x15, or 20x20 grids
- Modifiers:
- MINES: Spawns explosive mines every 2 apples.
- CHILL: Toggles wall-collisions off. You can phase through yourself, or phase through walls and loop back on the opposite side.
- RESET: Restores original settings.
- Move:
Arrow KeysorW, A, S, D - Self-Destruct (Reset):
R - Menu Selection: Left-click on buttons via Mouse
My Snake game uses coordinates on a grid to calculate positions rather than exact locations. Every coordinate is stored as an integer between 1 and boardDim, which is a variable equal to the length/width of the board. Scaling to actual screen pixels is separate from game logic and only processed when rendering in paintComponent(the graphics function). This simplifies collision detection and makes it easy to scale the board and related entities without requiring complex math.
The game also implements a feature to stop you from dying after you mash two inputs. The first input disables all directional events that happen afterwards until the next frame. This eliminates self-collision caused by frame rate issues.
Video reference: https://www.youtube.com/watch?v=bI6e6qjJ8JQ**
I used this video as a reference for the setup of my game. However, the main menu, modifiers, and majority of gameplay were developed by me. I used the video to get an idea of how to setup files, and referenced it whenever I was stuck on how to make a certain feature work.
Additionally, I occassionally used Google Gemini to help me debug and fix a few aspects of my code. The most notable AI section is the contains() function, which is used to detect collisions and ensure that apples did not overlap the snake.
This project was created and submitted to Hack Club Stardance 2026 by Zahran G.