implement level completion, score storing and a dismissable 'level complete' popup
This commit is contained in:
parent
4aa5ed9eec
commit
f9b8dba019
7 changed files with 130 additions and 18 deletions
|
@ -63,10 +63,10 @@ impl Board {
|
|||
Board::new(rows)
|
||||
}
|
||||
|
||||
pub fn to_string(&self)->String{
|
||||
pub fn to_string(&self) -> String {
|
||||
let mut out = String::new();
|
||||
for row in &self.rows{
|
||||
for tile in row{
|
||||
for row in &self.rows {
|
||||
for tile in row {
|
||||
out.push(tile.to_char())
|
||||
}
|
||||
out.push('\n');
|
||||
|
@ -91,6 +91,19 @@ impl Board {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn count_tiles(&self) -> usize {
|
||||
let mut sum = 0;
|
||||
for row in &self.rows {
|
||||
for tile in row {
|
||||
match tile {
|
||||
Tile::Blank | Tile::Block => (),
|
||||
_ => sum += 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
sum
|
||||
}
|
||||
|
||||
pub fn in_bounds(&self, p: Pos) -> bool {
|
||||
p.x >= 0 && p.y >= 0 && p.x < self.width as isize && p.y < self.height as isize
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue