Overview
This project is a console-based Snake game where the player navigates a snake to eat food
and grow longer, avoiding collisions with walls or its own tail. Implemented in Java, the
game showcases fundamental concepts such as collision detection, dynamic object spawning,
and basic AI for obstacle placement.
My Role & Key Contributions
- Game Logic & Collision Detection: Wrote the core Java code to handle
movement, wall collision, and snake-body collision detection.
- Obstacle & Teleport Design: Developed obstacle and teleport mechanics
that enhance gameplay complexity and variety.
- Randomized Food Placement: Implemented the logic to spawn food at
random grid locations while avoiding snake positions and obstacles.
- Console Rendering & User Input: Managed keyboard inputs (WASD) and
displayed the live game state on the console.
Challenges & Outcomes
-
Challenge: Ensuring the snake’s body updates accurately without overwriting
segments or leaving artifacts.
Outcome: Introduced a data structure to track every snake segment’s
(x, y) coordinates, allowing smooth, glitch-free movement.
-
Challenge: Implementing a teleport mechanic that sends the snake from one
side of the grid to another.
Outcome: Created a dedicated teleport method that inverts the snake’s
coordinates upon hitting specific grid cells, adding an innovative twist to the classic game.
-
Challenge: Balancing obstacle placement and random food spawning.
Outcome: Used checks to prevent food from spawning inside obstacles
or on the snake, ensuring fair gameplay and consistent difficulty.
Gameplay Instructions
Controls:
W: Move Up
A: Move Left
S: Move Down
D: Move Right
Press Q at any time to quit the game.
Your goal is to eat the food (@) and grow as large as possible without
hitting walls or your own tail. Avoid obstacles (%) and use teleports
(O) strategically to wrap around the board.
Key Features
- Responsive console-based gameplay with real-time movement.
- Dynamic snake growth and collision detection.
- Randomized food generation that rewards exploration.
- Teleport mechanics that add a twist to the classic format.
- Score tracking and game over conditions.
Technologies Used
Java
GitHub