https://github.com/changerd/oopsnake
console-based implementation of the classic Snake game
https://github.com/changerd/oopsnake
charp console oop
Last synced: 2 months ago
JSON representation
console-based implementation of the classic Snake game
- Host: GitHub
- URL: https://github.com/changerd/oopsnake
- Owner: changerd
- Created: 2021-07-08T18:53:39.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-25T20:58:34.000Z (10 months ago)
- Last Synced: 2025-01-29T08:37:29.253Z (4 months ago)
- Topics: charp, console, oop
- Language: C#
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OOPSnake
**OOPSnake** is a console-based Snake game implemented in C#. This project serves as a practical example of object-oriented programming principles, demonstrating how to manage game state, handle user input, and implement game mechanics.
## Features
- **Snake Movement**: Control the snake using arrow keys to navigate the console window.
- **Food Consumption**: Eat food to grow the snake and increase the score.
- **Collision Detection**: The game ends when the snake collides with the walls or itself.
- **Dynamic Walls**: Walls are represented as lines drawn at the edges of the console window.## How It Works
- **Console Window Setup**: The game runs in an 80x25 console window with adjustable buffer size.
- **Game Entities**: The game includes the snake, food, and walls, each managed by its respective class:
- `Snake`: Handles movement, growth, and collision detection.
- `FoodCreator`: Generates food items at random positions.
- `Walls`: Creates and manages the boundaries of the game.
- **Game Loop**: The main game loop checks for collisions, processes user input, and updates the game state at regular intervals.## Getting Started
1. **Clone the Repository**:
```sh
git clone https://github.com/changerd/OOPSnake
```
2. **Open the Project**:
Open the OOPSnake project in Visual Studio or any C# compatible IDE.
3. **Build and run**:
Build the project and run the application to start playing the game in the console window.## Gameplay
- Use the arrow keys to control the direction of the snake.
- Eat the food (represented by $) to grow the snake.
- Avoid collisions with the walls and the snake's own body.
- The game ends when the snake crashes into the walls or itself.