xxxxxxxxxx
149
let counter = 0;
let imgs2;
let tf = [
false,
false,
true,
true,
false,
true,
true,
false,
false,
false,
true,
false,
false,
true,
true,
false,
true,
false,
true,
true,
];
function preload() {
img1 = loadImage("fake2.png");
img2 = loadImage("fake4.png");
img3 = loadImage("real7.png");
img4 = loadImage("real8.png");
img5 = loadImage("fake10.png");
img6 = loadImage("real9.png");
img7 = loadImage("real10.png");
img8 = loadImage("fake6.png");
img9 = loadImage("fake1.png");
img10 = loadImage("fake8.png");
img11 = loadImage("real2.png");
img12 = loadImage("fake3.png");
img13 = loadImage("fake5.png");
img14 = loadImage("real1.png");
img15 = loadImage("real3.png");
img16 = loadImage("fake7.png");
img17 = loadImage("real6.png");
img18 = loadImage("fake9.png");
img19 = loadImage("real4.png");
img20 = loadImage("real5.png");
imgs2 = [
img1,
img2,
img3,
img4,
img5,
img6,
img7,
img8,
img9,
img10,
img11,
img12,
img13,
img14,
img15,
img16,
img17,
img18,
img19,
img20,
];
}
function setup() {
createCanvas(400, 400);
background(200);
buttonStart = createButton("start the game");
buttonStart.position(150, 195);
buttonStart.mousePressed(createButtons);
textAlign(CENTER);
textSize(30);
text("guess who is", width / 2, 70);
text("REAL or FAKE", width / 2, 120);
}
function createButtons() {
fill(150);
noStroke();
rect(0, 0, 400, 400);
buttonTrue = createButton("real");
buttonTrue.position(130, 350);
buttonFalse = createButton("fake");
buttonFalse.position(230, 350);
buttonStart.hide();
image(img1, 75, 25);
buttonTrue.mousePressed(tButton);
buttonFalse.mousePressed(fButton);
}
function tButton() {
if (tf[counter]) {
fill("green");
} else {
fill("red");
}
rect(0, 0, 400, 300);
counter++;
if (counter >= 20) {
fill(255);
rect(0, 0, 400, 400);
textAlign(CENTER);
textSize(30);
text("thanks for playing", width / 2, 70);
buttonTrue.hide();
buttonFalse.hide();
} else {
image(imgs2[counter], 75, 25);
console.log(counter);
}
}
function fButton() {
if (tf[counter]) {
fill("red");
} else {
fill("green");
}
rect(0, 0, 400, 300);
counter++;
if (counter >= 20) {
fill(255);
rect(0, 0, 400, 400);
textAlign(CENTER);
textSize(30);
text("thanks for playing", width / 2, 70);
buttonTrue.hide();
buttonFalse.hide();
} else {
image(imgs2[counter], 75, 25);
console.log(counter);
}
}
function draw() {}