Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/echosingh/snakegame

Simple Console Snake Game
https://github.com/echosingh/snakegame

console-game snake-game

Last synced: 2 days ago
JSON representation

Simple Console Snake Game

Awesome Lists containing this project

README

        

# Snake Game

This is a simple Snake game implemented in C++.

![Game](https://github.com/aditya26062003/SnakeGame/blob/master/Screenshot%202024-05-25%20132448.png)

## How to Play

- Use the keys (`w`, `s`, `a`, `d`) to control the direction of the snake.
- Try to eat as many fruits (`F`) as possible without colliding with the walls or the snake's own body.
- Each time the snake eats a fruit, its length increases, and your score increases.
- The game ends when the snake collides with the wall or its own body.
- Press `x` to exit the game.

## Controls

- `w` - Move the snake upwards.
- `s` - Move the snake downwards.
- `a` - Move the snake left.
- `d` - Move the snake right.
- `x` - Exit the game.

## Dependencies

- `iostream`: Standard input/output stream for console I/O.
- `conio.h`: Provides functions for non-blocking keyboard input.
- `cstdlib`: Provides functions for random number generation.
- `ctime`: Provides functions for getting the current time for seeding the random number generator.
- `thread`: Provides utilities for working with threads.

## Building the Game in Visual Studio 2022

1. Open Visual Studio 2022.
2. Create a new C++ project.
3. Copy and paste the contents of your `SnakeGame.cpp` file into the source file of your Visual Studio project.
4. Save the file.
5. If you have additional dependencies (`conio.h`, `cstdlib`, `ctime`, `thread`), make sure to include them in your project settings.

### Running the Game

1. Once the project is set up and the code is pasted, build the project by clicking on "Build" in the menu bar and then selecting "Build Solution".
2. If there are no errors, you should see "Build succeeded" in the output window.
3. Now, to run the game, simply click on "Start" or press `F5` to run the program.

### Playing the Game

1. Once the game window appears, follow the instructions provided in the game interface to play.
2. Use the specified keys (`w`, `s`, `a`, `d`) to control the snake.
3. Eat fruits (`F`) to increase your score.
4. Press `x` to exit the game.

### Exiting the Game

1. To exit the game, press `x` when prompted within the game interface and then press Enter.

### Additional Notes

- Make sure that the console window is active when playing the game to ensure keyboard input is detected.
- If there are any errors during compilation or runtime, refer to the error messages in the output window for troubleshooting.

## Credits

This Game is created by Aditya Singh

## Made with ❤️

This project was made with love and passion for creating fun and engaging games!

## License
This project is licensed under the MIT License. See the LICENSE file for details.