Shield hit effect optimisation.

This commit is contained in:
Steve 2015-11-22 16:51:11 +00:00
parent 182e34859e
commit 048d3b17e0
4 changed files with 12 additions and 7 deletions

View File

@ -95,6 +95,13 @@ void drawEffects(void)
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
}
void drawShieldHitEffect(Entity *e)
{
SDL_SetTextureBlendMode(shieldHitTexture, SDL_BLENDMODE_BLEND);
SDL_SetTextureAlphaMod(shieldHitTexture, e->shieldHit);
blit(shieldHitTexture, e->x - battle.camera.x, e->y - battle.camera.y, 1);
}
void addSmallFighterExplosion(void)
{
Effect *e;

View File

@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void blitScaled(SDL_Texture *texture, int x, int y, int w, int h);
extern SDL_Texture *getTexture(char *name);
extern void blit(SDL_Texture *t, int x, int y, int center);
extern App app;
extern Battle battle;

View File

@ -359,8 +359,6 @@ static void separate(void)
void drawFighter(Entity *e)
{
SDL_Texture *shieldHitTexture = getTexture("gfx/battle/shieldHit.png");
SDL_SetTextureColorMod(e->texture, 255, 255, 255);
if (e->armourHit > 0)
@ -377,9 +375,7 @@ void drawFighter(Entity *e)
if (e->shieldHit > 0)
{
SDL_SetTextureBlendMode(shieldHitTexture, SDL_BLENDMODE_BLEND);
SDL_SetTextureAlphaMod(shieldHitTexture, e->shieldHit);
blit(shieldHitTexture, e->x - battle.camera.x, e->y - battle.camera.y, 1);
drawShieldHitEffect(e);
}
}
@ -628,8 +624,8 @@ static void loadFighterDef(char *filename)
STRNCPY(f->name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH);
STRNCPY(f->defName, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH);
f->health = f->maxHealth = cJSON_GetObjectItem(root, "health")->valueint;
f->shield = f->maxShield = cJSON_GetObjectItem(root, "shield")->valueint;
f->health = f->maxHealth = cJSON_GetObjectItem(root, "health")->valueint * 2;
f->shield = f->maxShield = cJSON_GetObjectItem(root, "shield")->valueint * 2;
f->speed = cJSON_GetObjectItem(root, "speed")->valuedouble;
f->reloadTime = cJSON_GetObjectItem(root, "reloadTime")->valueint;
f->shieldRechargeRate = cJSON_GetObjectItem(root, "shieldRechargeRate")->valueint;

View File

@ -48,6 +48,7 @@ extern long lookup(char *name);
extern long flagsToLong(char *flags);
extern void addShieldSplinterEffect(Entity *ent);
extern void completeMission(void);
extern void drawShieldHitEffect(Entity *e);
extern App app;
extern Battle battle;