-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
50 lines (40 loc) · 1.1 KB
/
script.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//Snow
let gravity;
let snow = [];
let spritesheet,
textures = [];
let zOff = 0;
function preload() {
spritesheet = loadImage('https://alca.tv/static/f32.png');
}
function setup() {
createCanvas(windowWidth, windowHeight);
gravity = createVector(0, 0.0005);
for (let x = 0; x < spritesheet.width; x += 32) {
for (let y = 0; y < spritesheet.height; y += 32) {
let img = spritesheet.get(x, y, 32, 32);
textures.push(img);
}
}
for (let i = 0; i < 200; i++) {
let x = random(width),
y = random(height);
snow.push(new Snowflake(x, y));
}
frameRate(50);
}
function draw() {
background(0);
zOff += 0.1;
for (let flake of snow) {
let xOff = flake.pos.x / width;
let yOff = flake.pos.y / height;
let wAngle = noise(xOff, yOff, zOff) * TWO_PI;
let wind = p5.Vector.fromAngle(wAngle);
wind.mult(0);
flake.applyForce(gravity);
flake.applyForce(wind);
flake.update();
flake.show();
}
}