pub struct Game<'a, 'b, 'c: 'b, 't: 'a + 'b + 'c> {
options: &'t 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: &'t mut DefaultTerminal,
}Expand description
our game engine NB: ’c must outlive ’b as, ’c (fruits manager) uses in intern the map with lock on it. NB: ’t the terminal life must outlive all the other lifetimes
Fields§
§options: &'t GameOptionsGame main parameters
speed: SpeedThe 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: &'t mut DefaultTerminalThe current terminal
Implementations§
Source§impl<'a, 'b, 'c, 't> Game<'a, 'b, 'c, 't>
impl<'a, 'b, 'c, 't> Game<'a, 'b, 'c, 't>
Auto Trait Implementations§
impl<'a, 'b, 'c, 't> Freeze for Game<'a, 'b, 'c, 't>
impl<'a, 'b, 'c, 't> RefUnwindSafe for Game<'a, 'b, 'c, 't>
impl<'a, 'b, 'c, 't> Send for Game<'a, 'b, 'c, 't>
impl<'a, 'b, 'c, 't> Sync for Game<'a, 'b, 'c, 't>
impl<'a, 'b, 'c, 't> Unpin for Game<'a, 'b, 'c, 't>
impl<'a, 'b, 'c, 't> !UnwindSafe for Game<'a, 'b, 'c, 't>
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