xxxxxxxxxx
let notes = [];
let colorlist = ['rgb(84,233,229)', 'rgb(252,252,25)', 'red'];
let rhythm = [ [1, 3], [1, 4], [1, 3, 4]];
let longlength = [1, 2, 3, 4];
let ltor = [1, 1, 2, 3, 4, 4, 3, 2, 1, 1]
let x = 0;
let y = 0;
let i, j, k = 0;
function setup() {
createCanvas(1240, 500);
background('rgb(14,10,58)');
}
function drawlines(){
stroke(255);
strokeWeight(5);
line(40, 100, 1200, 100);
line(40, 400, 1200, 400);
}
function drawrects(){
fill('rgb(14,10,58)');
strokeWeight(0);
rect(0, 0, 1500, 100);
rect(0, 402, 1500, 100);
}
function draw() {
background('rgb(14,10,58)')
drawlines();
drawrects();
for(i = 0; i < 10; i++){
let notea;
if(ltor[i] == 1){
notea ={
x : 40,
y : 0,
width : 80,
color : colorlist[0],
height : 50,
rhythm : [1],
speed : 10,
};
notea.height *= random(1,4);
// notea.x += i * 120;
// notes.push(notea);
}else if(ltor[i] == 2){
notea = {
x : 40,
y : 0,
width : 80,
color : colorlist[0],
height : 20,
rhythm : [],
speed : random(3, 5),
};
notea.rhythm = random(rhythm);
// notea.x += i * 120;
// notes.push(notea);
}else if(ltor[i] == 3){
notea = {
x : 40,
y : 0,
width : 80,
color : colorlist[1],
height : 5,
rhythm : [],
speed : random(8, 10),
};
notea.rhythm = random(rhythm);
// notea.x += i * 120;
// notes.push(notea);
}else if(ltor[i] == 4){
notea = {
x : 40,
y : 0,
width : 80,
color : colorlist[2],
height : 10,
rhythm : [],
speed : random(5, 7),
};
notea.rhythm = [1, 2, 3, 4];
// notea.x += i * 120;
// for(k = 0; k < notea.rhythm.length; k++){
// notea.y -= 10 * notea.height * k;
// notes.push(notea);
// }
// notes.push(notea);
}
notea.x += i * 120;
notes.push(notea);
}
drawrects();
for(let j = 0; j < 10; j++){
drawrects();
let note = notes[j];
note.y += note.speed;
if (note.y > 500){
drawrects();
note.y = 100 - note.height;
}
drawrects();
fill(note.color);
stroke(5);
rect(note.x, note.y, note.width, note.height);
drawrects();
}
}