CODE
boolean fills = false;
int upto;
int currentGame;
String puzzle;
String gameNo;
String game1Size;
String[] sizes1; //if the [] is removed a string/array unresolved error occurs
String game1Dataa;
String game1Datab;
void setup () {
size (300, 300);
fill (255);
String[] puzzle = loadStrings("ass3.txt");
String gameNo = puzzle[0];
String game1Size = puzzle[1];
String[] sizes1 = split(game1Size, ' ');
String game1Dataa = puzzle[2];
String[] dataa1 = split(game1Dataa, ' ');
String game1Datab = puzzle[3];
String[] datab1 = split(game1Datab, ' ');
}
//
void draw() {
for (int i = 1; i <= int(sizes1[0]); i++) {
// if a num in inserted into the int( ) there is no null pointer error.
for (int j = 1; j <= int(sizes1[1]); j++) {
// if the [ ] is removed it becomes a operator <= error.
rect (j+j*20, i+i*20, 20, 20);
}
}
}
void mousePressed (){
for (int i = 1; i<= 10; i++) {
for (int j = 1; j<=10; j++) {
if (mouseX > j+j*20 && mouseX < j+(j+1)*20 && mouseY >i+i*20 && mouseY < i+(i+1)*20){
println (mouseX + ", " + mouseY);
fills = !fills;
if (fills) {
fill(0);
} else {
fill(255);
}
}
}
}
}
Bookmarks