Game

Struct Game 

Source
pub struct Game {
    pub event_receiver: Receiver<Event>,
    pub ghost_piece: Option<Piece>,
    pub held_piece: Option<Piece>,
    pub hold_used: bool,
    pub level: u16,
    pub lines_cleared: u16,
    pub moving_piece: Piece,
    pub next_pieces: Vec<Piece>,
    pub playfield: [[i16; 10]; 22],
    pub score: u16,
    pub speed_info_sender: Sender<u64>,
}

Fields§

§event_receiver: Receiver<Event>§ghost_piece: Option<Piece>§held_piece: Option<Piece>§hold_used: bool§level: u16§lines_cleared: u16§moving_piece: Piece§next_pieces: Vec<Piece>§playfield: [[i16; 10]; 22]§score: u16§speed_info_sender: Sender<u64>

Implementations§

Source§

impl Game

Source

pub fn get_next_piece_in_queue(&mut self, pop: bool) -> Piece

Source

pub fn piece_is_in_allowed_position( &self, piece: &Piece, ) -> Result<(), MinoesError>

Source

pub fn piece_is_out_of_bounds(&self, piece: &Piece) -> bool

Source

pub fn piece_is_overlapping_with(&self, piece: &Piece, checked: i16) -> bool

Source

pub fn add_piece_to_field(&mut self, piece: Piece) -> Result<(), MinoesError>

Source

pub fn rotate_moving_piece( &mut self, direction: &Rotation, ) -> Result<(), OutOfBoundsError>

Source

pub fn move_moving_piece( &mut self, direction: TetrisDirection, ) -> Result<(), OutOfBoundsError>

Source

pub fn hard_drop_moving_piece(&mut self) -> Result<(), MinoesError>

Source

pub fn hold_moving_piece(&mut self) -> Result<(), MinoesError>

Source

pub fn clear_filled_lines(&mut self) -> usize

Trait Implementations§

Source§

impl Debug for Game

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Game

Source§

fn default() -> Game

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Game

§

impl RefUnwindSafe for Game

§

impl Send for Game

§

impl !Sync for Game

§

impl Unpin for Game

§

impl UnwindSafe for Game

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V