# Working on a Simon says game

**URL:** https://discourse.processing.org/t/working-on-a-simon-says-game/43955
**Category:** Beginners
**Created:** [February 20, 2024, 9:36am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955 "2024-02-20T09:36:12Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![cattclawzz](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@cattclawzz](https://discourse.processing.org/u/cattclawzz)
#### Post date: [February 20, 2024, 9:36am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955/1 "2024-02-20T09:36:12Z")

</div>

having issues with line 27 and 28, I’m not sure how to properly write that line  
\<//r,b,g,y  
boolean colours = {false,false,false,false};  
color coloursTrue = {color(255, 0, 0) , color(0,0,255) , color(0,255,0) , color(255,255,0)};  
color coloursFalse = {color(100, 0, 0) , color(0,0,100) , color(0,100,0) , color(100,100,0)};  
ArrayList pattern = new ArrayList();

void setup(){  
size(600,600);  
background(200);  
}

void draw(){  
fill(100); ellipse(300,300,500,500);

if (colours[0]){fill(coloursTrue[0]);} else {fill(coloursFalse[0]);} arc(300, 300, 500, 500, -PI, -HALF\_PI);  
if (colours[1]){fill(coloursTrue[0]);} else {fill(coloursFalse[1]);} arc(300, 300, 500, 500, -HALF\_PI, 0);  
if (colours[2]){fill(coloursTrue[0]);} else {fill(coloursFalse[2]);} arc(300, 300, 500, 500, 0, HALF\_PI);  
if (colours[3]){fill(coloursTrue[0]);} else {fill(coloursFalse[3]);} arc(300, 300, 500, 500, HALF\_PI, PI);

line(50,300,550,300);  
line(300,50,300,550);  
}

void showPattern () {  
pattern.add((int)random(0, 4));

for (int i = 0; i \< size(pattern); i++) {  
colours[pattern.get(i)] = true;  
}  
}\>

---

<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: [February 20, 2024, 10:07am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955/2 "2024-02-20T10:07:39Z")

</div>

here is my version

it’s rgb by the way

press any key to change pattern

I don’t know the game so I don’t know what is supposed to happen

```auto
//r,g,b

boolean[] colours = {false, false, false, false};
color[] coloursTrue = {color(255, 0, 0), color(0, 0, 255), color(0, 255, 0), color(255, 255, 0)};
color[] coloursFalse = {color(100, 0, 0), color(0, 0, 100), color(0, 100, 0), color(100, 100, 0)};
ArrayList<Boolean> pattern = new ArrayList();

void setup() {
  size(600, 600);
  background(200);
}

void draw() {
  fill(100);
  ellipse(300, 300, 500, 500);

  // ----------------------------------------------
  // show 4 arcs
  if (colours[0]) {
    fill(coloursTrue[0]);
  } else {
    fill(coloursFalse[0]);
  }
  arc(300, 300, 500, 500, -PI, -HALF_PI);

  if (colours[1]) {
    fill(coloursTrue[0]);
  } else {
    fill(coloursFalse[1]);
  }
  arc(300, 300, 500, 500, -HALF_PI, 0);

  if (colours[2]) {
    fill(coloursTrue[0]);
  } else {
    fill(coloursFalse[2]);
  }
  arc(300, 300, 500, 500, 0, HALF_PI);

  if (colours[3]) {
    fill(coloursTrue[0]);
  } else {
    fill(coloursFalse[3]);
  }
  arc(300, 300, 500, 500, HALF_PI, PI);

  // ---------------------------------------------------
  line(50, 300, 550, 300);
  line(300, 50, 300, 550);
}

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

void keyPressed() {
  showPattern();
}

void showPattern() {
  // RESET
  pattern.clear();

  // fill
  for (int i = 0; i < 4; i++) {
    if (random(1)>0.5)
      pattern.add(true);
    else pattern.add(false);
  }

  // copy pattern to board
  for (int i = 0; i < pattern.size(); i++) {
    colours[i] = pattern.get(i);
  }
}
// ---

```

---

<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: [February 20, 2024, 10:09am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955/3 "2024-02-20T10:09:33Z")

</div>

well, you have lots of typos in the draw() function in the if-clause

```auto
  if (colours[1]) {
    fill(coloursTrue[0]);

```

your “0” must be `[1]`

error occurs 3 times

looks much better now…

---

<div class="post-metadata">

### Author: ![cattclawzz](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@cattclawzz](https://discourse.processing.org/u/cattclawzz)
#### Post date: [February 20, 2024, 10:16am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955/4 "2024-02-20T10:16:43Z")

</div>

I’m incredibly confused on what this is tryna do, it lights up some of the buttons red?

Simon (googling the game it’s just called Simon, i always called it Simon says, whoops) is a memory game where the board will show a pattern of colours, and then you have to repeat it back by pressing the buttons, and it increases by 1 every time, that explanation isn’t great but its the best I can do

also I just realized i formatted the code wrong, apologies, I’m new

the little note at the start was just for me to remember what order the 4 colours are in on the lists, i do know its rgb thats just sorta the order

---

<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: [February 20, 2024, 10:20am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955/5 "2024-02-20T10:20:59Z")

</div>

> [@cattclawzz](#):
>
> I’m incredibly confused on what this is tryna do, it lights up some of the buttons red?

as I said that is because of your typo in draw()

correct the 3 typos and it’s much better.

As I said I don’t know the game, you can change the code in `showPattern()`.  
Is one or more field enlightened?

---

<div class="post-metadata">

### Author: ![cattclawzz](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@cattclawzz](https://discourse.processing.org/u/cattclawzz)
#### Post date: [February 20, 2024, 10:23am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955/6 "2024-02-20T10:23:15Z")

</div>

could you explain what the typo is in different words? (really sorry, I’m slow)

---

<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: [February 20, 2024, 10:25am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955/7 "2024-02-20T10:25:01Z")

</div>

> [@cattclawzz](#):
>
> if (colours[1]){fill(coloursTrue[0]);} else {fill(coloursFalse[1]);} arc(300, 300, 500, 500, -HALF\_PI, 0);

in this line you have 3 arrays which are parallel

**Suggestion:**

you need to use “1” in all places (in this line), but you have “0” in the 2nd array

**Correction:**

```
                                1

```

`if (colours[1]){fill(coloursTrue[1]);} else {fill(coloursFalse[1]);} arc(300, 300, 500, 500, -HALF_PI, 0);`

**Remark**

This also applies for the other 3 lines

indexes for the arrays must be

```auto

0 0 0
1 1 1 
2 2 2
3 3 3

```

---

<div class="post-metadata">

### Author: ![cattclawzz](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@cattclawzz](https://discourse.processing.org/u/cattclawzz)
#### Post date: [February 20, 2024, 10:26am UTC](https://discourse.processing.org/t/working-on-a-simon-says-game/43955/8 "2024-02-20T10:26:44Z")

</div>

ahhh, i see that now, thanks!
