replace clock spawning with score attack style

This commit is contained in:
t. boddy 2022-09-24 14:09:10 -04:00
parent 527d1b8f8d
commit 51aed3b0ba
4 changed files with 85 additions and 99 deletions

View File

@ -93,6 +93,6 @@ void loadChrome(){
void updateChrome(){
updateBoss();
// VDP_drawText(debugStr, 0, 27);
VDP_drawText(debugStr, 0, 27);
// updateScore();
}

View File

@ -79,6 +79,7 @@ static void enemyAnimate(s16 i){
// loop
static void updateEnemy(s16 i){
enemyCount++;
enemies[i].last.x = enemies[i].pos.x;
enemies[i].last.y = enemies[i].pos.y;
if(enemies[i].seen && (enemies[i].pos.x < fix16Sub(0, enemies[i].off.x) ||
@ -110,11 +111,14 @@ static void updateEnemy(s16 i){
}
}
if(enemies[i].dead){
enemyCount--;
enemies[i].active = FALSE;
SPR_releaseSprite(enemies[i].image);
}
}
void updateEnemies(){
enemyCount = 0;
for(s16 i = 0; i < ENEMY_COUNT; i++) if(enemies[i].active) updateEnemy(i);
intToStr(enemyCount, debugStr, 2);
}

View File

@ -21,7 +21,7 @@
bool killBullets,
started;
s16 clock, timeLeft,
s16 clock, timeLeft, enemyCount,
bossHealth, bossMax;
char debugStr[8];

View File

@ -55,7 +55,10 @@ static void waveSine(bool right){
enemies[i].pos.x = fix16Sub(enemies[i].fixes[0], fix16Mul(sinFix16(enemies[i].fixes[1]), enemies[i].fixes[2]));
enemies[i].fixes[1] = enemies[i].bools[0] ? fix16Add(enemies[i].fixes[1], enemies[i].fixes[3]) : fix16Sub(enemies[i].fixes[1], enemies[i].fixes[3]);
}
spawnEnemy(spawner, updater, EMPTY);
for(u8 i = 0; i < 6; i++){
spawnEnemy(spawner, updater, EMPTY);
spawner.y -= 32;
}
}
static void waveBig1(){
@ -177,19 +180,22 @@ static void waveBig3(){
spawnEnemy(spawner, updater, EMPTY);
}
static void waveSwarm(bool right, bool color){
static void waveSwarm(u8 count){
struct enemySpawner spawner = {
.angle = 256,
.speed = FIX16(1.25),
.x = random() % (GAME_W / 2 - 64),
.y = -16,
.image = color ? &fairyRed : &fairyBlue,
.offX = 16,
.offY = 16,
.health = 2
};
spawner.x += right ? (GAME_W / 2) : 64;
spawnEnemy(spawner, EMPTY, EMPTY);
for(u8 i = 0; i < count; i++){
spawner.x = random() % (GAME_W / 2 - 48);
spawner.x += (i % 2 == 0) ? (GAME_W / 2) : 48;
spawner.image = i % 4 < 2 ? &fairyRed : &fairyBlue;
spawner.y -= 32;
spawnEnemy(spawner, EMPTY, EMPTY);
}
}
static void waveBig4(bool right, bool second){
@ -203,6 +209,7 @@ static void waveBig4(bool right, bool second){
.offY = 16,
.health = 4
};
if(right) spawner.y -= 24;
spawner.bools[0] = right;
spawner.bools[1] = second;
void updater(s16 i){
@ -254,10 +261,12 @@ static void waveBig5(bool right){
.offY = 16,
.health = 6
};
if(right) spawner.x = GAME_W - spawner.x;
if(right){
spawner.x = GAME_W - spawner.x;
spawner.y -= 32;
}
spawner.bools[0] = right;
void updater(s16 i){
if(enemies[i].clock > 0 && enemies[i].clock % 60 == 30 && enemies[i].clock < 240){
struct bulletSpawner spawner = {
.x = enemies[i].pos.x,
@ -286,7 +295,6 @@ static void waveBig5(bool right){
enemies[i].angle += enemies[i].bools[0] ? -64 : 64;
updateEnemyVel(i);
}
}
spawnEnemy(spawner, updater, EMPTY);
}
@ -368,7 +376,6 @@ static void bossMove(s16 i){
}
}
static void waveMidboss1(){
bossAnimateClock = 0;
struct enemySpawner spawner = {
@ -387,7 +394,6 @@ static void waveMidboss1(){
bossAnimate(i);
if(enemies[i].bools[0]){
bossHealth = enemies[i].health;
intToStr(bossHealth, debugStr, 2);
bossMove(i);
if(enemies[i].health >= 25){
// ring
@ -482,100 +488,76 @@ static void waveMidboss1(){
void suicide(s16 i){
bossHealth = 0;
killBullets = TRUE;
nextClock = stageClock + 120;
}
spawnEnemy(spawner, updater, suicide);
}
// loop
s16 currentWave = 43;
static void updateWaves(){
if(stageClock == nextClock){
// sine from left
if(currentWave < 6){
waveSine(FALSE);
nextClock += currentWave == 5 ? 60 : 30;
}
// sine from right
else if(currentWave < 12){
waveSine(TRUE);
nextClock += currentWave == 11 ? 60 : 30;
}
// big middle
else if(currentWave == 12){
waveBig1();
nextClock += 120;
}
// sine from left, big right
else if(currentWave < 18){
waveSine(FALSE);
if(currentWave == 16) waveBig2(FALSE);
nextClock += currentWave == 17 ? 90 : 30;
}
// sine from right, big left
else if(currentWave < 24){
waveSine(TRUE);
if(currentWave == 22) waveBig2(TRUE);
nextClock += currentWave == 23 ? 120 : 30;
}
// big middle
else if(currentWave == 24){
waveBig3();
nextClock += 210;
}
// swarm (8)
else if(currentWave < 32){
waveSwarm(currentWave % 2 == 0, currentWave % 4 < 2);
nextClock += 30;
}
// big left and right
else if(currentWave < 34){
waveBig4(currentWave == 32, FALSE);
nextClock += currentWave == 32 ? 60 : 120;
}
// swarm (4), big right
else if(currentWave < 38){
waveSwarm(FALSE, currentWave % 2 < 1);
if(currentWave == 35) waveBig4(TRUE, TRUE);
nextClock += currentWave == 37 ? 60 : 30;
}
// swarm (4), big left
else if(currentWave < 42){
waveSwarm(TRUE, currentWave % 2 < 1);
if(currentWave == 39) waveBig4(FALSE, TRUE);
nextClock += currentWave == 41 ? 210 : 30;
}
// midboss
else if(currentWave == 42){
waveMidboss1();
}
// big from left and right
else if(currentWave < 45){
waveBig5(currentWave == 44);
nextClock += 60;
}
currentWave++;
}
}
s16 currentWave = 0;
void updateStage(){
updateWaves();
if(enemyCount == 0){
switch(currentWave){
// sine from left
case 0:
waveSine(FALSE);
break;
// sine from right
case 1:
waveSine(TRUE);
break;
// big middle
case 2:
waveBig1();
break;
// sine from left, big right
case 3:
waveSine(FALSE);
waveBig2(FALSE);
break;
// sine from right, big left
case 4:
waveSine(TRUE);
waveBig2(TRUE);
break;
// big middle
case 5:
waveBig3();
break;
// swarm (8)
case 6:
waveSwarm(8);
break;
// big left and right
case 7:
waveBig4(TRUE, FALSE);
waveBig4(FALSE, FALSE);
break;
// swarm (2), big right
case 8:
waveSwarm(2);
waveBig4(TRUE, TRUE);
break;
case 9:
// swarm (2), big left
waveSwarm(2);
waveBig4(FALSE, TRUE);
break;
// midboss
case 10:
waveMidboss1();
break;
// big from left and right
case 11:
waveBig5(FALSE);
waveBig5(TRUE);
break;
}
currentWave++;
}
stageClock++;
if(stageClock >= CLOCK_LIMIT) stageClock -= CLOCK_LIMIT;
}