Compare commits
40 Commits
a1d788fd5f
...
main
Author | SHA1 | Date | |
---|---|---|---|
8893395878
|
|||
cf60d6734a
|
|||
32070e9af4
|
|||
1bd27128ae
|
|||
1160c5d143
|
|||
f24af6f800
|
|||
f7aa9c6e35
|
|||
88ed908faa
|
|||
9fc8654e7b
|
|||
903b2d7ead
|
|||
bf202a42ba
|
|||
1db789889c
|
|||
e3bdce6065
|
|||
18113a3f4b
|
|||
8078438d3c
|
|||
921f68a081
|
|||
57a634d4ee
|
|||
23bb3e1153
|
|||
428fca40ae
|
|||
1309ee7489
|
|||
5022c840de
|
|||
ab5f2b200c
|
|||
8fb04f9ad0
|
|||
a8e8c1fcac
|
|||
4131baa1a5
|
|||
c19af78ae2
|
|||
9c515cfab0
|
|||
db859ddeb8
|
|||
eda305e402
|
|||
c03c996a48
|
|||
b8cd346b0a
|
|||
622f6d1791
|
|||
59df532105
|
|||
fa2ff36610
|
|||
d6e8bb8859
|
|||
8f71fa0771
|
|||
fc93078d3f
|
|||
9cebf49862
|
|||
db99e90198
|
|||
8378376385
|
@ -97,12 +97,28 @@ impl TetrisBoard {
|
|||||||
/// Get the value of the cell at the given position.
|
/// Get the value of the cell at the given position.
|
||||||
/// Returns [`None`] if (x, y) exceeds the board's bounds.
|
/// Returns [`None`] if (x, y) exceeds the board's bounds.
|
||||||
pub fn get_cell(&self, x: usize, y: usize) -> Option<&TetrisCell> {
|
pub fn get_cell(&self, x: usize, y: usize) -> Option<&TetrisCell> {
|
||||||
|
if y >= TetrisBoard::BOARD_HEIGHT {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if x >= TetrisBoard::BOARD_WIDTH {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
return self.board.get(y * TetrisBoard::BOARD_WIDTH + x);
|
return self.board.get(y * TetrisBoard::BOARD_WIDTH + x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a mutable reference to the cell at the given position.
|
/// Get a mutable reference to the cell at the given position.
|
||||||
/// Returns [`None`] if (x, y) exceeds the board's bounds.
|
/// Returns [`None`] if (x, y) exceeds the board's bounds.
|
||||||
pub fn get_cell_mut(&mut self, x: usize, y: usize) -> Option<&mut TetrisCell> {
|
pub fn get_cell_mut(&mut self, x: usize, y: usize) -> Option<&mut TetrisCell> {
|
||||||
|
if y >= TetrisBoard::BOARD_HEIGHT {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
if x >= TetrisBoard::BOARD_WIDTH {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
return self.board.get_mut(y * TetrisBoard::BOARD_WIDTH + x);
|
return self.board.get_mut(y * TetrisBoard::BOARD_WIDTH + x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user