Skip to content

Commit 81e4a40

Browse files
committed
chore: new particles example
1 parent c3a36a3 commit 81e4a40

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

examples/particle.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Creating particles using Particle Component
2+
3+
kaplay();
4+
5+
loadSprite("star", "./examples/sprites/particle_star_filled.png");
6+
7+
onLoad(() => {
8+
go("game")
9+
});
10+
11+
function woah() {
12+
const parts = add([
13+
pos(center()),
14+
particles({
15+
max: 20,
16+
speed: [50, 100],
17+
angle: [0, 360],
18+
angularVelocity: [45, 90],
19+
lifeTime: [1.0, 1.5],
20+
colors: [rgb(128, 128, 255), WHITE],
21+
opacities: [0.1, 1.0, 0.0],
22+
scales: [1, 2, 1],
23+
texture: getSprite("star").data.tex,
24+
quads: [getSprite("star").data.frames[0]],
25+
}, {
26+
lifetime: 1.5,
27+
rate: 0,
28+
direction: -90,
29+
spread: 40,
30+
}),
31+
]);
32+
33+
parts.emit(20);
34+
}
35+
36+
scene("game", () => {
37+
onKeyPress("space", () => {
38+
woah();
39+
});
40+
41+
onMousePress(() => {
42+
woah();
43+
});
44+
45+
add([
46+
text("press space for particles"),
47+
]);
48+
});
49+

0 commit comments

Comments
 (0)