Skip to content

Commit

Permalink
Only store the last attack of the first boss
Browse files Browse the repository at this point in the history
  • Loading branch information
bit69tream committed Jan 14, 2024
1 parent 3de2403 commit f097327
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/stribun.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ void bossMarineShoot(float speedMultiplier,
}
}

static bool bossMarineAttacks[BOSS_MARINE_NOT_SHOOTING] = {0};
static BossMarineAttack bossMarineLastAttack = 0;

void bossMarineAttack(void) {
bossMarine.attackTimer -= GetFrameTime();
Expand All @@ -947,24 +947,12 @@ void bossMarineAttack(void) {
bossMarine.isWalking = (bool)GetRandomValue(0, 1);

if (bossMarine.currentAttack == BOSS_MARINE_NOT_SHOOTING) {
int c = 0;
for (int i = 0; i < BOSS_MARINE_NOT_SHOOTING; i++) {
if (bossMarineAttacks[i]) {
c++;
}
}

if (c == BOSS_MARINE_NOT_SHOOTING) {
memset(bossMarineAttacks, 0, sizeof(bossMarineAttacks));
}

BossMarineAttack a = 0;
do {
a = GetRandomValue(BOSS_MARINE_SINUS_SHOOTING,
BOSS_MARINE_BOUNCING_WAVES);
} while (bossMarineAttacks[a]);
bossMarineAttacks[a] = true;

} while (a == bossMarineLastAttack);
bossMarineLastAttack = a;
bossMarine.currentAttack = a;

bossMarine.attackTimer = (float)GetRandomValue(3, 7);
Expand Down Expand Up @@ -3545,7 +3533,7 @@ void initBossBall(void) {

void initBossMarine(void) {
memset(&bossMarine, 0, sizeof(bossMarine));
memset(bossMarineAttacks, 0, sizeof(bossMarineAttacks));
bossMarineLastAttack = 0;

bossMarine = (BossMarine) {
.position = {
Expand Down

0 comments on commit f097327

Please sign in to comment.