Added EyeDroid Commander boss battle.

This commit is contained in:
Steve 2018-02-24 16:53:03 +00:00
parent 1c149695e2
commit 15d6ca5678
4 changed files with 43 additions and 21 deletions

View File

@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void activate(int activate); static void activate(int activate);
static void tick(void); static void tick(void);
static void walk(void); static void walk(void);
static void moveTowardsPlayer(void); static void moveTowardsPlayer(int dir);
static void die1(void); static void die(void);
static void die2(void); static void die2(void);
static void selectWeapon(void); static void selectWeapon(void);
static void attackPistol(void); static void attackPistol(void);
@ -40,13 +40,11 @@ static Sprite *aimedSprite;
static Sprite *missileSprite[2]; static Sprite *missileSprite[2];
static Sprite *plasmaSprite[2]; static Sprite *plasmaSprite[2];
void initEyeDroidCommander(Entity *e) Entity *initEyeDroidCommander(void)
{ {
Boss *b; Boss *b;
initBoss(e); b = initBoss();
b = (Boss*)e;
STRNCPY(b->name, "EyeDroid Commander", MAX_NAME_LENGTH); STRNCPY(b->name, "EyeDroid Commander", MAX_NAME_LENGTH);
@ -58,10 +56,12 @@ void initEyeDroidCommander(Entity *e)
b->health = b->healthMax = 250; b->health = b->healthMax = 250;
b->action = walk;
b->walk = walk; b->walk = walk;
b->tick = tick; b->tick = tick;
b->activate = activate; b->activate = activate;
b->applyDamage = applyDamage; b->applyDamage = applyDamage;
b->die = die;
b->getCurrentSprite = getCurrentSprite; b->getCurrentSprite = getCurrentSprite;
brakingTimer = 0; brakingTimer = 0;
@ -73,6 +73,8 @@ void initEyeDroidCommander(Entity *e)
plasmaSprite[0] = getSprite("PlasmaRight"); plasmaSprite[0] = getSprite("PlasmaRight");
plasmaSprite[1] = getSprite("PlasmaLeft"); plasmaSprite[1] = getSprite("PlasmaLeft");
return (Entity*)b;
} }
static void activate(int activate) static void activate(int activate)
@ -114,22 +116,26 @@ static void tick(void)
static void lookForPlayer(void) static void lookForPlayer(void)
{ {
float distance;
self->thinkTime = rrnd(0, FPS / 2); self->thinkTime = rrnd(0, FPS / 2);
if (rand() % 100 < 5) if (rand() % 100 < 5)
{ {
brakingTimer = rrnd(60, 120); brakingTimer = rrnd(60, 120);
} }
distance = getDistance(world.bob->x, world.bob->y, self->x, self->y);
if (getDistance(world.bob->x, world.bob->y, self->x, self->y) > 650) if (distance > SCREEN_HEIGHT)
{ {
moveTowardsPlayer(); moveTowardsPlayer(1);
return; return;
} }
if (enemyCanSeePlayer(self)) if (!enemyCanSeePlayer(self))
{ {
moveTowardsPlayer(); moveTowardsPlayer(1);
return; return;
} }
@ -137,8 +143,15 @@ static void lookForPlayer(void)
{ {
selectWeapon(); selectWeapon();
} }
moveTowardsPlayer(); if (distance < SCREEN_HEIGHT / 4)
{
moveTowardsPlayer(-6);
}
else
{
moveTowardsPlayer(1);
}
} }
static void selectWeapon(void) static void selectWeapon(void)
@ -169,31 +182,35 @@ static void selectWeapon(void)
static void walk(void) static void walk(void)
{ {
self->action = (self->health > 0) ? lookForPlayer : die1; self->action = (self->health > 0) ? lookForPlayer : die;
} }
static void moveTowardsPlayer(void) static void moveTowardsPlayer(int dir)
{ {
float vel;
vel = 0.5 * dir;
if (brakingTimer == 0) if (brakingTimer == 0)
{ {
if (world.bob->x < self->x) if (world.bob->x < self->x)
{ {
self->dx -= 0.5; self->dx -= vel;
} }
if (world.bob->x > self->x) if (world.bob->x > self->x)
{ {
self->dx += 0.5; self->dx += vel;
} }
if (world.bob->y < self->y) if (world.bob->y < self->y)
{ {
self->dy -= 0.5; self->dy -= vel;
} }
if (world.bob->y > self->y) if (world.bob->y > self->y)
{ {
self->dy += 0.5; self->dy += vel;
} }
self->dx = limit(self->dx, -7.5, 7.5); self->dx = limit(self->dx, -7.5, 7.5);
@ -316,6 +333,8 @@ static void attackMissile(void)
missile->health = FPS * 3; missile->health = FPS * 3;
missile->sprite[0] = missileSprite[0]; missile->sprite[0] = missileSprite[0];
missile->sprite[1] = missileSprite[1]; missile->sprite[1] = missileSprite[1];
initMissile(missile);
b->reload = 15; b->reload = 15;
@ -333,7 +352,7 @@ static void applyDamage(int amount)
} }
} }
static void die1(void) static void die(void)
{ {
Boss *b; Boss *b;

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h" #include "../../common.h"
extern void initBoss(Entity *e); extern Boss *initBoss(void);
extern Sprite *getSprite(char *name); extern Sprite *getSprite(char *name);
extern void playMusic(char *filename, int loop); extern void playMusic(char *filename, int loop);
extern void addTeleportStars(Entity *e); extern void addTeleportStars(Entity *e);
@ -37,6 +37,7 @@ extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern void addExplosion(float x, float y, int radius, Entity *owner); extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void awardTrophy(char *id); extern void awardTrophy(char *id);
extern void entityIdle(void); extern void entityIdle(void);
extern void initMissile(Bullet *b);
extern Entity *self; extern Entity *self;
extern Game game; extern Game game;

View File

@ -52,6 +52,7 @@ void initEntityFactory(void)
addEntityDef("Cannon", initCannon); addEntityDef("Cannon", initCannon);
addEntityDef("Blaze", initBlaze); addEntityDef("Blaze", initBlaze);
addEntityDef("Frost", initFrost); addEntityDef("Frost", initFrost);
addEntityDef("EyeDroidCommander", initEyeDroidCommander);
addEntityDef("Bob", initBob); addEntityDef("Bob", initBob);
addEntityDef("MIA", initMIA); addEntityDef("MIA", initMIA);

View File

@ -71,5 +71,6 @@ extern Entity *initItemPad(void);
extern Entity *initWeaponPickup(void); extern Entity *initWeaponPickup(void);
extern Entity *initBlaze(void); extern Entity *initBlaze(void);
extern Entity *initFrost(void); extern Entity *initFrost(void);
extern Entity *initEyeDroidCommander(void);
extern World world; extern World world;