Welcome to Snake Game 2D! This is a classic arcade-style game where you control a snake, guiding it to eat food and grow while avoiding collisions with walls and its own tail. This project utilizes C++ and the SFML library for graphics rendering and user input handling.
To compile and run Snake Game 2D, you need the following:
-
SFML (Simple and Fast Multimedia Library): SFML is a cross-platform and easy-to-use library for developing multimedia applications and games in C++. It handles graphical rendering, keyboard input, and window events.
-
iostream: Standard C++ library for input and output operations, used for printing messages to the console, such as "Game Over".
-
cstdlib and ctime: Standard C++ libraries for time manipulation and random number generation, utilized for generating random positions for food and obtaining the current time.
-
deque: Standard C++ double-ended queue data structure used for storing the segments of the snake in the game.
Snake Game 2D depends on the following SFML libraries:
sfml-graphics
sfml-window
sfml-system
To compile the Snake Game 2D, you need to follow these steps:
-
Create Directories: Create
/bin
and/build
directories in the root of the repository. You can do this using the following commands:mkdir bin mkdir build
-
Compile with Makefile: Navigate to the root directory of the project and run the following command in your terminal:
make
This command will compile the source files and link them with the necessary SFML libraries. After successful compilation, the executable will be placed in the
/bin
directory. -
Run the Game: Execute the generated executable file located in the
/bin
directory:./bin/snake_game
Enjoy playing Snake Game 2D!
If you'd like to contribute to Snake Game 2D, feel free to fork this repository, make your changes, and submit a pull request. We welcome any improvements or new features to make the game even more enjoyable.
Thank you for choosing Snake Game 2D! If you have any questions, issues, or suggestions, please don't hesitate to reach out. Happy gaming! ๐๐ฎ