readme.md
img.png
This commit is contained in:
98
readme.md
Normal file
98
readme.md
Normal file
@@ -0,0 +1,98 @@
|
||||
# cppsnek - A Simple Snake Game in C++ with SFML
|
||||
|
||||

|
||||
|
||||
Snake in C++17 ; uses SFML ; the snake is on fucking crack ; it moves like a fucking mig21
|
||||
|
||||
## Features
|
||||
|
||||
- Classic Snake gameplay with grid-based movement
|
||||
- Score tracking and milestone celebrations
|
||||
- Programmatically generated sound effects (no external audio files needed)
|
||||
- Simple pixel-art style graphics
|
||||
- Responsive controls (WASD or arrow keys)
|
||||
- Adjustable game speed that increases with score
|
||||
- Visual grid overlay
|
||||
- Pause/resume functionality (Space key)
|
||||
|
||||
## Technical Details
|
||||
|
||||
- **Language**: C++17
|
||||
- **Libraries**:
|
||||
- SFML 2.5+ (Graphics, Window, System, Audio modules)
|
||||
- **Pattern**: Object-oriented design with separate classes for game logic, rendering, and sound
|
||||
- **Notable Techniques**:
|
||||
- Programmatic sound generation
|
||||
- Pixel pattern-based sprite creation
|
||||
- Vertex arrays for grid rendering
|
||||
- State management for game flow
|
||||
|
||||
## Building the Project
|
||||
|
||||
### Requirements
|
||||
|
||||
- CMake (version 3.10+)
|
||||
- SFML development libraries (libsfml-graphics, libsfml-window, libsfml-system, libsfml-audio)
|
||||
- C++17 compatible compiler
|
||||
|
||||
### Build Steps
|
||||
|
||||
```bash
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
### Running
|
||||
|
||||
```bash
|
||||
./cppsnek
|
||||
```
|
||||
|
||||
## Controls
|
||||
|
||||
- **W** - Move Up
|
||||
- **A** - Move Left
|
||||
- **S** - Move Down
|
||||
- **D** - Move Right
|
||||
- **Space** - Pause/Resume game
|
||||
|
||||
## Code Structure
|
||||
|
||||
```
|
||||
.
|
||||
├── main.cpp # Main game implementation
|
||||
├── CMakeLists.txt # Build configuration
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
Key classes:
|
||||
- `Game`: Main game loop and state management
|
||||
- `SoundManager`: Handles all audio generation and playback
|
||||
- `NumericSprite`: Creates sprites from numeric patterns
|
||||
- `SnakeSegment`: Simple struct for snake body parts
|
||||
|
||||
## Customization
|
||||
|
||||
You can easily modify:
|
||||
- Game speed by changing the `speed` initial value in `Game` constructor
|
||||
- Grid appearance by modifying the `createGrid()` method
|
||||
- Snake and fruit visuals by editing the pattern arrays
|
||||
- Sound characteristics in the `SoundManager` class
|
||||
|
||||
## Known Issues/Limitations
|
||||
|
||||
- Sound generation is CPU-intensive during initialization
|
||||
- No proper game menu or start screen
|
||||
- High scores aren't persisted between sessions
|
||||
- Theme song generation is currently commented out
|
||||
|
||||
## Learning Objectives
|
||||
|
||||
This project demonstrates:
|
||||
1. SFML basics (window management, rendering, input handling)
|
||||
2. Game loop implementation
|
||||
3. Procedural audio generation
|
||||
4. Simple collision detection
|
||||
5. State management in games
|
||||
6. Object-oriented game design
|
||||
Reference in New Issue
Block a user