Skip to content

Commit

Permalink
Make boss not repeat attacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bit69tream committed Jan 4, 2024
1 parent 84add6a commit 95df384
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/stribun.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ void bossMarineShoot(float speedMultiplier,
}
}

static bool bossMarineAttacks[BOSS_MARINE_NOT_SHOOTING] = {0};

void bossMarineAttack(void) {
bossMarine.attackTimer -= GetFrameTime();
bossMarine.fireCooldown -= GetFrameTime();
Expand All @@ -655,9 +657,26 @@ void bossMarineAttack(void) {
bossMarine.isWalking = (bool)GetRandomValue(0, 1);

if (bossMarine.currentAttack == BOSS_MARINE_NOT_SHOOTING) {
bossMarine.currentAttack += GetRandomValue(BOSS_MARINE_SINUS_SHOOTING,
BOSS_MARINE_BOUNCING_WAVES);
bossMarine.currentAttack = 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;

bossMarine.currentAttack = a;

bossMarine.attackTimer = (float)GetRandomValue(3, 7);
} else {
bossMarine.currentAttack = BOSS_MARINE_NOT_SHOOTING;
Expand Down Expand Up @@ -692,7 +711,7 @@ void bossMarineAttack(void) {
(void) i;

float spread = (float)GetRandomValue(-15, 15);
float speed = (float)GetRandomValue(1, 10) / 10.0f * 0.6f;
float speed = (float)GetRandomValue(1, 10) / 10.0f * 0.8f;

bossMarineShoot(speed,
0,
Expand Down Expand Up @@ -2039,6 +2058,7 @@ void initBackgroundAsteroid(void) {

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

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

0 comments on commit 95df384

Please sign in to comment.