boss movement
This commit is contained in:
parent
921954d8ac
commit
0750aef980
49
src/stage.h
49
src/stage.h
|
@ -229,6 +229,40 @@ static void waveBig4(bool right, bool second){
|
|||
|
||||
// bosses
|
||||
|
||||
#define BOSS_MOD_Y FIX16(16)
|
||||
#define BOSS_MOD_X FIX16(64)
|
||||
fix16 bossLimitY, bossLimitH, bossLimitX, bossLimitW;
|
||||
|
||||
static void bossIntro(s16 i){
|
||||
if(enemies[i].clock > 0 && enemies[i].clock % 30 == 0){
|
||||
enemies[i].speed = fix16Sub(enemies[i].speed, FIX16(0.25));
|
||||
if(enemies[i].speed <= 0){
|
||||
bossLimitY = fix16Sub(enemies[i].pos.y, BOSS_MOD_Y);
|
||||
bossLimitH = fix16Add(enemies[i].pos.y, BOSS_MOD_Y);
|
||||
bossLimitX = fix16Sub(enemies[i].pos.x, BOSS_MOD_X);
|
||||
bossLimitW = fix16Add(enemies[i].pos.x, BOSS_MOD_X);
|
||||
enemies[i].speed = FIX16(0.4);
|
||||
enemies[i].angle = 32;
|
||||
enemies[i].bools[0] = TRUE;
|
||||
enemies[i].clock = -1;
|
||||
}
|
||||
updateEnemyVel(i);
|
||||
}
|
||||
}
|
||||
|
||||
static void bossMove(s16 i){
|
||||
if(enemies[i].pos.x > bossLimitW || enemies[i].pos.x < bossLimitX){
|
||||
enemies[i].pos.x = enemies[i].pos.x > bossLimitW ? bossLimitW : bossLimitX;
|
||||
enemies[i].angle = 512 - enemies[i].angle;
|
||||
updateEnemyVel(i);
|
||||
}
|
||||
if(enemies[i].pos.y > bossLimitH || enemies[i].pos.y < bossLimitY){
|
||||
enemies[i].pos.y = enemies[i].pos.y > bossLimitH ? bossLimitH : bossLimitY;
|
||||
enemies[i].angle = 1024 - enemies[i].angle;
|
||||
updateEnemyVel(i);
|
||||
}
|
||||
}
|
||||
|
||||
static void waveMidboss1(){
|
||||
struct enemySpawner spawner = {
|
||||
.angle = 256,
|
||||
|
@ -242,6 +276,8 @@ static void waveMidboss1(){
|
|||
void updater(s16 i){
|
||||
if(enemies[i].bools[0]){
|
||||
|
||||
bossMove(i);
|
||||
|
||||
// ring
|
||||
if(enemies[i].clock % 90 == 0){
|
||||
struct bulletSpawner spawner = {
|
||||
|
@ -249,7 +285,7 @@ static void waveMidboss1(){
|
|||
.y = enemies[i].pos.y,
|
||||
.image = &bigBullet,
|
||||
.big = TRUE,
|
||||
.speed = FIX16(1),
|
||||
.speed = FIX16(1.25),
|
||||
.angle = 80 + random() % 32,
|
||||
.light = TRUE
|
||||
};
|
||||
|
@ -274,16 +310,7 @@ static void waveMidboss1(){
|
|||
spawnBullet(spawner, EMPTY);
|
||||
}
|
||||
|
||||
|
||||
} else if(!enemies[i].bools[0] && enemies[i].clock > 0 && enemies[i].clock % 30 == 0) {
|
||||
enemies[i].speed = fix16Sub(enemies[i].speed, FIX16(0.25));
|
||||
if(enemies[i].speed <= 0){
|
||||
enemies[i].speed = 0;
|
||||
enemies[i].bools[0] = TRUE;
|
||||
enemies[i].clock = -1;
|
||||
}
|
||||
updateEnemyVel(i);
|
||||
}
|
||||
} else bossIntro(i);
|
||||
}
|
||||
spawnEnemy(spawner, updater, EMPTY);
|
||||
}
|
||||
|
|
Reference in New Issue