mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
Minesweeper: Fix wrong adjacency numbers on right and bottom edges.
This commit is contained in:
parent
0dbd7b0409
commit
3f37665492
2 changed files with 5 additions and 7 deletions
|
@ -50,17 +50,17 @@ void Field::for_each_neighbor_of(const Square& square, Callback callback)
|
|||
callback(this->square(r - 1, c));
|
||||
if (c > 0) // Left
|
||||
callback(this->square(r, c - 1));
|
||||
if (r < (m_rows - 2)) // Down
|
||||
if (r < (m_rows - 1)) // Down
|
||||
callback(this->square(r + 1, c));
|
||||
if (c < (m_columns - 2)) // Right
|
||||
if (c < (m_columns - 1)) // Right
|
||||
callback(this->square(r, c + 1));
|
||||
if (r > 0 && c > 0) // UpLeft
|
||||
callback(this->square(r - 1, c - 1));
|
||||
if (r > 0 && c < (m_columns - 2)) // UpRight
|
||||
if (r > 0 && c < (m_columns - 1)) // UpRight
|
||||
callback(this->square(r - 1, c + 1));
|
||||
if (r < (m_rows - 2) && c > 0) // DownLeft
|
||||
if (r < (m_rows - 1) && c > 0) // DownLeft
|
||||
callback(this->square(r + 1, c - 1));
|
||||
if (r < (m_rows - 2) && c < (m_columns - 2)) // DownRight
|
||||
if (r < (m_rows - 1) && c < (m_columns - 1)) // DownRight
|
||||
callback(this->square(r + 1, c + 1));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ int main(int argc, char** argv)
|
|||
container->set_preferred_size({ 0, 36 });
|
||||
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
auto* face_button = new GButton(container);
|
||||
face_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
face_button->set_preferred_size({ 32, 32 });
|
||||
face_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/minesweeper/face-default.png"));
|
||||
|
||||
auto* field = new Field(widget);
|
||||
|
|
Loading…
Add table
Reference in a new issue