xxxxxxxxxx
44
let g, r, thickness;
let sound;
let mapRate;
function preload() {
sound = loadSound('sounds/wrong.wav');
}
function setup() {
createCanvas(400, 400);
r = 0;
g = 0;
thinkness = 10;
print("bring the mouse over the screen and a green bar will appear. move the mouse to control the green bar. if the bar is balanced, it will turn green, else it will turn red and you will hear annoying buzzer. can you bring the bar down to the blue region without playing the buzzer even once????");
print("bring the mouse over the to blue region if you want the sound to stop");
}
function draw() {
background(220);
fill(0);
// text("bring the mouse over the screen and a green bar will appear. move the mouse to control the green bar. if the bar is balanced, it will turn green, else it will turn red and you will hear annoying buzzer. can you bring the bar down to the blue region without playing the buzzer even once????", 10, 10);
text("bring the mouse over here if you want the sound to stop", 50,height-8);
noStroke();
fill(0,255,255,80);
rect(0,380,width,height);
strokeWeight(thickness);
stroke(r,g,0);
line(0,mouseX,width, mouseY);
if (mouseY<380) {
if(abs(mouseX-mouseY)<5) {
r = 0;
g = 255;
} else {
strokeWeight(1+random(0.5,-0.5));
stroke(255,0,0,40);
line(0,0,width,height);
r = 255;
g = 0;
thickness = 10+random(-1,4);
sound.play();
}
}
}