MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / spawnExplosion

Function spawnExplosion

examples/space-blaster/main.ts:137–155  ·  view source on GitHub ↗
(x: number, y: number, count: number, color: Color)

Source from the content-addressed store, hash-verified

135}
136
137function spawnExplosion(x: number, y: number, count: number, color: Color): void {
138 for (let n = 0; n < count; n++) {
139 for (let i = 0; i < MAX_PARTICLES; i++) {
140 if (!particles[i].active) {
141 const angle = randomFloat(0, Math.PI * 2);
142 const speed = randomFloat(50, 200);
143 particles[i].x = x;
144 particles[i].y = y;
145 particles[i].vx = Math.cos(angle) * speed;
146 particles[i].vy = Math.sin(angle) * speed;
147 particles[i].life = randomFloat(0.3, 0.8);
148 particles[i].maxLife = particles[i].life;
149 particles[i].color = color;
150 particles[i].active = true;
151 break;
152 }
153 }
154 }
155}
156
157function getEnemyColor(kind: number): Color {
158 if (kind === 0) return { r: 230, g: 50, b: 50, a: 255 };

Callers 1

main.tsFile · 0.85

Calls 1

randomFloatFunction · 0.90

Tested by

no test coverage detected