Minesweeper: Fix wrong adjacency numbers on right and bottom edges.

This commit is contained in:
Andreas Kling 2019-04-13 14:14:38 +02:00
parent 0dbd7b0409
commit 3f37665492
Notes: sideshowbarker 2024-07-19 14:44:00 +09:00
2 changed files with 5 additions and 7 deletions

View file

@ -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));
}

View file

@ -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);