# MazzSweeper Game

**URL:** <https://discourse.processing.org/t/mazzsweeper-game/6519>\
**Category:** Coding Questions\
**Created:** [December 11, 2018, 8:50pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519 "2018-12-11T20:50:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jolak101](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@Jolak101](https://discourse.processing.org/u/Jolak101)\
**Post date:** [December 11, 2018, 8:50pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519/1 "2018-12-11T20:50:07Z")

</div>

Hey, I am attempting to create a Minesweeper game with a chemistry twist to it on processing. In my code, the if statement to unveil what is hidden under the square (bomb or number) did not work. I attempted to println with Mouse X and MouseY to see what the computer was computing at different positions. Whenever I pressed the mouse anywhere on the screen, the print line provided the text “object is in an invalid state.” Help?!

```auto
int square = 50;
int T = 260;
void setup() {
   size(1080, 800);
}

void draw() {
   background(240, 230, 220);
for(int a = 140; a<460; a+= 50){
   rectMode(CENTER);
   rect(80,a,50,50);
}
for(int b = 190; b<460; b+= 50){
   rectMode(CENTER);
   rect(130,b,50,50);
}
for(int c = 290; c<460; c+= 50){
   rectMode(CENTER);
   rect(180,c,50,50);
}
for(int d = 290; d<460; d+= 50){
   rectMode(CENTER);
   rect(230,d,50,50);
}
for(int e = 290; e<460; e+= 50){
   rectMode(CENTER);
   rect(280,e,50,50);
}
for(int f = 290; f<460; f+= 50){
   rectMode(CENTER);
rect(f, 640, square, square);
}
   for(int X = 290; X<460; X+=square){
      rectMode(CENTER);
      rect(530, X, square, square);
   }
   for(int XI = 290; XI<460; XI+=square){
      rectMode(CENTER);
      rect(580, XI, square, square);
   }
   for(int XII = 290; XII<460; XII+=square){
      rectMode(CENTER);
      rect(630, XII, square, square);
   }
   for(int XIII = 290; XIII<460; XIII+=square){
      rectMode(CENTER);
      rect(680, XIII, square, square);
   }
   for(int XIV = 290; XIV<460; XIV+=square){
      rectMode(CENTER);
      rect(730, XIV, square, square);
   }
   for(int XV=290; XV<460; XV+=square){
      rectMode(CENTER);
      rect(780, XV, square, square);
   }
   for(int XVI=290; XVI<460; XVI+=square){
      rectMode(CENTER);
      rect(830, XVI, square, square);
   }
   for(int XVII=190; XVII<460; XVII+=square){
      rectMode(CENTER);
      rect(880, XVII, square, square);
   }
   for(int XVIII = 140; XVIII<460; XVIII+=square){
      rectMode(CENTER);
      rect(930, XVIII, square, square);
   }
	fill(0);
	ellipse(80,140,30,30);
	noLoop();
	textSize(32);
text("He", 62, 200); 
	fill(0);
	ellipse(130,190,30,30);
	noLoop();
	fill(240,243,242,T);
	rect(80,140,50,50);
	rect(80,190,50,50);
	rect(130,190,50,50);
	noLoop(); 
	println(mouseX, mouseY);
}
void mousePressed() {
	if(mouseX > 80 && mouseX < 130 && mouseY > 140 && mouseY <190) {
		T = 0;
	}
		else {
			T = 260;
	}
}

```

---

<div class="post-metadata">

**Author:** ![PascalAudet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/pascalaudet/32/1903_2.png) [@PascalAudet](https://discourse.processing.org/u/PascalAudet)\
**Post date:** [December 11, 2018, 9:01pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519/2 "2018-12-11T21:01:46Z")

</div>

> [@Jolak101](#):
>
> noLoop();

First , do you need the noLoop() at 3 differents places?

---

<div class="post-metadata">

**Author:** ![PascalAudet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/pascalaudet/32/1903_2.png) [@PascalAudet](https://discourse.processing.org/u/PascalAudet)\
**Post date:** [December 11, 2018, 9:06pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519/3 "2018-12-11T21:06:20Z")

</div>

Whit this code I get the println(mouseX, mouseY); working

```auto
int square = 50;
int T = 260;
void setup() {
  size(1080, 800);
}

void draw() {
  background(240, 230, 220);
  for (int a = 140; a<460; a+= 50) {
    rectMode(CENTER);
    rect(80, a, 50, 50);
  }
  for (int b = 190; b<460; b+= 50) {
    rectMode(CENTER);
    rect(130, b, 50, 50);
  }
  for (int c = 290; c<460; c+= 50) {
    rectMode(CENTER);
    rect(180, c, 50, 50);
  }
  for (int d = 290; d<460; d+= 50) {
    rectMode(CENTER);
    rect(230, d, 50, 50);
  }
  for (int e = 290; e<460; e+= 50) {
    rectMode(CENTER);
    rect(280, e, 50, 50);
  }
  for (int f = 290; f<460; f+= 50) {
    rectMode(CENTER);
    rect(f, 640, square, square);
  }
  for (int X = 290; X<460; X+=square) {
    rectMode(CENTER);
    rect(530, X, square, square);
  }
  for (int XI = 290; XI<460; XI+=square) {
    rectMode(CENTER);
    rect(580, XI, square, square);
  }
  for (int XII = 290; XII<460; XII+=square) {
    rectMode(CENTER);
    rect(630, XII, square, square);
  }
  for (int XIII = 290; XIII<460; XIII+=square) {
    rectMode(CENTER);
    rect(680, XIII, square, square);
  }
  for (int XIV = 290; XIV<460; XIV+=square) {
    rectMode(CENTER);
    rect(730, XIV, square, square);
  }
  for (int XV=290; XV<460; XV+=square) {
    rectMode(CENTER);
    rect(780, XV, square, square);
  }
  for (int XVI=290; XVI<460; XVI+=square) {
    rectMode(CENTER);
    rect(830, XVI, square, square);
  }
  for (int XVII=190; XVII<460; XVII+=square) {
    rectMode(CENTER);
    rect(880, XVII, square, square);
  }
  for (int XVIII = 140; XVIII<460; XVIII+=square) {
    rectMode(CENTER);
    rect(930, XVIII, square, square);
  }
  fill(0);
  ellipse(80, 140, 30, 30);
 // noLoop();
  textSize(32);
  text("He", 62, 200);
  fill(0);
  ellipse(130, 190, 30, 30);
 // noLoop();
  fill(240, 243, 242, T);
  rect(80, 140, 50, 50);
  rect(80, 190, 50, 50);
  rect(130, 190, 50, 50);
 // noLoop();
  println(mouseX, mouseY);
}
void mousePressed() {
  if (mouseX > 80 && mouseX < 130 && mouseY > 140 && mouseY <190) {
    T = 0;
  } else {
    T = 260;
  }
}

```

---

<div class="post-metadata">

**Author:** ![Jolak101](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@Jolak101](https://discourse.processing.org/u/Jolak101)\
**Post date:** [December 11, 2018, 9:37pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519/4 "2018-12-11T21:37:40Z")

</div>

Sincerely,  
Joseph Olakkengil

---

<div class="post-metadata">

**Author:** ![Jolak101](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@Jolak101](https://discourse.processing.org/u/Jolak101)\
**Post date:** [December 11, 2018, 9:38pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519/5 "2018-12-11T21:38:46Z")

</div>

On openprocessing, I ran the code with the print ln and no matter where I clicked, the line printed was “object is in an invalid state.”

Sincerely,  
Joseph Olakkengil

---

<div class="post-metadata">

**Author:** ![PascalAudet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/pascalaudet/32/1903_2.png) [@PascalAudet](https://discourse.processing.org/u/PascalAudet)\
**Post date:** [December 11, 2018, 9:47pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519/6 "2018-12-11T21:47:09Z")

</div>

> [@Jolak101](#):
>
> On openprocessing

I run this in Processing 3.3 , I dont Know if openprecessing act like 3.3 , but  
when you use noloop() , the draw() section is not executed.

---

<div class="post-metadata">

**Author:** ![Jolak101](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@Jolak101](https://discourse.processing.org/u/Jolak101)\
**Post date:** [December 11, 2018, 11:28pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519/7 "2018-12-11T23:28:22Z")

</div>

I don’t think that is the issue. I contained all of the noLoops by surrounding them with push and pop matrixes. We put the noLoops because without them, the whole periodic table was covered by a black font rather than just the letters “He” in one square to represent two bombs in close proximity.

---

<div class="post-metadata">

**Author:** ![Jolak101](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@Jolak101](https://discourse.processing.org/u/Jolak101)\
**Post date:** [December 11, 2018, 11:32pm UTC](https://discourse.processing.org/t/mazzsweeper-game/6519/8 "2018-12-11T23:32:35Z")

</div>

Nevermind. The code works without the noLoops. Thanks so much for your help!
