xxxxxxxxxx
57
let paperPlanes = [];
function mousePressed() {
for (let i = 0; i < 15; i++) {
let p = new Planes(mouseX, mouseY, 10);
paperPlanes.push(p);
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB); //alpha is between 0 - 1, floating number
}
function draw() {
background(0);
noFill();
stroke(0, 0, 100);
text("<", 70, 80);
text(">", 140, 80);
rect(50, 50, 50);
rect(120, 50, 50);
for (let p of paperPlanes) {
p.show();
p.update();
p.edge();
/* interactive keys */
if (keyIsDown(LEFT_ARROW)) {
p.a -= 0.03;
p.update();
fill(0, 0, 100);
rect(50, 50, 50);
stroke(0, 0, 0);
text("<", 70, 80);
} else if (keyIsDown(RIGHT_ARROW)) {
p.a += 0.03;
p.update();
fill(0, 0, 100);
rect(120, 50, 50);
stroke(0, 0, 0);
text(">", 140, 80);
} else if (keyIsDown(UP_ARROW)) {
p.vel += 0.03;
p.update();
}
}
for(let i = paperPlanes.length -1; i >= 0; i--){
if(paperPlanes[i].remove()){
paperPlanes.splice(i, 1);
}
}
}