Skip to content

Commit

Permalink
Merge pull request #54 from Brian-Catcow-B/default
Browse files Browse the repository at this point in the history
Board::new_empty() -> default()
  • Loading branch information
Brian-Catcow-B authored Mar 15, 2021
2 parents 374b42c + 37ed708 commit 6c60a84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/game/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Board {
vec_active_piece.push(Piece::new(Shapes::None));
}
let matrix = vec![
vec![Tile::new_empty(); board_width as usize];
vec![Tile::default(); board_width as usize];
(board_height + BOARD_HEIGHT_BUFFER_U) as usize
];

Expand Down Expand Up @@ -55,7 +55,7 @@ impl Board {
.take(4)
{
if position != &(0xffu8, 0xffu8) {
self.matrix[position.0 as usize][position.1 as usize] = Tile::new_empty();
self.matrix[position.0 as usize][position.1 as usize] = Tile::default();
} else {
println!("[!] tried to emptify piece that contained position (0xffu8, 0xffu8)");
}
Expand Down Expand Up @@ -330,7 +330,7 @@ impl Board {
self.matrix
.remove(self.vec_full_lines[index - indices_destroyed].row as usize);
self.matrix
.insert(0, vec![Tile::new_empty(); self.width as usize]);
.insert(0, vec![Tile::default(); self.width as usize]);
self.vec_full_lines.remove(index - indices_destroyed);
indices_destroyed += 1;
// now is when we step backwards through the self.vec_full_lines vector,
Expand Down
4 changes: 3 additions & 1 deletion src/game/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ impl Tile {
player,
}
}
}

pub fn new_empty() -> Self {
impl Default for Tile {
fn default() -> Self {
Self {
empty: true,
active: false,
Expand Down

0 comments on commit 6c60a84

Please sign in to comment.