Scale shield effect size, to better match ship (mostly for supply ships).

This commit is contained in:
Steve 2016-07-22 11:07:35 +01:00
parent f7d2b4d738
commit 7547e14c9f
7 changed files with 23 additions and 14 deletions

View File

@ -220,12 +220,13 @@ static void draw(void)
drawBackground(battle.background);
blitScaled(battle.planetTexture, battle.planet.x, battle.planet.y, battle.planetWidth, battle.planetHeight);
blitScaled(battle.planetTexture, battle.planet.x, battle.planet.y, battle.planetWidth, battle.planetHeight, 0);
if (battle.destroyTorelli)
{
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
SDL_SetTextureAlphaMod(battle.fireStormTexture, battle.torelliFireStormAlpha);
blitScaled(battle.fireStormTexture, battle.planet.x, battle.planet.y, battle.planetWidth, battle.planetHeight);
blitScaled(battle.fireStormTexture, battle.planet.x, battle.planet.y, battle.planetWidth, battle.planetHeight, 0);
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
}

View File

@ -40,7 +40,7 @@ extern void drawEffects(void);
extern void doEffects(void);
extern void doObjectives(void);
extern void doChallenges(void);
extern void blitScaled(SDL_Texture *texture, int x, int y, int w, int h);
extern void blitScaled(SDL_Texture *texture, int x, int y, int w, int h, int center);
extern void initHud(void);
extern void initRadar(void);
extern void initGalacticMap(void);

View File

@ -154,17 +154,17 @@ void drawEffects(void)
case EFFECT_TEXTURE:
SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b);
blitScaled(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->size, e->size);
blitScaled(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->size, e->size, 0);
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);
blitScaled(e->texture, e->x - battle.camera.x - (e->size / 2), e->y - battle.camera.y - (e->size / 2), e->size, e->size, 0);
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);
blitScaled(e->texture, SCREEN_WIDTH / 2 - (e->size / 2), SCREEN_HEIGHT / 2 - (e->size / 2), e->size, e->size, 0);
break;
}
}
@ -174,9 +174,11 @@ void drawEffects(void)
void drawShieldHitEffect(Entity *e)
{
int size = MAX(e->w, e->h) + 32;
SDL_SetTextureBlendMode(shieldHitTexture, SDL_BLENDMODE_BLEND);
SDL_SetTextureAlphaMod(shieldHitTexture, e->shieldHit);
blit(shieldHitTexture, e->x - battle.camera.x, e->y - battle.camera.y, 1);
blitScaled(shieldHitTexture, e->x - battle.camera.x, e->y - battle.camera.y, size, size, 1);
}
void addBulletHitEffect(int x, int y, int r, int g, int b)

View File

@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define INITIAL_EFFECT_DRAW_CAPACITY 128
extern void blitScaled(SDL_Texture *texture, int x, int y, int w, int h);
extern void blitScaled(SDL_Texture *texture, int x, int y, int w, int h, int center);
extern SDL_Texture *getTexture(char *name);
extern void blit(SDL_Texture *t, int x, int y, int center);
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);

View File

@ -82,7 +82,7 @@ void blit(SDL_Texture *texture, int x, int y, int center)
SDL_RenderCopy(app.renderer, texture, NULL, &dstRect);
}
void blitScaled(SDL_Texture *texture, int x, int y, int w, int h)
void blitScaled(SDL_Texture *texture, int x, int y, int w, int h, int center)
{
SDL_Rect dstRect;
@ -91,6 +91,12 @@ void blitScaled(SDL_Texture *texture, int x, int y, int w, int h)
dstRect.w = w;
dstRect.h = h;
if (center)
{
dstRect.x -= (dstRect.w / 2);
dstRect.y -= (dstRect.h / 2);
}
SDL_RenderCopy(app.renderer, texture, NULL, &dstRect);
}
@ -182,7 +188,7 @@ void drawBackground(SDL_Texture *texture)
for (i = 0 ; i < 4 ; i++)
{
blitScaled(texture, backgroundPoint[i].x, backgroundPoint[i].y, SCREEN_WIDTH, SCREEN_HEIGHT);
blitScaled(texture, backgroundPoint[i].x, backgroundPoint[i].y, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
}
}

View File

@ -171,14 +171,14 @@ void drawTrophies(void)
blitRotated(sparkle, x + 32, y + 32, sparkleAngle);
blitRotated(sparkle, x + 32, y + 32, -sparkleAngle);
blitScaled(trophyIcons[t->value], x, y, 64, 64);
blitScaled(trophyIcons[t->value], x, y, 64, 64, 0);
drawText(x + 85, y - 10, 20, TA_LEFT, colors.yellow, t->title);
drawText(x + 85, y + 20, 18, TA_LEFT, colors.white, t->description);
drawText(x + 85, y + 48, 18, TA_LEFT, colors.white, t->awardDateStr);
}
else
{
blitScaled(trophyIcons[TROPHY_UNEARNED], x, y, 64, 64);
blitScaled(trophyIcons[TROPHY_UNEARNED], x, y, 64, 64, 0);
if (!t->hidden)
{
@ -318,7 +318,7 @@ void drawTrophyAlert(void)
blit(alertSphere, x + 24, y + 24, 1);
blitRotated(sparkle, x + 24, y + 24, sparkleAngle);
blitRotated(sparkle, x + 24, y + 24, -sparkleAngle);
blitScaled(trophyIcons[alertTrophy->value], x, y, 48, 48);
blitScaled(trophyIcons[alertTrophy->value], x, y, 48, 48, 0);
}
}

View File

@ -32,7 +32,7 @@ extern int getPercent(float current, float total);
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
extern void blit(SDL_Texture *texture, int x, int y, int centered);
extern void blitRotated(SDL_Texture *texture, int x, int y, float angle);
extern void blitScaled(SDL_Texture *t, int x, int y, int w, int h);
extern void blitScaled(SDL_Texture *t, int x, int y, int w, int h, int center);
extern char *getTranslatedString(char *string);
extern SDL_Texture *getTexture(char *filename);
extern void playSound(int id);