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

Function spawnEnemy

examples/space-blaster/main.ts:114–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112}
113
114function spawnEnemy(): void {
115 for (let i = 0; i < MAX_ENEMIES; i++) {
116 if (!enemies[i].active) {
117 const kind = wave >= 3 ? randomInt(0, 2) : (wave >= 2 ? randomInt(0, 1) : 0);
118 enemies[i].x = randomFloat(ENEMY_WIDTH, SCREEN_WIDTH - ENEMY_WIDTH);
119 enemies[i].y = -ENEMY_HEIGHT;
120 enemies[i].kind = kind;
121 if (kind === 0) {
122 enemies[i].hp = 1;
123 enemies[i].speed = randomFloat(80, 150);
124 } else if (kind === 1) {
125 enemies[i].hp = 1;
126 enemies[i].speed = randomFloat(150, 250);
127 } else {
128 enemies[i].hp = 3;
129 enemies[i].speed = randomFloat(50, 100);
130 }
131 enemies[i].active = true;
132 return;
133 }
134 }
135}
136
137function spawnExplosion(x: number, y: number, count: number, color: Color): void {
138 for (let n = 0; n < count; n++) {

Callers 1

main.tsFile · 0.85

Calls 2

randomIntFunction · 0.90
randomFloatFunction · 0.90

Tested by

no test coverage detected