tetris/src/game.rs

53 lines
1.4 KiB
Rust
Raw Normal View History

2020-03-19 15:51:43 -07:00
// A game is a self-contained struct that holds everything that an instance of
// Tetris needs to run, except for something to tick the time forward.
use crate::playfield::PlayField;
use crate::srs::RotationSystem;
use crate::srs::SRS;
pub struct Game<RS: RotationSystem> {
playfield: PlayField,
rotation_system: RS,
level: u8,
points: u64,
}
trait PlayerControllable {
fn move_left(&mut self);
fn move_up(&mut self);
fn move_right(&mut self);
fn move_down(&mut self);
fn rotate_left(&mut self);
fn rotate_right(&mut self);
fn hard_drop(&mut self);
fn hold(&mut self);
}
impl<RS: RotationSystem> PlayerControllable for Game<RS> {
fn move_left(&mut self) {}
fn move_up(&mut self) {}
fn move_right(&mut self) {}
fn move_down(&mut self) {}
fn rotate_left(&mut self) {}
fn rotate_right(&mut self) {}
fn hard_drop(&mut self) {}
fn hold(&mut self) {
// if self.can_swap_hold {
// match self.hold_piece {
// None => {
// self.hold_piece = Some(self.active_piece);
// self.get_new_piece();
// }
// Some(piece) => {
// self.hold_piece = Some(self.active_piece);
// self.active_piece = piece;
// self.reset_position();
// }
// }
// self.can_swap_hold = false;
// }
}
}