Lecture 13 - Minesweeper
Classes and Methods
- int ACTION_DOWN
- final int getAction ( )
- final float getX ( )
- final float getY ( )
- void drawLine(float startX, float startY, float stopX, float stopY, Paint paint)
- void drawText(String text, float x, float y, Paint paint)
- void setTextSize(float textSize)
- void setColor (int color)
- void invalidate ()
- int nextInt (int n)
- static String toString (int i)
- static final int BLACK
- static final int RED
- static Toast makeText(Context context, CharSequence text, int duration)
- void show ( )
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.
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.