diff options
author | curly <curlybryce@protonmail.com> | 2022-08-15 16:28:00 -0600 |
---|---|---|
committer | curly <curlybryce@protonmail.com> | 2022-08-15 16:28:00 -0600 |
commit | 02515663dd89994dbc987958b19d707a4cd44864 (patch) | |
tree | 08d12a78bed40dedd33e0180b0c1d70815ca8ec7 /src/lib.rs | |
parent | 462c1f8bf195a1e30b6c05be7a0ec60ee89d230c (diff) | |
download | tetris-02515663dd89994dbc987958b19d707a4cd44864.tar.gz tetris-02515663dd89994dbc987958b19d707a4cd44864.tar.bz2 tetris-02515663dd89994dbc987958b19d707a4cd44864.zip |
Piece.area needs a rewrite again
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -7,29 +7,31 @@ use std::io::stdin; use crate::input::Input; pub struct Game { - tickrate: u8, // Between + tickrate: u8, // How many times things are checked a second maxfps: u8, // Between 1 and 240 + gamespeed: u8, // How quickly r#move(down) is called in ms } impl Game { pub fn new() -> Game { Game{ tickrate: 20, maxfps: 30, + gamespeed: 250, } } // The actual game loop pub fn game_loop(&self, input: &Input) { let mut tetris = tetris::Tetris::new(); - let mut piece = piece::Piece::random(); + let mut piece = piece::Piece::random(piece::Pos(0,0)); loop { piece.r#move(piece::Dir::Down, &tetris); // Check if piece is dead if piece.is_alive() == false { piece.apply_to_grid(&mut tetris); - // piece = piece::Piece::random(); - piece = piece::Piece::new(piece::Pieces::Cube); + piece = piece::Piece::random(piece::Pos(0,0)); + // piece = piece::Piece::new(piece::Pieces::Cube, piece::Pos(0,0)); } let grid = tetris.return_grid(); @@ -43,7 +45,7 @@ impl Game { "a" => piece.r#move(piece::Dir::Left, &tetris), "d" => piece.r#move(piece::Dir::Right, &tetris), "e" => piece.rotate(piece::Rotate::Right), - "q" => piece.rotate(piece::Rotate::Right), + "q" => piece.rotate(piece::Rotate::Left), " " => break, _ => (), } |