-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathMinesweeper.pde
More file actions
108 lines (98 loc) · 2.14 KB
/
Minesweeper.pde
File metadata and controls
108 lines (98 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import de.bezier.guido.*;
//Declare and initialize constants NUM_ROWS and NUM_COLS = 20
private MSButton[][] buttons; //2d array of minesweeper buttons
private ArrayList <MSButton> mines; //ArrayList of just the minesweeper buttons that are mined
void setup ()
{
size(400, 400);
textAlign(CENTER,CENTER);
// make the manager
Interactive.make( this );
//your code to initialize buttons goes here
setMines();
}
public void setMines()
{
//your code
}
public void draw ()
{
background( 0 );
if(isWon() == true)
displayWinningMessage();
}
public boolean isWon()
{
//your code here
return false;
}
public void displayLosingMessage()
{
//your code here
}
public void displayWinningMessage()
{
//your code here
}
public boolean isValid(int r, int c)
{
//your code here
return false;
}
public int countMines(int row, int col)
{
int numMines = 0;
//your code here
return numMines;
}
public class MSButton
{
private int myRow, myCol;
private float x,y, width, height;
private boolean clicked, flagged;
private String myLabel;
public MSButton ( int row, int col )
{
// width = 400/NUM_COLS;
// height = 400/NUM_ROWS;
myRow = row;
myCol = col;
x = myCol*width;
y = myRow*height;
myLabel = "";
flagged = clicked = false;
Interactive.add( this ); // register it with the manager
}
// called by manager
public void mousePressed ()
{
clicked = true;
//your code here
}
public void draw ()
{
if (flagged)
fill(0);
// else if( clicked && mines.contains(this) )
// fill(255,0,0);
else if(clicked)
fill( 200 );
else
fill( 100 );
rect(x, y, width, height);
fill(0);
text(myLabel,x+width/2,y+height/2);
}
public void setLabel(String newLabel)
{
myLabel = newLabel;
}
public void setLabel(int newLabel)
{
myLabel = ""+ newLabel;
}
public boolean isFlagged()
{
return flagged;
}
}