# I am confused on why my code won't work

**URL:** <https://discourse.processing.org/t/i-am-confused-on-why-my-code-wont-work/15648>\
**Category:** Coding Questions\
**Created:** [November 19, 2019, 10:40pm UTC](https://discourse.processing.org/t/i-am-confused-on-why-my-code-wont-work/15648 "2019-11-19T22:40:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Silly\_bois](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@Silly\_bois](https://discourse.processing.org/u/Silly_bois)\
**Post date:** [November 19, 2019, 10:40pm UTC](https://discourse.processing.org/t/i-am-confused-on-why-my-code-wont-work/15648/1 "2019-11-19T22:40:37Z")

</div>

```auto
int mode = 0;
int INTRO = 0;
int levelone = 1;
int GAME_OVER = 2;
int fontcolor;
float speed = 3;

void setup () {
  background(0);
  size(1440, 900);
  fontcolor = color( 0, 225, 149);
}

void draw () {
  if (mode == INTRO) {
    doINTROmode();
  } else if (mode == levelone) {
    dolevelone();
  } else if (mode == GAME_OVER) {
    doGAME_OVER();
  }
} //Void DRAW!!!!

public void doINTROmode () {
  textSize(90);
  fill(fontcolor);
  text("Welcome!Press Space to start", 100, 450);
  if (keyPressed) {
    if (key == 'd') {
      INTRO = INTRO + 1;
    }
  }
}

public void dolevelone () {
  background(0, 34, 93);
}

public void doGAME_OVER () {
  textSize(90);
  fill(fontcolor);
  text("Game Over!!!", 100, 450);
}

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 19, 2019, 11:02pm UTC](https://discourse.processing.org/t/i-am-confused-on-why-my-code-wont-work/15648/2 "2019-11-19T23:02:49Z")

</div>

> [@Silly\_bois](#):
>
> INTRO = INTRO + 1;

Instead try mode=levelone;

Welcome to the forum!

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 20, 2019, 1:09pm UTC](https://discourse.processing.org/t/i-am-confused-on-why-my-code-wont-work/15648/3 "2019-11-20T13:09:52Z")

</div>

In this example you have to press Space Bar, not “d”

I use the keyword “`final`” to make some variables (the names of the modes) _constants_

Chrisir

```auto

// current mode 
int mode = 0;
// modes (constants - keyword final)
final int INTRO = 0;
final int levelone = 1;
final int GAME_OVER = 2;

// other 
int fontcolor;
float speed = 3;

void setup () {
  background(0);
  size(1440, 900);
  fontcolor = color( 0, 225, 149);
}//function setup()

void draw () {
  if (mode == INTRO) {
    doINTROmode();
  } else if (mode == levelone) {
    dolevelone();
  } else if (mode == GAME_OVER) {
    doGAME_OVER();
  }
} //function draw()

// ------------------------------------------------------

public void doINTROmode () {
  textSize(90);
  fill(fontcolor);
  text("Welcome!\nPress Space to start", 
    100, 450);
  if (keyPressed) {
    if (key == ' ') {
      mode=levelone; //INTRO = INTRO + 1;
    }
  }
}

public void dolevelone () {
  background(0, 34, 93);
}

public void doGAME_OVER () {
  textSize(90);
  fill(fontcolor);
  text("Game Over!!!", 100, 450);
}
//

```
