pub struct CurrentPiece {
pub piece: Piece,
pub x: i32,
pub y: i32,
}Expand description
The current piece in the game, that is, a piece that is currently being moved by the player and has not been committed to the board yet.
Fields§
§piece: Piece§x: i32§y: i32Implementations§
Source§impl CurrentPiece
impl CurrentPiece
Sourcepub fn collides(&self, board: &Board, x: i32, y: i32) -> bool
pub fn collides(&self, board: &Board, x: i32, y: i32) -> bool
Detects if the position of the piece collides with existing squares on the board.
The piece cannot intersect with the walls or the bottom of the board, and it cannot intersect with existing squares on the board.
Sourcepub fn rotate_right(&mut self, board: &Board) -> bool
pub fn rotate_right(&mut self, board: &Board) -> bool
Rotate this current piece right Returns true if the rotation was successful, false if it was not.
Sourcepub fn move_left(&mut self, board: &Board) -> bool
pub fn move_left(&mut self, board: &Board) -> bool
Move this current piece to the left Returns true if the move was successful, false if it was not.
Sourcepub fn move_right(&mut self, board: &Board) -> bool
pub fn move_right(&mut self, board: &Board) -> bool
Move this current piece to the right Returns true if the move was successful, false if it was not.
Trait Implementations§
Source§impl Clone for CurrentPiece
impl Clone for CurrentPiece
Source§fn clone(&self) -> CurrentPiece
fn clone(&self) -> CurrentPiece
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CurrentPiece
impl RefUnwindSafe for CurrentPiece
impl Send for CurrentPiece
impl Sync for CurrentPiece
impl Unpin for CurrentPiece
impl UnwindSafe for CurrentPiece
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