Added disabled pulse effect to entities.

This commit is contained in:
Steve 2016-02-14 16:34:11 +00:00
parent 54b92ad137
commit b5fc0aacbd
2 changed files with 26 additions and 0 deletions

View File

@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static Entity deadHead; static Entity deadHead;
static Entity *deadTail; static Entity *deadTail;
static int disabledGlow;
static int disabledGlowDir;
static void drawEntity(Entity *e); static void drawEntity(Entity *e);
static void doEntity(void); static void doEntity(void);
static void alignComponents(void); static void alignComponents(void);
@ -38,6 +41,9 @@ void initEntities(void)
memset(&deadHead, 0, sizeof(Entity)); memset(&deadHead, 0, sizeof(Entity));
deadTail = &deadHead; deadTail = &deadHead;
disabledGlow = DISABLED_GLOW_MAX;
disabledGlowDir = -DISABLED_GLOW_SPEED;
} }
Entity *spawnEntity(void) Entity *spawnEntity(void)
@ -238,6 +244,17 @@ void doEntities(void)
} }
alignComponents(); alignComponents();
disabledGlow = MAX(DISABLED_GLOW_MIN, MIN(disabledGlow + disabledGlowDir, DISABLED_GLOW_MAX));
if (disabledGlow <= DISABLED_GLOW_MIN)
{
disabledGlowDir = DISABLED_GLOW_SPEED;
}
else if (disabledGlow >= DISABLED_GLOW_MAX)
{
disabledGlowDir = -DISABLED_GLOW_SPEED;
}
} }
static void restrictToGrid(Entity *e) static void restrictToGrid(Entity *e)
@ -371,6 +388,11 @@ static void drawEntity(Entity *e)
SDL_SetTextureColorMod(e->texture, 255 - e->systemHit, 255, 255); SDL_SetTextureColorMod(e->texture, 255 - e->systemHit, 255, 255);
} }
if (e->flags & EF_DISABLED)
{
SDL_SetTextureColorMod(e->texture, disabledGlow, disabledGlow, 255);
}
blitRotated(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->angle); blitRotated(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->angle);
if (e->shieldHit > 0) if (e->shieldHit > 0)

View File

@ -20,6 +20,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../common.h" #include "../common.h"
#define DISABLED_GLOW_SPEED 3
#define DISABLED_GLOW_MIN 128
#define DISABLED_GLOW_MAX 255
extern void blitRotated(SDL_Texture *texture, int x, int y, float angle); extern void blitRotated(SDL_Texture *texture, int x, int y, float angle);
extern void doFighter(void); extern void doFighter(void);
extern void doCapitalShip(void); extern void doCapitalShip(void);