| Crates.io | snake-rs |
| lib.rs | snake-rs |
| version | 0.1.2 |
| created_at | 2020-09-02 02:08:06.289687+00 |
| updated_at | 2021-03-28 23:08:44.313158+00 |
| description | A library to handle the logic for the classic game snake |
| homepage | |
| repository | https://github.com/jspspike/snake |
| max_upload_size | |
| id | 283717 |
| size | 186,818 |
A library to handle the logic for the classic game snake.

[dependencies]
snake-rs = "0.1.1"
Initialize with new and use turn to progress a game step. An example is in game.rs.
Game without display
use snake::{Snake, Direction};
let mut game = Snake::new(0, 10);
game.turn(Direction::Down);
You can use the display feature flag to have a window displaying the game. This requires
csfml to be installed.
Game with display
use snake::{Direction, RenderWindow, Snake, Style};
let window = RenderWindow::new((1000, 1000), "Snake", Style::CLOSE, &Default::default());
let mut game = Snake::new_display(0, 15, Some(window));
Arch:
sudo pacman -Syu csfml
Ubuntu:
sudo apt-get install libcsfml
git clone https://github.com/jspspike/snake
cd snake
cargo run --example game --features display