A classic Snake game written in Rust using SDL2.
This project was created primarily as a learning exercise while exploring Rust, SDL2, game development, asset management, and related concepts. As a result, the code is not particularly clean or idiomatic in places—but it was a fun project to build and experiment with.
- Classic Snake gameplay
- Keyboard-controlled movement
- Menu navigation
- Sound effects and music
- Custom graphics and fonts
- Packed game assets
- Screenshot support
| Key | Action |
|---|---|
| Arrow Keys | Navigate menus and control the snake |
| Enter / Return | Select menu options |
| Ctrl + Print Screen | Save a screenshot |
![]() |
![]() |
![]() |
![]() |
![]() |
- rand;
- sdl2, with the
ttf,imageandmixerfeatures.
Make sure the required SDL2 development libraries are installed on your system before building the project.
Clone the repository and build the project with Cargo:
git clone https://github.com/delarco/snake-rust.git
cd snake-rust
cargo run --releaseAlternatively, build without running:
cargo build --releaseThe resulting executable will be available in:
target/release/
Note: SDL2 must be installed and available on your system for the game to build and run.
Game assets are stored in a packed data.pck file.
The tools directory contains Python scripts for extracting and creating this asset pack.
To extract the contents of data.pck, run:
cd tools
python datapack_extract.pyThe script extracts all assets from data.pck into:
tools/assets/
After extraction, the image, audio and font files can be edited directly.
To add a new asset:
- Add it's file index and name to
tools/files.json. - Copy the asset into
tools/assets/. - Update the AssetsEnum in
src/assets.rs. - Add the corresponding asset to the code where required.
To create a new data.pck file, run:
cd tools
python datapack_create.pyThis creates a new data.pck containing all files mapped in tools/files.json.
All referenced files must exist in:
tools/assets/
This is primarily a learning project rather than a polished or production-ready game.
The code contains areas that could be refactored, simplified, or made more idiomatic as my Rust knowledge improves.
- Compress assets in the data pack
- Implement a scoreboard
- Add tests
- Refactor and clean up the code
This project is licensed under the MIT License. See the LICENSE file for details.




