title: How to make a front page of a game in processing?
body: <p>I am trying to program a game for an assignment. I have the guts of it done, but I need something at the beginning to say the rules etc. </p>
  
  <p>In order to do this, I have used the 'if' statement so it checks when the space bar is pressed and thus starts the game. However, when another key is pressed it just goes back to the starting page. </p>
  
  <p>Is there a way to stop this?</p>
  
  <p>This is my code:</p>
  
  <pre><code>int direction = 1;
  float points = 0;
  float speed = 1;
  float distance;
  
  PImage bg;
  //https://opengameart.org/sites/default/files/Preview-Cave-Parallax.png
  
  goal[] goals = new goal[10];
  goal[] level2 = new goal[15];
  
  
  
  player p;
  void setup() {
      bg = loadImage("bg.png");
      size(800,800);
      background(bg);
      smooth();
      noStroke();
  
      goals[0] = new goal(40, 100, 60, 1, -1);
      goals[1] = new goal(60, 200, 40, 2, 1);
      goals[2] = new goal(50, 200, 30, 4, -1);
      goals[3] = new goal(16, 250, 30, 3, 1);
      goals[4] = new goal(30, 300, 50, 1.5, -1);
      goals[5] = new goal(40, 350, 60, 5, -1);
      goals[6] = new goal(60, 400, 40, 2, 1);
      goals[7] = new goal(50, 450, 30, 2.5, -1);
      goals[8] = new goal(16, 500, 30, 3, 1);
      goals[9] = new goal(30, 550, 50, 2, -1);
  
      level2[0] = new goal(40, 100, 60, 1, -1);
  
      p = new player();
  }
  
  void draw() {
  
      //The starting page
  
      background(bg);
      fill(0);
      rect(0, 325, 800, 340);
      fill(255);
      textAlign(CENTER, CENTER);
      textSize(50);
      text("Welcome", 400, 350);
      textSize(30);
      text("Rules: Don't let the red balls touch you!", 400, 450);
      text("Controls: Use arrows to move to the left or right.", 400, 500);
      text("Press Space to start.", 400, 550);
  
  
  
      //The Game
  
      if(key == ' '){
           background(bg);
          fill(255);
          textSize(30);
          text("Score:", 50, 50);
          text(points, 140, 50);
          p.show();
          p.move();
          for(int i =0; i&lt;10; i++){
              if (i%2 == 0){
                  goals[i].show();
                  goals[i].move();
              }
          }
  
          if(points &gt;= 2){
              for(int i = 0; i&lt;10; i++){
                  if(i%3 == 0){
                      goals[i].show();
                      goals[i].move();
                  }
              }
          }
  
          if(points &gt;= 3) {
              for(int i = 0; i&lt;10; i++){
                  goals[i].show();
                  goals[i].move();
              }
          }
  
          for(int i = 0; i&lt;10; i++){
              distance = dist((p.x), (p.y), (goals[i].x), (goals[i].y));
              if(distance &lt;=(15+goals[i].w/2)){
  
                  background(0);
                  fill(255);
                  textSize(50);
                  textAlign(CENTER, CENTER);
                  text("GAME OVER", 400, 400);
                  noLoop();
              }
          }
  
          if(p.y == 15 || p.y == 785){
              points = points + 0.5;
              fill(255);
              textSize(30);
              text(points, 140, 50);
  
          }
      }
      //else {
  
      // }
  }
  
  class goal {
      float x;
      float y;
      float w;
      float c;
      float speed;
      float direction;
      goal(float xpos, float ypos, float wd, float sp,  float dr) {
          x = xpos;
          y = ypos;
          w = wd;
          speed = sp;
          direction = dr;  
      }
  
      void show() {
          fill(255,0,0);
          ellipse(x,y,w,w);
      }
      void move() {
          x = x + (speed * direction);
          if ((x &gt; 800-w/2) || (x &lt;w/2)) {
              direction = direction * -1;
          } 
      }
  }
  
  class player {
      float x = 400;
      float y = 750;
      float speed = 1;
      int direction = 1;
      void show() {
          fill(255);
          ellipse(x, y, 30, 30);
      }
      void move() {
          y = y +(speed * direction);
          if ((y&gt;785)||(y&lt;15)){
              direction = direction*-1;
          }
  
  
          if (key == CODED){
  
              if (keyCode == LEFT){
                  if (x &gt;15){
                      x--;
                  }
              }
              else if (keyCode == RIGHT){
                  if (x &lt;785){
                      x++;
                  }
              } 
          }
      }
  }
  </code></pre>
  
  <p>I am new to this so I'm not really sure as to do. </p>