A classic Snake game built with C++ and Raylib, compiled to WebAssembly for web browsers.
- Arrow Keys: Move the snake
- Spacebar: Start the game
- Q: Quit to game over
- R: Restart from game over screen
- F or Fullscreen Button: Toggle fullscreen mode
- Classic Snake gameplay
- Responsive fullscreen mode
- Smooth animations
- Score tracking
- Food collection with growth mechanics
- Collision detection (walls and self)
- Pulsing food animation
- Retro-style graphics
- C++ - Game logic and structure
- Raylib - Graphics and input handling
- Emscripten - WebAssembly compilation
- WebAssembly - High-performance web execution
- Emscripten SDK
- Raylib (web-compiled version)
- Make
- Clone this repository
- Ensure you have the web-compiled Raylib in
../raylib/src/ - Compile:
emcc main.cc \
-I../raylib/src
-L../raylib/src
-lraylib.web
-s USE_GLFW=3
-s ASYNCIFY
-s FORCE_FILESYSTEM=1
-DPLATFORM_WEB
-o snake_game.html
4. Serve locally:
```bash
python3 -m http.server 8000
- Chrome/Chromium (recommended)
- Firefox
- Safari
- Edge
- Control the snake to eat the red food
- Each food item increases your score by 10 points
- The snake grows longer with each food eaten
- Avoid hitting the walls or your own body
- Try to achieve the highest score possible!
This project is open source and available under the MIT License.