Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 49 additions & 58 deletions Minesweeper.pde
Original file line number Diff line number Diff line change
@@ -1,108 +1,99 @@
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 ()
{
// 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


Interactive.make(this);

// your code to initialize buttons goes here
setMines();
}
public void setMines()
{
//your code

public void setMines() {
// your code
}

public void draw ()
{
background( 0 );
if(isWon() == true)
displayWinningMessage();
public void draw() {
background(0);
if (isWon() == true) displayWinningMessage();
}
public boolean isWon()
{
//your code here

public boolean isWon() {
// your code here
return false;
}
public void displayLosingMessage()
{
//your code here

public void displayLosingMessage() {
// your code here
}
public void displayWinningMessage()
{
//your code here

public void displayWinningMessage() {
// your code here
}
public boolean isValid(int r, int c)
{
//your code here

public boolean isValid(int r, int c) {
// your code here
return false;
}
public int countMines(int row, int col)
{

public int countMines(int row, int col) {
int numMines = 0;
//your code here
// your code here
return numMines;
}
public class MSButton
{

public class MSButton {
private int myRow, myCol;
private float x,y, width, height;
private float x, y, width, height;
private boolean clicked, flagged;
private String myLabel;

public MSButton ( int row, int col )
{
public MSButton (int row, int col) {
// width = 400/NUM_COLS;
// height = 400/NUM_ROWS;
myRow = row;
myCol = col;
x = myCol*width;
y = myRow*height;
x = myCol * width;
y = myRow * height;
myLabel = "";
flagged = clicked = false;
Interactive.add( this ); // register it with the manager
Interactive.add(this); // register it with the manager
}

// called by manager
public void mousePressed ()
{
public void mousePressed() {
clicked = true;
//your code here
// your code here
}
public void draw ()
{

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 );
else if (clicked) fill(200);
else fill(100);

rect(x, y, width, height);
fill(0);
text(myLabel,x+width/2,y+height/2);
text(myLabel, x + width / 2, y + height / 2);
}
public void setLabel(String newLabel)
{

public void setLabel(String newLabel) {
myLabel = newLabel;
}
public void setLabel(int newLabel)
{
myLabel = ""+ newLabel;

public void setLabel(int newLabel) {
myLabel = "" + newLabel;
}
public boolean isFlagged()
{

public boolean isFlagged() {
return flagged;
}
}