pub struct Game<'a, 'b, 'c: 'b> {
options: GameOptions,
speed: Speed,
serpent: Arc<RwLock<SnakeBody<'a>>>,
direction: Arc<RwLock<Direction>>,
carte: Arc<RwLock<Map<'b>>>,
state: Arc<RwLock<GameState>>,
fruits_manager: Arc<RwLock<FruitsManager<'c, 'b>>>,
terminal: DefaultTerminal,
}
Expand description
Our game engine NB: ’c must outlive ’b as, ’c (fruits manager) uses in intern the map with lock on it.
Fields§
§options: GameOptions
Game main parameters
speed: Speed
The game logic speed, linked to the snake movements
serpent: Arc<RwLock<SnakeBody<'a>>>
Represents the snake moving around
direction: Arc<RwLock<Direction>>
The direction chosen by the player for the snake
carte: Arc<RwLock<Map<'b>>>
The game logic map where items/snake are displayed
NB: As we want a resizable map, RwLock
, otherwise use only Arc
state: Arc<RwLock<GameState>>
Game states and metrics (life etc.)
fruits_manager: Arc<RwLock<FruitsManager<'c, 'b>>>
Manage fruits (popping, eaten etc.)
terminal: DefaultTerminal
The current terminal
Implementations§
Source§impl<'a, 'b, 'c> Game<'a, 'b, 'c>
impl<'a, 'b, 'c> Game<'a, 'b, 'c>
Auto Trait Implementations§
impl<'a, 'b, 'c> Freeze for Game<'a, 'b, 'c>
impl<'a, 'b, 'c> RefUnwindSafe for Game<'a, 'b, 'c>
impl<'a, 'b, 'c> Send for Game<'a, 'b, 'c>
impl<'a, 'b, 'c> Sync for Game<'a, 'b, 'c>
impl<'a, 'b, 'c> Unpin for Game<'a, 'b, 'c>
impl<'a, 'b, 'c> UnwindSafe for Game<'a, 'b, 'c>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more