Further missile tweaks. Added launch sound effect.
This commit is contained in:
parent
05860ed8ca
commit
a21153cb12
|
@ -19,8 +19,8 @@
|
|||
"type" : "BT_MISSILE",
|
||||
"damage" : 25,
|
||||
"textureName" : "gfx/bullets/missile.png",
|
||||
"sound" : "SND_PLASMA",
|
||||
"flags" : "BF_ENGINE"
|
||||
"sound" : "SND_MISSILE",
|
||||
"flags" : "BF_ENGINE+BF_EXPLODES"
|
||||
},
|
||||
|
||||
{
|
||||
|
|
Binary file not shown.
|
@ -115,8 +115,14 @@ static void checkCollisions(Bullet *b)
|
|||
}
|
||||
|
||||
damageFighter(f, b->damage, b->flags);
|
||||
|
||||
b->life = 0;
|
||||
|
||||
if (b->flags & BF_EXPLODES)
|
||||
{
|
||||
addMissileExplosion(b);
|
||||
}
|
||||
|
||||
/* assuming that health <= 0 will always mean killed */
|
||||
if (f->health <= 0 && b->owner == player)
|
||||
{
|
||||
|
@ -142,6 +148,8 @@ static void faceTarget(Bullet *b)
|
|||
{
|
||||
int dir;
|
||||
int wantedAngle = getAngle(b->x, b->y, b->target->x, b->target->y);
|
||||
int angleDiff, angleDist;
|
||||
float brakeAmount;
|
||||
|
||||
wantedAngle %= 360;
|
||||
|
||||
|
@ -153,9 +161,16 @@ static void faceTarget(Bullet *b)
|
|||
|
||||
b->angle = mod(b->angle, 360);
|
||||
|
||||
angleDiff = abs(b->angle - wantedAngle) % 360;
|
||||
angleDist = angleDiff > 180 ? 360 - angleDiff : angleDiff;
|
||||
|
||||
brakeAmount = angleDist;
|
||||
brakeAmount /= 360;
|
||||
brakeAmount = 0.7 - brakeAmount;
|
||||
|
||||
/* halve your speed while you're not at the correct angle */
|
||||
b->dx *= 0.5;
|
||||
b->dy *= 0.5;
|
||||
b->dx *= brakeAmount;
|
||||
b->dy *= brakeAmount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,6 +276,8 @@ void fireMissile(Fighter *owner)
|
|||
b->life = FPS * 30;
|
||||
|
||||
owner->missiles.ammo--;
|
||||
|
||||
playBattleSound(b->sound, owner->x, owner->y);
|
||||
}
|
||||
|
||||
void destroyBulletDefs(void)
|
||||
|
|
|
@ -38,6 +38,7 @@ extern char *readFile(char *filename);
|
|||
extern float getAngle(int x1, int y1, int x2, int y2);
|
||||
extern void addMissileEngineEffect(Bullet *b);
|
||||
extern int mod(int n, int x);
|
||||
extern void addMissileExplosion(Bullet *b);
|
||||
|
||||
extern Battle battle;
|
||||
extern Fighter *player;
|
||||
|
|
|
@ -170,6 +170,62 @@ void addFighterExplosion(void)
|
|||
}
|
||||
}
|
||||
|
||||
void addMissileExplosion(Bullet *b)
|
||||
{
|
||||
int i;
|
||||
Effect *e;
|
||||
SDL_Texture *t = getTexture("gfx/battle/explosion.png");
|
||||
|
||||
for (i = 0 ; i < 8 ; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
battle.effectTail->next = e;
|
||||
battle.effectTail = e;
|
||||
|
||||
e->type = EFFECT_TEXTURE;
|
||||
|
||||
e->x = b->x;
|
||||
e->y = b->y;
|
||||
e->dx = (rand() % 25) - (rand() % 25);
|
||||
e->dx *= 0.025;
|
||||
e->dy = (rand() % 25) - (rand() % 25);
|
||||
e->dy *= 0.025;
|
||||
e->texture = t;
|
||||
e->health = 0;
|
||||
e->size = 32 + (rand() % 64);
|
||||
e->r = 255;
|
||||
|
||||
setRandomFlameHue(e);
|
||||
|
||||
e->a = 128 + (rand() % 128);
|
||||
|
||||
e->x -= e->size / 2;
|
||||
e->y -= e->size / 2;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < 24 ; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
battle.effectTail->next = e;
|
||||
battle.effectTail = e;
|
||||
|
||||
e->type = EFFECT_LINE;
|
||||
e->x = b->x;
|
||||
e->y = b->y;
|
||||
e->dx = rand() % 64 - rand() % 64;
|
||||
e->dx *= 0.1;
|
||||
e->dy = rand() % 64 - rand() % 64;
|
||||
e->dy *= 0.1;
|
||||
e->health = FPS / 2;
|
||||
|
||||
e->a = 128;
|
||||
|
||||
setRandomFlameHue(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void setRandomFlameHue(Effect *e)
|
||||
{
|
||||
e->r = 255;
|
||||
|
|
|
@ -49,6 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define BF_NONE 0
|
||||
#define BF_ENGINE (2 << 0)
|
||||
#define BF_SYSTEM_DAMAGE (2 << 1)
|
||||
#define BF_EXPLODES (2 << 2)
|
||||
|
||||
#define FF_NONE 0
|
||||
#define FF_NO_KILL (2 << 0)
|
||||
|
@ -121,6 +122,7 @@ enum
|
|||
SND_EXPLOSION_2,
|
||||
SND_EXPLOSION_3,
|
||||
SND_EXPLOSION_4,
|
||||
SND_MISSILE,
|
||||
SND_GUI_CLICK,
|
||||
SND_GUI_SELECT,
|
||||
SND_GUI_CLOSE,
|
||||
|
|
|
@ -51,6 +51,7 @@ void initLookups(void)
|
|||
addLookup("SND_PARTICLE", SND_PARTICLE);
|
||||
addLookup("SND_PLASMA", SND_PLASMA);
|
||||
addLookup("SND_MAG", SND_MAG);
|
||||
addLookup("SND_MISSILE", SND_MISSILE);
|
||||
|
||||
addLookup("BT_PARTICLE", BT_PARTICLE);
|
||||
addLookup("BT_PLASMA", BT_PLASMA);
|
||||
|
@ -62,6 +63,7 @@ void initLookups(void)
|
|||
addLookup("BF_NONE", BF_NONE);
|
||||
addLookup("BF_ENGINE", BF_ENGINE);
|
||||
addLookup("BF_SYSTEM_DAMAGE", BF_SYSTEM_DAMAGE);
|
||||
addLookup("BF_EXPLODES", BF_EXPLODES);
|
||||
|
||||
addLookup("MISSILE_ROCKET", MISSILE_ROCKET);
|
||||
addLookup("MISSILE_MISSILE", MISSILE_MISSILE);
|
||||
|
|
|
@ -95,6 +95,7 @@ static void loadSounds(void)
|
|||
sounds[SND_PLASMA] = Mix_LoadWAV("sound/268344__julien-matthey__jm-noiz-laser-01.ogg");
|
||||
sounds[SND_MAG] = Mix_LoadWAV("sound/18382__inferno__hvylas.ogg");
|
||||
sounds[SND_PARTICLE] = Mix_LoadWAV("sound/77087__supraliminal__laser-short.ogg");
|
||||
sounds[SND_MISSILE] = Mix_LoadWAV("sound/18380__inferno__hvrl.ogg");
|
||||
sounds[SND_EXPLOSION_1] = Mix_LoadWAV("sound/162265__qubodup__explosive.ogg");
|
||||
sounds[SND_EXPLOSION_2] = Mix_LoadWAV("sound/207322__animationisaac__short-explosion.ogg");
|
||||
sounds[SND_EXPLOSION_3] = Mix_LoadWAV("sound/254071__tb0y298__firework-explosion.ogg");
|
||||
|
|
Loading…
Reference in New Issue