-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticleSystem.test.mjs
More file actions
51 lines (45 loc) · 1.2 KB
/
ParticleSystem.test.mjs
File metadata and controls
51 lines (45 loc) · 1.2 KB
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
51
/*
Toolbox Aid
David Quesenberry
03/23/2026
ParticleSystem.test.mjs
*/
import assert from 'node:assert/strict';
import { ParticleSystem } from '../../src/engine/fx/index.js';
function createSequenceRandom(values) {
let index = 0;
return () => {
const value = values[index % values.length];
index += 1;
return value;
};
}
export function run() {
const sequence = [0.1, 0.7, 0.25, 0.9, 0.4, 0.6, 0.2, 0.8, 0.3];
const first = new ParticleSystem({ random: createSequenceRandom(sequence) });
const second = new ParticleSystem({ random: createSequenceRandom(sequence) });
first.spawnExplosion({
x: 40,
y: 55,
count: 3,
speed: 140,
lifeSeconds: 1.1,
randomize: true,
shape: 'circle',
color: '#ffaa00',
});
second.spawnExplosion({
x: 40,
y: 55,
count: 3,
speed: 140,
lifeSeconds: 1.1,
randomize: true,
shape: 'circle',
color: '#ffaa00',
});
assert.deepEqual(first.getSnapshot(), second.getSnapshot());
const fallbackRandomSystem = new ParticleSystem({ random: 'invalid' });
fallbackRandomSystem.spawnExplosion({ x: 10, y: 20, count: 2, randomize: true });
assert.equal(fallbackRandomSystem.getSnapshot().length, 2);
}