Welcome to the Snake Game project! This is a simple yet entertaining Snake Game, written in C++. This Readme file will guide you through building and running this game.
The project contains the following files:
.
โโโ main.cpp # Main program file
โโโ game.cpp # Source file related to the game logic
โโโ game.h # Header file related to the game logic
โโโ fruit.cpp # Source file related to the fruit
โโโ fruit.h # Header file related to the fruit
โโโ snake.cpp # Source file related to the snake
โโโ snake.h # Header file related to the snake
โโโ vector2.h # 2D Vector class for representing coordinates
โโโ input.cpp # Source file for handling user input
โโโ input.h # Header file for handling user input
โโโ CMakeLists.txt # CMake configuration file
- C++17 Compiler: Make sure you have a C++ compiler that supports C++17.
- CMake: Version 3.20 or higher is required. You can download it from the official website.
-
Clone or download this repository to a local directory.
git clone https://github.com/yourusername/snakeprogram.git cd snakeprogram
-
Create a build directory and navigate into it.
mkdir build cd build
-
Run CMake to configure the project.
cmake ..
-
Build the project using CMake or your compiler.
cmake --build .
After building, you can find an executable named snakeprogram
in the build
directory. Run it from the command line to start the game:
./snakeprogram
- Use the arrow keys to control the direction of the snake.
- Eating fruits makes the snake grow longer.
- The game ends if the snake hits the wall or itself.
- Try to achieve the highest score possible by eating as many fruits as you can without dying.