Lecture 13 - Minesweeper

home | previous | next

Classes and Methods

Exercise

Minesweeper is a single-player puzzle video game. The game has been written for many computing platforms. Before starting the project, find the game in your computer. Play and examine it what rules the game has.

Exercise 13.1

1. Make a new project and put one view widget and one button widget on the panel.

2. On the view widget, draw cells with 5 columns and 5 rows.

3. Select 3 cells randomly and set the values of the cells to -1. In this project -1 means mine.

4. On every cell, show the number of mines around the cell.

5. Hide all the numbers and get the click motion from the user.

6. When the user clicks a cell, show the number of the cell.

7. If the user clears all cells or clicks the cell with mine, show the toast.

8. Write code for the 'Reset' button to restart the game.