xxxxxxxxxx
143
let background;
let input;
let timer;
let change;
let r;
let g;
let b;
let i = 0;
let totalA = 0;
let b1P = false;
let b2P = false;
let b3P = false;
//Preload Font, Images, Sounds
function preload() {
bgImage = loadImage("WindowsBG.jpeg");
}
//Create Array for Apple
let apple = [];
//Create Class for Apple
class Apple{
constructor(){
this.xPos = random(300, 450);
this.rxPos = this.xPos - 1;
this.yPos = random(130, 280);
this.ryPos = this.yPos - 20
if (b1P == true) {
this.r = random(190, 255);
this.g = random(190, 255);
this.b = 0;
}
else if (b2P == true) {
this.r = random(0, 100);
this.g = random(0, 100);
this.b = 255;
}
else if (b3P == true) {
this.r = 255;
this.g = random(0, 90);
this.b = random(0, 90);
}
}
//Function for Drawing Apple
draw(){
fill(this.r, this.g, this.b);
print(this.r, this.g, this.b);
ellipse(this.xPos, this.yPos, 30, 30);
fill('black');
rect(this.rxPos, this.ryPos, 3, 10);
}
}
function setup() {
createCanvas(700, 500);
image(bgImage, 0, 0, 700, 700);
let button = createButton('Happy');
button.size(120, 60);
button.position(30, 120);
button.style("font-size", "25px");
button.mousePressed(b1Pressed);
let button2 = createButton('Sad');
button2.size(120, 60);
button2.position(100, 200);
button2.style("font-size", "25px");
button2.mousePressed(b2Pressed);
let button3 = createButton('Angry');
button3.size(120, 60);
button3.position(60, 280);
button3.style("font-size", "25px");
button3.mousePressed(b3Pressed);
}
function draw() {
textSize(20);
fill('black')
text("Hello. Welcome to our Mindscape.", 30, 70);
text("How might you be feeling today?", 10, 100);
strokeWeight(0);
fill(120, 70, 50);
rect(350, 420, 50, -150);
fill(35, 100, 35);
ellipse(330, 250, 120, 120);
ellipse(420, 250, 120, 120);
ellipse(375, 180, 120, 120);
ellipse(440, 180, 120, 120);
ellipse(310, 180, 120, 120);
ellipse(375, 120, 120, 120);
fill(120, 70, 50);
for (let i = 0; i < totalA; i++)
apple[i].draw();
}
function b1Pressed() {
r = random(190, 255);
g = random(190, 255);
b = 0;
b1P = true;
b2P = false;
b3P = false;
apple[i] = new Apple();
totalA = totalA + 1;
i = i + 1;
print(i);
}
function b2Pressed() {
r = random(0, 100);
g = random(0, 100);
b = 255;
b1P = false;
b2P = true;
b3P = false;
apple[i] = new Apple();
totalA = totalA + 1;
i = i + 1;
print(i);
}
function b3Pressed() {
r = 255;
g = random(0, 90);
b = random(0, 90);
b1P = false;
b2P = false;
b3P = true;
apple[i] = new Apple();
totalA = totalA + 1;
i = i + 1;
print(i);
}
/*
function appleDraw() {
fill(r, g, b);
print(r, g, b);
ellipse(350, 160, 30, 30);
fill('black');
rect(349, 140, 3, 10);
}
*/