diff --git a/data/battle/bullets.json b/data/battle/bullets.json index 66fd53a..7fca7fa 100644 --- a/data/battle/bullets.json +++ b/data/battle/bullets.json @@ -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" }, { diff --git a/sound/18380__inferno__hvrl.ogg b/sound/18380__inferno__hvrl.ogg new file mode 100644 index 0000000..1d3a755 Binary files /dev/null and b/sound/18380__inferno__hvrl.ogg differ diff --git a/src/battle/bullets.c b/src/battle/bullets.c index 1f763bd..edb4c02 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -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) diff --git a/src/battle/bullets.h b/src/battle/bullets.h index 818a651..5613eb4 100644 --- a/src/battle/bullets.h +++ b/src/battle/bullets.h @@ -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; diff --git a/src/battle/effects.c b/src/battle/effects.c index b3f2015..591d56b 100644 --- a/src/battle/effects.c +++ b/src/battle/effects.c @@ -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; diff --git a/src/defs.h b/src/defs.h index cd535c4..a24f4fa 100644 --- a/src/defs.h +++ b/src/defs.h @@ -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, diff --git a/src/system/lookup.c b/src/system/lookup.c index 4120586..7cf5ff8 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -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); diff --git a/src/system/sound.c b/src/system/sound.c index 786fa08..50b880d 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -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");