2.2

https://editor.p5js.org/nicepelican061/full/XtAxDKhub

// light switch game

var light1; // true or false
var light2; // is het woensdag EN het regent
var light3;
var light4;
var light5;
var light6; 
var song;
var imagewin;

var button1;
var button2;
var button3;
var button4;
var button5;
var button6;
var button9;


var grey1;
var grey2;
var yellow;

var gameWon = false;

// key 1,2,3 is for button 1,2,3


function setup() {
  createCanvas(1000, 500);
  light1 = false;
  light2 = false;
  light3 = false;
  light4 = false;
  light5 = false;
  light6 = false;
  song = loadSound("Good Job! sound effect #NOCOPYRIGHT.mp3")
  imagewin = loadImage("goodjob.png")
  button1 = false;
  button2 = false;
  button3 = false;
  button4 = false;
  button5 = false;
  button6 = false;
  button9 = false;
 
  yellow = color(255, 255, 0);
  grey1 = 250;
  grey2 = 220;
}

function draw() {
  background(220);

  
  makelight(light1, 1);
  makelight(light2, 2);
  makelight(light3, 3);
  makelight(light4, 4);
  makelight(light5, 5);
  makelight(light6,6);
  if (isKeyPressed) {
    checkbuttons();
  }
  // change this in your uber duper shizzle
 
  light5 = button3;
  light1 = button2;
  light2 = button1;
  light6 = button6;
  light3 = button5;
  light4 = button4;
 
}

function checkbuttons() {
  switch (key) {
    case "1":
      button1 = !button1;
      button2 = false
      break;
    case "2":
      button2 = !button2;
      button5 = false
      break;
    case "3":
      button3 = !button3;
      button1= false
      break;
    default:
      break;
      case "4":
      button4 = !button4;
      button5 = false
      break;
      case "5":
      button5 = !button5;
      button6 = false
      break;
      case "6":
      button6 = !button6;
      break;

  }
}

function makelight(myLight, myNumber) {
  // fill(grey1);
  switch (myNumber) {
    case 1:
      if (light1) {
        fill(yellow);
      } else {
        fill(grey2);
      }
      rect(10, 10, 100, 100);
      break;
    case 2:
      if (light2) {
        fill(yellow);
      } else {
        fill(grey2);
      }
      rect(200, 10, 100, 100);
      break;
    case 3:
      if (light3) {
        fill(yellow);
      } else {
        fill(grey2);
      }
      rect(10, 210, 100, 100);
      break;
    case 4:
    if (light4) {
      fill(yellow);
    } else {
      fill(grey2)
    }
     rect(200,210,100,100)
    break;
    case 5:
      if (light5) {
      fill(yellow);
      } else {
        fill(grey2)
      }
      rect(400,10,100,100)
      break;
     
      case 6:
      if (light6){
        fill(yellow);
      } else{
        fill(grey2)
      }
      rect(400,210,100,100)
      }
  
  if(light1 == true && light2 == true && light3 == true && light4 == true && light5 == true && light6 ==true){
    fill('black')
    textSize(50)
    text('you won', 200,200);
    image(imagewin, width/200, height/200);
    if(gameWon === false) {
      song.play();
      gameWon = true;
    }
    
  }

}



//juiste volgorde = 4,3,1,2,5,6