xxxxxxxxxx
80
let i = 0;
let totalT = 0;
let bP = false;
let song;
let splash;
//Preload Font, Images, Sounds
function preload() {
wellImg = loadImage("OoTWell.jpg");
song = loadSound("SoH.mp3");
splash = loadSound("splash.mp3");
}
function setup() {
createCanvas(600, 470);
background(0);
image(wellImg, 0, 0, 600, 360);
let butCol = color('gray');
let textCol = color('white');
let button = createButton('Let Go');
button.style('background-color', butCol);
button.style('color', textCol);
button.size(120, 90);
button.position(470, 370);
button.style("font-size", "25px");
button.mousePressed(bPressed);
textSize(22);
fill('lightgray')
text("Welcome to Mindwell.", 10, 390);
text("Keep your mind well and drop a thought here.", 12, 420);
text("Negative, positive - it shall all pass.", 12, 450);
song.loop();
}
//Create Array for Thought
let thought = [];
//Create Class for Thought
class Thought{
constructor(){
this.xPos = random(240, 330);
this.yPos = random(140, 230);
this.tSize = 30;
this.tRound = 15;
this.splash = false;
if (bP == true) {
this.r = random(0, 255);
this.g = random(0, 255);
this.b = random(0, 255);
}
}
//Function for Drawing Thought
draw(){
fill(this.r, this.g, this.b);
// print(this.r, this.g, this.b);
rect(this.xPos, this.yPos, this.tSize, this.tSize, this.tRound);
if (this.tSize > 0)
this.tSize = this.tSize - 0.3;
}
}
function draw() {
for (let i = 0; i < totalT; i++){
if (thought[i].tSize > 0){
thought[i].draw();
}
else if (thought[i].splash == false){
splash.play();
thought[i].splash = true;
}
}
}
function bPressed() {
bP = true;
thought[i] = new Thought();
totalT = totalT + 1;
i = i + 1;
// print(i);
}