From 542209c24cd485be3486c70800702c460631ea5a Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 29 Nov 2015 08:34:25 +0000 Subject: [PATCH] Added ECM effect. --- gfx/battle/shieldSplinter.png | Bin 202 -> 0 bytes gfx/{battle => effects}/explosion.png | Bin gfx/{battle => effects}/halo.png | Bin gfx/{battle => effects}/shieldHit.png | Bin src/battle/effects.c | 46 ++++++++++++++++++++++++-- src/battle/player.c | 2 ++ src/battle/player.h | 1 + src/defs.h | 3 +- src/structs.h | 3 +- 9 files changed, 50 insertions(+), 5 deletions(-) delete mode 100644 gfx/battle/shieldSplinter.png rename gfx/{battle => effects}/explosion.png (100%) rename gfx/{battle => effects}/halo.png (100%) rename gfx/{battle => effects}/shieldHit.png (100%) diff --git a/gfx/battle/shieldSplinter.png b/gfx/battle/shieldSplinter.png deleted file mode 100644 index 3bcfee12725925c53013ab2b33433ae55b9c00b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>1|%O$WD@{VY)RhkERL)U+-9lH>0w$a!g-mBgcV`>ryK+kIZg4 lE0S`#!health--; + e->size += e->scaleAmount; + if (e->health <= 0) { - if (--e->a <= 0) + e->a -= (e->type != EFFECT_ECM) ? 1 : 3; + + if (e->a <= 0) { if (e == battle.effectTail) { @@ -88,6 +94,13 @@ void drawEffects(void) break; case EFFECT_HALO: + SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b); + blitScaled(e->texture, e->x - battle.camera.x - (e->size / 2), e->y - battle.camera.y - (e->size / 2), e->size, e->size); + break; + + case EFFECT_ECM: + SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b); + blitScaled(e->texture, SCREEN_WIDTH / 2 - (e->size / 2), SCREEN_HEIGHT / 2 - (e->size / 2), e->size, e->size); break; } } @@ -325,6 +338,33 @@ void addShieldSplinterEffect(Entity *ent) } } +void addECMEffect(Entity *ent) +{ + int i; + Effect *e; + + for (i = 0 ; i < 3 ; i++) + { + e = malloc(sizeof(Effect)); + + memset(e, 0, sizeof(Effect)); + battle.effectTail->next = e; + battle.effectTail = e; + + e->type = EFFECT_ECM; + e->x = ent->x; + e->y = ent->y; + e->size = i * 4; + e->scaleAmount = 5; + e->texture = haloTexture; + + e->r = 128; + e->g = 128 + (i * 64); + e->b = 255; + e->a = 255; + } +} + static void setRandomFlameHue(Effect *e) { e->r = 255; diff --git a/src/battle/player.c b/src/battle/player.c index f55be26..6d93621 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -329,6 +329,8 @@ static void activateECM(void) { battle.ecmTimer = 0; + addECMEffect(player); + battle.stats[STAT_ECM]++; } diff --git a/src/battle/player.h b/src/battle/player.h index f761733..1d0ece8 100644 --- a/src/battle/player.h +++ b/src/battle/player.h @@ -38,6 +38,7 @@ extern void failMission(void); extern float getAngle(int x1, int y1, int x2, int y2); extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); extern void setMouse(int x, int y); +extern void addECMEffect(Entity *ent); extern App app; extern Battle battle; diff --git a/src/defs.h b/src/defs.h index 11b47a3..36bccaa 100644 --- a/src/defs.h +++ b/src/defs.h @@ -146,7 +146,8 @@ enum { EFFECT_LINE, EFFECT_TEXTURE, - EFFECT_HALO + EFFECT_HALO, + EFFECT_ECM }; enum diff --git a/src/structs.h b/src/structs.h index d38822a..39d1b6e 100644 --- a/src/structs.h +++ b/src/structs.h @@ -160,7 +160,8 @@ struct Effect { float dx; float dy; float health; - int size; + float size; + float scaleAmount; int r; int g; int b;