Show warning message and play sound when a missile is launched, targetting the player.

This commit is contained in:
Steve 2015-11-16 18:39:49 +00:00
parent 3bf5a0f057
commit c224aff926
6 changed files with 24 additions and 1 deletions

Binary file not shown.

View File

@ -25,6 +25,7 @@ static void checkCollisions(Bullet *b);
static Bullet bulletDef[BT_MAX];
static Bullet *bulletsToDraw[MAX_BULLETS_TO_DRAW];
static int incomingMissile;
void initBulletDefs(void)
{
@ -63,6 +64,8 @@ void doBullets(void)
Bullet *b;
Bullet *prev = &battle.bulletHead;
incomingMissile = 0;
memset(bulletsToDraw, 0, sizeof(Bullet*) * MAX_BULLETS_TO_DRAW);
for (b = battle.bulletHead.next ; b != NULL ; b = b->next)
@ -75,6 +78,11 @@ void doBullets(void)
addMissileEngineEffect(b);
huntTarget(b);
if (b->target == player && player != NULL && player->health > 0)
{
incomingMissile = 1;
}
}
checkCollisions(b);
@ -164,6 +172,11 @@ void drawBullets(void)
{
blitRotated(b->texture, b->x - battle.camera.x, b->y - battle.camera.y, b->angle);
}
if (incomingMissile && battle.stats[STAT_TIME] % FPS < 40)
{
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 60, 18, TA_CENTER, colors.red, "WARNING: INCOMING MISSILE!");
}
}
static void faceTarget(Bullet *b)
@ -302,6 +315,11 @@ void fireMissile(Entity *owner)
}
playBattleSound(b->sound, owner->x, owner->y);
if (owner->target == player)
{
playSound(SND_INCOMING);
}
}
void destroyBulletDefs(void)

View File

@ -41,6 +41,9 @@ extern void addMissileEngineEffect(Bullet *b);
extern int mod(int n, int x);
extern void addMissileExplosion(Bullet *b);
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
extern void playSound(int id);
extern Battle battle;
extern Colors colors;
extern Entity *player;

View File

@ -122,6 +122,6 @@ void drawRadarRangeWarning(void)
if (leaving && battle.stats[STAT_TIME] % FPS < 40)
{
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 50, 14, TA_CENTER, colors.red, "WARNING: Leaving battle area - turn around!");
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 30, 14, TA_CENTER, colors.white, "Caution: Leaving battle area - turn around.");
}
}

View File

@ -157,6 +157,7 @@ enum
SND_EXPLOSION_4,
SND_GET_ITEM,
SND_MISSILE,
SND_INCOMING,
SND_BOOST,
SND_GUI_CLICK,
SND_GUI_SELECT,

View File

@ -98,6 +98,7 @@ static void loadSounds(void)
sounds[SND_MISSILE] = Mix_LoadWAV("sound/65787__iwilldstroyu__laserrocket.ogg");
sounds[SND_BOOST] = Mix_LoadWAV("sound/18380__inferno__hvrl.ogg");
/*sounds[SND_ECM] = Mix_LoadWAV("sound/18380__inferno__hvrl.ogg");*/
sounds[SND_INCOMING] = Mix_LoadWAV("sound/242856__plasterbrain__nuclear-alarm.ogg");
sounds[SND_GET_ITEM] = Mix_LoadWAV("sound/56246__q-k__latch-04.ogg");
sounds[SND_EXPLOSION_1] = Mix_LoadWAV("sound/162265__qubodup__explosive.ogg");
sounds[SND_EXPLOSION_2] = Mix_LoadWAV("sound/207322__animationisaac__short-explosion.ogg");