diff --git a/README.md b/README.md index ac1648c..259c2cd 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ GRAPHICS gfx/planets/earth.png - modified from the the Blue Marble NASA photograph: http://visibleearth.nasa.gov/view.php?id=57723 -All other graphics are CC BY-NC-SA 3.0, with the following attribution: Copyright 2015, Stephen J Sweeney | www.battleforthesolarsystem.com +All other graphics are CC BY-NC-SA 3.0, with the following attribution: Copyright 2015,2016, Stephen J Sweeney | www.battleforthesolarsystem.com DATA FILES (with the exception of Roboto font) -CC BY-NC-SA 3.0, with the following attribution: Copyright 2015, Stephen J Sweeney | www.battleforthesolarsystem.com +CC BY-NC-SA 3.0, with the following attribution: Copyright 2015,2016, Stephen J Sweeney | www.battleforthesolarsystem.com SOUND @@ -45,6 +45,7 @@ SOUND 321104__nsstudios__blip2.ogg - blip2, by nsstudios - https://freesound.org/people/nsstudios/sounds/321104/ 321906__bruce965__walkie-talkie-roger-beep.ogg - Walkie Talkie - Roger Beep, by bruce965 - https://freesound.org/people/bruce965/sounds/321906/ 322603__clippysounds__glass-break.ogg - Glass Break, by clippysounds - https://freesound.org/people/clippysounds/sounds/322603/ +276912__pauldihor__transform.ogg - transform, by PaulDihor - https://freesound.org/people/PaulDihor/sounds/276912/ MUSIC diff --git a/sound/276912__pauldihor__transform.ogg b/sound/276912__pauldihor__transform.ogg new file mode 100644 index 0000000..eeec1b0 Binary files /dev/null and b/sound/276912__pauldihor__transform.ogg differ diff --git a/src/battle/effects.c b/src/battle/effects.c index e6bac68..edb8939 100644 --- a/src/battle/effects.c +++ b/src/battle/effects.c @@ -44,25 +44,23 @@ void doEffects(void) e->x += e->dx; e->y += e->dy; + e->a -= (e->type != EFFECT_ECM) ? 1 : 3; + e->a = MAX(0, e->a); + e->health--; e->size += e->scaleAmount; if (e->health <= 0) { - e->a -= (e->type != EFFECT_ECM) ? 1 : 3; - - if (e->a <= 0) + if (e == battle.effectTail) { - if (e == battle.effectTail) - { - battle.effectTail = prev; - } - - prev->next = e->next; - free(e); - e = prev; + battle.effectTail = prev; } + + prev->next = e->next; + free(e); + e = prev; } prev = e; @@ -84,6 +82,10 @@ void drawEffects(void) switch (e->type) { + case EFFECT_POINT: + SDL_RenderDrawPoint(app.renderer, e->x - battle.camera.x, e->y - battle.camera.y); + break; + case EFFECT_LINE: SDL_RenderDrawLine(app.renderer, e->x - battle.camera.x, e->y - battle.camera.y, e->x + (e->dx * 3) - battle.camera.x, e->y + (e->dy * 3) - battle.camera.y); break; @@ -129,12 +131,12 @@ void addSmallFighterExplosion(void) e->x = self->x + (rand() % 16 - rand() % 16); e->y = self->y + (rand() % 16 - rand() % 16); e->texture = explosionTexture; - e->health = 0; e->size = 32; setRandomFlameHue(e); e->a = 128 + (rand() % 128); + e->health = e->a; e->x -= e->size / 2; e->y -= e->size / 2; @@ -154,12 +156,12 @@ void addDebrisFire(int x, int y) e->x = x + (rand() % 8 - rand() % 8); e->y = y + (rand() % 8 - rand() % 8); e->texture = explosionTexture; - e->health = 0; e->size = 4 + rand() % 12; setRandomFlameHue(e); e->a = rand() % 256; + e->health = e->a; e->x -= e->size / 2; e->y -= e->size / 2; @@ -186,13 +188,13 @@ void addSmallExplosion(void) e->dy = (rand() % 25) - (rand() % 25); e->dy *= 0.025; e->texture = explosionTexture; - e->health = 0; e->size = 32 + (rand() % 64); e->r = 255; setRandomFlameHue(e); e->a = 128 + (rand() % 128); + e->health = e->a; e->x -= e->size / 2; e->y -= e->size / 2; @@ -212,9 +214,9 @@ void addSmallExplosion(void) e->dx *= 0.1; e->dy = rand() % 64 - rand() % 64; e->dy *= 0.1; - e->health = FPS / 2; e->a = 128; + e->health = e->a; setRandomFlameHue(e); } @@ -241,13 +243,13 @@ void addMissileExplosion(Bullet *b) e->dy = (rand() % 25) - (rand() % 25); e->dy *= 0.025; e->texture = explosionTexture; - e->health = 0; e->size = 32 + (rand() % 64); e->r = 255; setRandomFlameHue(e); e->a = 128 + (rand() % 128); + e->health = e->a; e->x -= e->size / 2; e->y -= e->size / 2; @@ -267,9 +269,9 @@ void addMissileExplosion(Bullet *b) e->dx *= 0.1; e->dy = rand() % 64 - rand() % 64; e->dy *= 0.1; - e->health = FPS / 2; e->a = 128; + e->health = e->a; setRandomFlameHue(e); } @@ -299,13 +301,14 @@ void addEngineEffect(void) e->x += rand() % 4 - rand() % 4; e->texture = explosionTexture; - e->health = 0; e->size = 16; e->r = 128; e->g = 128; e->b = 255; e->a = 64; + e->health = e->a; + e->x -= e->size / 2; e->y -= e->size / 2; } @@ -331,13 +334,14 @@ void addLargeEngineEffect(void) e->x -= rand() % 4; e->texture = explosionTexture; - e->health = 0; e->size = 64; e->r = 128; e->g = 128; e->b = 255; e->a = 64; + e->health = e->a; + e->x -= e->size / 2; e->y -= e->size / 2; } @@ -363,11 +367,12 @@ void addMissileEngineEffect(Bullet *b) e->x -= rand() % 4; e->texture = explosionTexture; - e->health = 0; e->size = 12; setRandomFlameHue(e); e->a = 128; + e->health = e->a; + e->x -= e->size / 2; e->y -= e->size / 2; } diff --git a/src/battle/extractionPoint.c b/src/battle/extractionPoint.c index 9fb24e2..7d23f94 100644 --- a/src/battle/extractionPoint.c +++ b/src/battle/extractionPoint.c @@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void think(void); static void handleFleeingEntities(void); +static void addEscapeEffect(Entity *ent); Entity *spawnExtractionPoint(void) { @@ -60,9 +61,44 @@ static void handleFleeingEntities(void) for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) { - if (e->health > 0 && e->flags & EF_RETREATING && getDistance(self->x, self->y, e->x, e->y) <= 64) + if (e->health > 0 && e->flags & EF_RETREATING && getDistance(self->x, self->y, e->x, e->y) <= 255) { e->alive = ALIVE_ESCAPED; + + addEscapeEffect(e); + + playSound(SND_JUMP); } } } + +static void addEscapeEffect(Entity *ent) +{ + Effect *e; + int i, n, speed; + + n = ent->w * ent->h; + + for (i = 0 ; i < n ; i++) + { + e = malloc(sizeof(Effect)); + memset(e, 0, sizeof(Effect)); + battle.effectTail->next = e; + battle.effectTail = e; + + speed = 50 + rand() % 50; + + e->type = EFFECT_POINT; + e->x = ent->x + (rand() % ent->w) - (rand() % ent->w); + e->y = ent->y + (rand() % ent->h) - (rand() % ent->w); + + e->dx = self->x - e->x; + e->dx /= speed; + + e->dy = self->y - e->y; + e->dy /= speed; + + e->r = e->g = e->b = e->a = (rand() % 255); + e->health = speed; + } +} diff --git a/src/battle/extractionPoint.h b/src/battle/extractionPoint.h index 73c3b05..e531127 100644 --- a/src/battle/extractionPoint.h +++ b/src/battle/extractionPoint.h @@ -24,6 +24,7 @@ extern SDL_Texture *getTexture(char *filename); extern Entity *spawnEntity(void); extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore); extern int getDistance(int x1, int y1, int x2, int y2); +extern void playSound(int id); extern Battle battle; extern Entity *self; diff --git a/src/defs.h b/src/defs.h index 3a45fce..f7a5a1a 100644 --- a/src/defs.h +++ b/src/defs.h @@ -172,6 +172,7 @@ enum enum { + EFFECT_POINT, EFFECT_LINE, EFFECT_TEXTURE, EFFECT_HALO, @@ -194,6 +195,7 @@ enum SND_GET_ITEM, SND_MISSILE, SND_INCOMING, + SND_JUMP, SND_BOOST, SND_RADIO, SND_GUI_CLICK, diff --git a/src/system/sound.c b/src/system/sound.c index df3f53e..85df026 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -107,6 +107,7 @@ static void loadSounds(void) sounds[SND_EXPLOSION_2] = Mix_LoadWAV(getFileLocation("sound/207322__animationisaac__short-explosion.ogg")); sounds[SND_EXPLOSION_3] = Mix_LoadWAV(getFileLocation("sound/254071__tb0y298__firework-explosion.ogg")); sounds[SND_EXPLOSION_4] = Mix_LoadWAV(getFileLocation("sound/47252__nthompson__bad-explosion.ogg")); + sounds[SND_JUMP] = Mix_LoadWAV(getFileLocation("sound/276912__pauldihor__transform.ogg")); sounds[SND_GUI_CLICK] = Mix_LoadWAV(getFileLocation("sound/257786__xtrgamr__mouse-click.ogg")); sounds[SND_GUI_SELECT] = Mix_LoadWAV(getFileLocation("sound/321104__nsstudios__blip2.ogg"));