From 7547e14c9fcc6c692f73066ce3b19c025a93bd1a Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 22 Jul 2016 11:07:35 +0100 Subject: [PATCH] Scale shield effect size, to better match ship (mostly for supply ships). --- src/battle/battle.c | 5 +++-- src/battle/battle.h | 2 +- src/battle/effects.c | 10 ++++++---- src/battle/effects.h | 2 +- src/draw/draw.c | 10 ++++++++-- src/game/trophies.c | 6 +++--- src/game/trophies.h | 2 +- 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/battle/battle.c b/src/battle/battle.c index e77d471..fb14bf5 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -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); } diff --git a/src/battle/battle.h b/src/battle/battle.h index aa34abd..5ccb899 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -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); diff --git a/src/battle/effects.c b/src/battle/effects.c index 2211698..30da648 100644 --- a/src/battle/effects.c +++ b/src/battle/effects.c @@ -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) diff --git a/src/battle/effects.h b/src/battle/effects.h index f5da065..56ebec0 100644 --- a/src/battle/effects.h +++ b/src/battle/effects.h @@ -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); diff --git a/src/draw/draw.c b/src/draw/draw.c index a638c70..100ddfb 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -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; @@ -90,6 +90,12 @@ void blitScaled(SDL_Texture *texture, int x, int y, int w, int h) dstRect.y = y; 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); } } diff --git a/src/game/trophies.c b/src/game/trophies.c index 18e7d62..fe3290b 100644 --- a/src/game/trophies.c +++ b/src/game/trophies.c @@ -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); } } diff --git a/src/game/trophies.h b/src/game/trophies.h index eeedfb2..c62f4b8 100644 --- a/src/game/trophies.h +++ b/src/game/trophies.h @@ -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);