This repository contains a simple implementation of the classic Snake game using C++ and OpenGL. The game provides a grid-based environment where the player controls a snake, guiding it to eat food and grow in length while avoiding collisions with the boundaries and its own body.
- Grid-based environment with customizable size
- Snake movement in four directions: up, down, left, and right
- Randomly generated food on the grid
- Collision detection with boundaries and self
- Increasing snake length upon eating food
To run the Snake game, you need to have the following installed:
- C++ compiler
- OpenGL library
- GLUT library
-
Clone the repository:
git clone https://github.com/your-username/snake-game.git
-
Compile the code using your C++ compiler:
g++ -o snake-game snake.cpp -lGL -lGLU -lglut
-
Run the executable:
./snake-game
-
Play the game:
- Use the arrow keys to control the snake's movement.
- Guide the snake to eat the food and avoid collisions with the boundaries and its own body.
- The game ends when the snake collides with a boundary or itself.
Contributions to this project are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
- This project is based on the classic Snake game concept.
- The implementation utilizes the OpenGL and GLUT libraries for graphics and user input.
- The code was inspired by various online resources and tutorials.
Enjoy the Snake Game!