xxxxxxxxxx
94
let person;
let input;
let timer;
let change;
let b1P = false;
let b2P = false;
let b3P = false;
//Preload Font, Images, Sounds
function preload() {
person = loadImage("personIcon.png");
}
function setup() {
createCanvas(800, 600);
background(100);
let button = createButton('Happy');
button.size(150, 100);
button.position(100, 250);
button.style("font-size", "42px");
button.mousePressed(recolorH);
let button2 = createButton('Sad');
button2.size(150, 100);
button2.position(300, 250);
button2.style("font-size", "42px");
button2.mousePressed(recolorS);
let button3 = createButton('Angry');
button3.size(150, 100);
button3.position(500, 250);
button3.style("font-size", "42px");
button3.mousePressed(recolorA);
input = createInput('');
input.position(330, 110);
input.size(100, 50);
input.style("font-size", "30px");
input.input(reset);
}
function draw() {
textSize(40);
text("Hello. Welcome to Mindscape", 120, 80);
text("Heart Rate:", 100, 150);
text("BPM", 450, 150);
text("Today I feel:", 150, 220);
image(person, 300, 400, 200, 200);
if (millis() > change) {
if (b1P == true) {
recolorH();
}
else if (b2P == true) {
recolorS();
}
else if (b3P == true) {
recolorA();
}
change = millis() + timer;
}
}
function reset() {
timer = (60000/input.value());
change = timer;
print(timer);
}
function recolorH() {
let r = random(190, 255);
let g = random(190, 255);
let b = 0;
background(r, g, 0);
b1P = true;
b2P = false;
b3P = false;
}
function recolorS() {
let r = random(0, 100);
let g = random(0, 100);
let b = 0;
background(r, g, 255);
b1P = false;
b2P = true;
b3P = false;
}
function recolorA() {
let r = 0;
let g = random(0, 90);
let b = random(0, 90);
background(255, g, b);
b1P = false;
b2P = false;
b3P = true;
}