https://github.com/ocdbytes/rsnake
Snake Game : Rust 🐍
https://github.com/ocdbytes/rsnake
piston-window rust standard-library
Last synced: 11 months ago
JSON representation
Snake Game : Rust 🐍
- Host: GitHub
- URL: https://github.com/ocdbytes/rsnake
- Owner: ocdbytes
- Created: 2023-07-28T21:36:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-02T01:55:17.000Z (over 2 years ago)
- Last Synced: 2024-04-14T10:46:09.524Z (almost 2 years ago)
- Topics: piston-window, rust, standard-library
- Language: Rust
- Homepage:
- Size: 348 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# RSnake
Snake game made in rust lang using `piston_window` game engine.

## File Structure
```sh
---- /src
| - draw.rs
| - game.rs
| - snake.rs
| - main.rs
---- /target
---- Cargo.toml
---- config.json
---- score.txt
---- Readme.md
```
- `draw.rs` : This file contains all the functions that allow to create the block and rectangle using the piston_window library.
- `game.rs` : This file contains all the functions that are related to Game and it also contains the functions to check the snake state.
- `snake.rs` : This file contains all the functions related to updating the state of the snake and checking the current state.
- `main.rs` : This file contains all the main functions to init the game and make the canvas to render a window.
- `config.json` : This file contains the config for the game.
- `score.txt` : This file tracks the score.
**CONFIG file :**
```json
{
"food_exists": "true",
"moving_period": "0.1",
"restart_time": "1.0"
}
```
1. food_exists : Initiate food in game or not.
2. moving_period : Game speed.
3. restart_time : Time after that game will restart after the `game_over`.
## Build
```sh
cargo update
cargo build
```
## Run
```sh
cargo run
```
## Libraries
Piston Window
-
Rand
-