# I have a problem with the menu of my game

**URL:** <https://discourse.processing.org/t/i-have-a-problem-with-the-menu-of-my-game/21826>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [June 13, 2020, 12:35am UTC](https://discourse.processing.org/t/i-have-a-problem-with-the-menu-of-my-game/21826 "2020-06-13T00:35:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![OohYuma](https://avatars.discourse-cdn.com/v4/letter/o/96bed5/32.png) [@OohYuma](https://discourse.processing.org/u/OohYuma)\
**Post date:** [June 13, 2020, 12:35am UTC](https://discourse.processing.org/t/i-have-a-problem-with-the-menu-of-my-game/21826/1 "2020-06-13T00:35:48Z")

</div>

Hi guys, I’m a beginner with processing and others languages. I started to do a Snake game for my exam but I have a problem with my code. When I’m in the menu, I can select to play (pic.1) or to go in the setting(pic.2) and I don’t have any problems. The problem is that when I play and pause to open the settings, the setting menu is bugged and I don’t understand why. I can’t exit the menu like I can do when the game is not start and the color of some thing are not correct. I commented on the necessary line of code. I hope I’ve been clear, I apologize if it’s not. I’m not really used to using this kind of forum.  
I also added a link to my complete code if u want to test and see the problem.

> **[TransferNow](https://www.transfernow.net/files/?utm_source=jpZCDW062020&utm_medium=&utm_content=en)**
>
> Download your files now with TransferNow.net, the simple and free service for sending and sharing large files.

 ![menu](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0f9f2400907a5549f3450c5ca3d736defb998111.jpeg)  
 ![setting](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/fbd34edf855fbc33d48457af7836bb57001070ea.jpeg)  
 ![problem](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a566ee2775116a32955972144bdb3d66e7364e9a.jpeg)

```auto
void draw()
{
  menu(); // start the menu
}

void menu()
{
  if (playgame == false) // show the menu (pic. 1)
  {
    image(movie, 0, 0);
    play();
    setting(); // open the setting
  } else
  {
    game();
  }
}

void setting()
{
  textAlign(CORNER, RIGHT);
  if (mouseX>310 && mouseX<380 && mouseY > 10 && mouseY < 30)
  {
    textSize(22);
    if (mousePressed)
    {
      setting = true;
    }
  } else
  {
    textSize(18);
  }
  fill(0);
  text("Settings", 310, 25);
  stroke(1);
  if (setting)
  {
    stroke(1);
    if (general) // if general is chosen, the shape where " general " is writen becomes dark
    {
      fill(0, 50);
    } else
    {
      fill(255);
    }
    beginShape(); // the form where "general" is writen
    vertex(0, 50);
    vertex(25, 20);
    vertex(75, 20);
    vertex(100, 50);
    endShape(CLOSE);
    if (general) // same but for " Key "
    {
      fill(255);
    } else
    {
      fill(0, 50);
    }
    beginShape(); // same but for " Key"
    vertex(100, 50);
    vertex(125, 20);
    vertex(175, 20);
    vertex(200, 50);
    endShape(CLOSE);
    fill(255);
    stroke(1);
    rectMode(CORNER);
    rect(0, 50, 400, 400);
    if (mousePressed)
    {
      if (mouseX>0 && mouseX< 100 && mouseY > 20 && mouseY < 50)
      {
        general = true;
      }
      if (mouseX>100 && mouseX< 200 && mouseY > 20 && mouseY < 50)
      {
        general = false;
      }
    }
    fill(0);
    textSize(14);
    textAlign(CENTER);
    text("General", 50, 40);
    text("Keys", 150, 40);
    if (general)
    {
      colorS();
      difficulty();
      song();
      volumeM();
      volumeE();
    } else
    {
      chooseKey();
    }
    fill(0);
    textAlign(LEFT);
    text("Save and exit", 300, 440);
    if (mouseX>295 && mouseX<390 && mouseY > 425 && mouseY < 440) // if u click on the text " save and exit", setting closes
    {
      rectMode(CORNER);
      fill(0, 0);
      rect(295, 425, 100, 20);
      if (mousePressed)
      {
        setting = false;
      }
    }
  }
}

void game()
{
  if(settingIngame == false)
  {
    rectMode(CORNER);
    background();
    score();
    snake();
    eye();
    food();
    dead();
    if(x.size() == 480)
    {
      win = true;
    }
    if(win)
    {
      speed = new PVector(0, 0);
      textAlign(CENTER);
      textSize(50);
      fill(0);
      text("YOU WIN", wR/2, hR/2);
      winSound.play();
    }
    else if(lose)
    {
      gameOver();
    }
  }
  else // pauses the game and allows access to the setting while it is on pause
  {
    rectMode(CORNER); // this rect hide the excess text ( "setting " is writen a lot of time, I guess it’s the same problem but I only understand now)
    noStroke();
    fill(255);
    rect(300,0, 200,45);
    setting(); // start the setting again
  }
}

```

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 13, 2020, 12:13pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-the-menu-of-my-game/21826/2 "2020-06-13T12:13:16Z")

</div>

1/2 a gig for this file…

---

<div class="post-metadata">

**Author:** ![OohYuma](https://avatars.discourse-cdn.com/v4/letter/o/96bed5/32.png) [@OohYuma](https://discourse.processing.org/u/OohYuma)\
**Post date:** [June 13, 2020, 4:16pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-the-menu-of-my-game/21826/3 "2020-06-13T16:16:08Z")

</div>

yes sorry, it’s because there’s music in the code

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 13, 2020, 4:18pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-the-menu-of-my-game/21826/4 "2020-06-13T16:18:38Z")

</div>

what library are you using for the gui?

---

<div class="post-metadata">

**Author:** ![OohYuma](https://avatars.discourse-cdn.com/v4/letter/o/96bed5/32.png) [@OohYuma](https://discourse.processing.org/u/OohYuma)\
**Post date:** [June 13, 2020, 4:33pm UTC](https://discourse.processing.org/t/i-have-a-problem-with-the-menu-of-my-game/21826/5 "2020-06-13T16:33:24Z")

</div>

I don’t use a library for that, just that line of code :  
import static javax.swing.JOptionPane.\*;

---

<div class="post-metadata">

**Author:** ![OohYuma](https://avatars.discourse-cdn.com/v4/letter/o/96bed5/32.png) [@OohYuma](https://discourse.processing.org/u/OohYuma)\
**Post date:** [June 14, 2020, 9:29am UTC](https://discourse.processing.org/t/i-have-a-problem-with-the-menu-of-my-game/21826/6 "2020-06-14T09:29:29Z")

</div>

I found the problem, my setting menu do that because he is always called, I just need to use a background(255) when I call setting()
