-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (27 loc) · 679 Bytes
/
script.js
File metadata and controls
34 lines (27 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
let gravity;
let fireworks = [];
let darkness = 2;
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
gravity = createVector(0, 0.05);
}
function draw() {
background(0, 0, 0, 25);
if (random() < 0.01) {
let x = random(width);
fireworks.push(new Firework(x));
}
for (let i = fireworks.length - 1; i >= 0; i--) {
const firework = fireworks[i];
if (firework.done)
fireworks.splice(i, 1);
firework.update();
firework.show();
}
if (fireworks.length == 0) {
background(0, 0, 0, darkness);
darkness += 2;
} else
darkness = 2;
}