Skip to content

Commit

Permalink
add back particle example but skip in test
Browse files Browse the repository at this point in the history
  • Loading branch information
slmjkdbtl committed Mar 24, 2024
1 parent d4bafa6 commit 1ec399e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/particle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Particle spawning

kaboom()

const sprites = [
"apple",
"heart",
"coin",
"meat",
"lightening",
]

sprites.forEach((spr) => {
loadSprite(spr, `/sprites/${spr}.png`)
})

setGravity(800)

// Spawn one particle every 0.1 second
loop(0.1, () => {

// TODO: they are resolving collision with each other for some reason
// Compose particle properties with components
const item = add([
pos(mousePos()),
sprite(choose(sprites)),
anchor("center"),
scale(rand(0.5, 1)),
area({ collisionIgnore: ["particle"] }),
body(),
lifespan(1, { fade: 0.5 }),
opacity(1),
move(choose([LEFT, RIGHT]), rand(60, 240)),
"particle",
])

item.jump(rand(320, 640))

})
2 changes: 2 additions & 0 deletions scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const run = async () => {
const examples = (await fs.readdir("examples"))
.filter((p) => !p.startsWith(".") && p.endsWith(".js"))
.map((d) => path.basename(d, ".js"))
// particle example crashes puppeteer in github action for some reason
.filter((e) => e !== "particle")

for (const example of examples) {
console.log(`testing example "${example}"`)
Expand Down

0 comments on commit 1ec399e

Please sign in to comment.