xxxxxxxxxx
115
let song;
let amp;
let volhistory = [];
let bY, bX;
let bunny;
let bunnyX;
let bunnyY;
let a = 0;
let b = 0;
let skiSpeed = 1;
let bunnycolor = 250;
var snows = [];
function preload() {
song = loadSound("1.mp3");
}
function setup() {
createCanvas(windowWidth, windowHeight);
song.play();
amp = new p5.Amplitude();
for (var i = 0; i < 100; i++) {
snows[i] = new Snow();
}
}
function draw() {
//night
//background("#023047");
//day
background("lightblue");
for (var j = 0; j < snows.length; j++) {
snows[j].fall();
snows[j].show();
}
bunny = new Bunny();
var vol = amp.getLevel();
volhistory.push(vol);
// stroke(255);
// noFill();
for (var i = 0; i < volhistory.length; i++) {
var y = map(volhistory[i], 0, 0.5, height, 30);
stroke(255);
let sum =
volhistory[i] +
volhistory[i - 1] +
volhistory[i - 2] +
volhistory[i - 3] +
volhistory[i - 4] +
volhistory[i - 5] +
volhistory[i - 6] +
volhistory[i - 7] +
volhistory[i - 8] +
volhistory[i - 9] +
volhistory[i - 10] +
volhistory[i - 11] +
volhistory[i - 12] +
volhistory[i - 13] +
volhistory[i - 14] +
volhistory[i - 15] +
volhistory[i - 16] +
volhistory[i - 17] +
volhistory[i - 18] +
volhistory[i - 19];
let psum =
volhistory[i - 3] +
volhistory[i - 4] +
volhistory[i - 5] +
volhistory[i - 6] +
volhistory[i - 7] +
volhistory[i - 8] +
volhistory[i - 9] +
volhistory[i - 10] +
volhistory[i - 11] +
volhistory[i - 12] +
volhistory[i - 13] +
volhistory[i - 14] +
volhistory[i - 15] +
volhistory[i - 16] +
volhistory[i - 17] +
volhistory[i - 18] +
volhistory[i - 19] +
volhistory[i - 20] +
volhistory[i - 21] +
volhistory[i - 22];
let avg = sum / 20;
let by = map(avg, 0, 0.5, height / 2 + 130, 100);
let pavg = psum / 20;
let pby = map(pavg, 0, 0.5, height / 2 + 130, 100);
bunnyX = i - 25;
bunnyY = pby - 25;
// stroke(random(150,255),random(150,255),random(150,255));
// rect(i-22, pby, 1, 1);
rect(i - 22, pby, 1, height - pby);
a = atan2(by - pby, 1) / 3;
}
if (volhistory.length > width - 100) volhistory.splice(0, 1);
bunny.show();
}