snake/lib.rs
1//! # Quick Start
2//!
3//! Initialize with `new` and use `turn` to progress a game step. An example is in [game.rs](https://github.com/jspspike/snake/blob/master/examples/game.rs).
4//!
5//! Game without display
6//! ```
7//! use snake::{Snake, Direction};
8//! let mut game = Snake::new(0, 10);
9//!
10//! game.turn(Direction::Down);
11//! ```
12//!
13//! You can use the `display` feature flag to have a window displaying the game. This requires
14//! [csfml](https://www.sfml-dev.org/download/csfml) to be installed.
15//!
16//! Game with display
17//! ```ignore
18//! use snake::{Direction, RenderWindow, Snake, Style};
19//! let window = RenderWindow::new((1000, 1000), "Snake", Style::CLOSE, &Default::default());
20//! let mut game = Snake::new_display(0, 15, Some(window));
21//! ```
22//!
23//! ### Installing CSFML
24//! Arch:
25//! ```sh
26//! sudo pacman -Syu csfml
27//! ```
28//! Ubuntu:
29//! ```sh
30//! sudo apt-get install libcsfml
31//! ```
32
33mod coord;
34#[cfg(feature = "display")]
35mod display;
36mod snake;
37
38pub use crate::coord::Direction;
39pub use crate::snake::Snake;
40
41#[cfg(feature = "display")]
42pub use crate::snake::{RenderWindow, Style};