-
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathparticle.js
48 lines (40 loc) · 976 Bytes
/
particle.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
// Creating particles using Particle Component
kaplay();
loadSprite("star", "./examples/sprites/particle_star_filled.png");
onLoad(() => {
go("game");
});
function woah() {
const parts = add([
pos(center()),
particles({
max: 20,
speed: [50, 100],
angle: [0, 360],
angularVelocity: [45, 90],
lifeTime: [1.0, 1.5],
colors: [rgb(128, 128, 255), WHITE],
opacities: [0.1, 1.0, 0.0],
scales: [1, 2, 1],
texture: getSprite("star").data.tex,
quads: [getSprite("star").data.frames[0]],
}, {
lifetime: 1.5,
rate: 0,
direction: -90,
spread: 40,
}),
]);
parts.emit(20);
}
scene("game", () => {
onKeyPress("space", () => {
woah();
});
onMousePress(() => {
woah();
});
add([
text("press space for particles"),
]);
});