From 0ef4dc19f03955b82d22330342acb179cf12b551 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 8 Aug 2012 14:47:09 +0200 Subject: [PATCH 1/1] added hero tag labels --- src/battle/BattleState.cpp | 2 +- src/battle/BattleState.h | 4 +++- src/battle/HeroTag.cpp | 18 ++++++++++++++++++ src/battle/HeroTag.h | 6 ++++-- src/main.cpp | 4 +++- test-data/hero-tag-sprites.png | Bin 0 -> 475 bytes 6 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 test-data/hero-tag-sprites.png diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index b1eaa4d..4053220 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -50,7 +50,7 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { heroesLayout->CalculatePositions(background->w, background->h, heroesPositions); attackChoices.resize(heroes.size()); for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { - heroTags.push_back(HeroTag(&heroes[i], &attackChoices[i], heroTagFrame, activeHeroTagFrame, healthGauge, manaGauge, ikariGauge, HeroTag::Alignment((i + 1) % 2))); + heroTags.push_back(HeroTag(&heroes[i], &attackChoices[i], heroTagFrame, activeHeroTagFrame, healthGauge, manaGauge, ikariGauge, heroTagSprites, HeroTag::Alignment((i + 1) % 2))); } } diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index b56b9fe..0e3436b 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -36,7 +36,7 @@ class BattleState : public app::State { public: - BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons, const graphics::Sprite *moveIcons, const graphics::Frame *heroTagFrame, const graphics::Frame *activeHeroTagFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge) + BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons, const graphics::Sprite *moveIcons, const graphics::Frame *heroTagFrame, const graphics::Frame *activeHeroTagFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge, const graphics::Sprite *heroTagSprites) : background(background) , monstersLayout(&monstersLayout) , heroesLayout(&heroesLayout) @@ -45,6 +45,7 @@ public: , healthGauge(healthGauge) , manaGauge(manaGauge) , ikariGauge(ikariGauge) + , heroTagSprites(heroTagSprites) , attackTypeMenu(attackIcons) , moveMenu(moveIcons) , activeHero(-1) { } @@ -98,6 +99,7 @@ private: const graphics::Gauge *healthGauge; const graphics::Gauge *manaGauge; const graphics::Gauge *ikariGauge; + const graphics::Sprite *heroTagSprites; AttackTypeMenu attackTypeMenu; MoveMenu moveMenu; std::vector > monsterPositions; diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 4c34402..a823749 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -47,6 +47,24 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point posi Vector ikariGaugeOffset(gaugeX, 4 * frameOffset.Y()); ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(gaugeWidth)); + // labels + int labelX((align == LEFT ? 5 : 1) * frameOffset.X()); + // level + Vector levelLabelOffset(gaugeX, frameOffset.Y()); + sprites->Draw(screen, position + levelLabelOffset, 0, 0); + // hp + Vector healthLabelOffset(labelX, 2 * frameOffset.Y()); + sprites->Draw(screen, position + healthLabelOffset, 0, 1); + // mp + Vector manaLabelOffset(labelX, 3 * frameOffset.Y()); + sprites->Draw(screen, position + manaLabelOffset, 0, 2); + // cm + Vector moveLabelOffset(labelX, 4 * frameOffset.Y()); + sprites->Draw(screen, position + moveLabelOffset, 0, 3); + // ip + Vector ikariLabelOffset(labelX + 3 * frameOffset.X(), 4 * frameOffset.Y()); + sprites->Draw(screen, position + ikariLabelOffset, 0, 4); + // hero Vector heroOffset( (align == LEFT) ? yOffset : width - hero->Sprite()->Width() - yOffset, diff --git a/src/battle/HeroTag.h b/src/battle/HeroTag.h index b5ab475..004d3ec 100644 --- a/src/battle/HeroTag.h +++ b/src/battle/HeroTag.h @@ -15,6 +15,7 @@ namespace graphics { class Frame; class Gauge; + class Sprite; } namespace battle { @@ -31,8 +32,8 @@ public: }; public: - HeroTag(const Hero *hero, const AttackChoice *choice, const graphics::Frame *frame, const graphics::Frame *activeFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge, Alignment align) - : hero(hero), choice(choice), frame(frame), activeFrame(activeFrame), healthGauge(healthGauge), manaGauge(manaGauge), ikariGauge(ikariGauge), align(align) { } + HeroTag(const Hero *hero, const AttackChoice *choice, const graphics::Frame *frame, const graphics::Frame *activeFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge, const graphics::Sprite *sprites, Alignment align) + : hero(hero), choice(choice), frame(frame), activeFrame(activeFrame), healthGauge(healthGauge), manaGauge(manaGauge), ikariGauge(ikariGauge), sprites(sprites), align(align) { } ~HeroTag() { } public: @@ -46,6 +47,7 @@ private: const graphics::Gauge *healthGauge; const graphics::Gauge *manaGauge; const graphics::Gauge *ikariGauge; + const graphics::Sprite *sprites; Alignment align; }; diff --git a/src/main.cpp b/src/main.cpp index c3d73cb..71a4afb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,6 +86,8 @@ int main(int argc, char **argv) { Sprite attackIconsSprite(attackIcons, 32, 32); SDL_Surface *moveIcons(IMG_Load("test-data/move-icons.png")); Sprite moveIconsSprite(moveIcons, 32, 32); + SDL_Surface *heroTagSprites(IMG_Load("test-data/hero-tag-sprites.png")); + Sprite heroTagSprite(heroTagSprites, 32, 16); SDL_Surface *tagFrames(IMG_Load("test-data/tag-frames.png")); Frame heroTagFrame(tagFrames, 16, 16, 1, 1, 0, 33); Frame activeHeroTagFrame(tagFrames, 16, 16); @@ -95,7 +97,7 @@ int main(int argc, char **argv) { Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6); Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6); - BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &attackIconsSprite, &moveIconsSprite, &heroTagFrame, &activeHeroTagFrame, &healthGauge, &manaGauge, &ikariGauge)); + BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &attackIconsSprite, &moveIconsSprite, &heroTagFrame, &activeHeroTagFrame, &healthGauge, &manaGauge, &ikariGauge, &heroTagSprite)); battleState->AddMonster(monster); battleState->AddMonster(monster); battleState->AddMonster(monster); diff --git a/test-data/hero-tag-sprites.png b/test-data/hero-tag-sprites.png new file mode 100644 index 0000000000000000000000000000000000000000..0a3fee995d61890244e4de445e7ca072466b33ea GIT binary patch literal 475 zcmV<10VMv3P)P*fL;o8iT0Q-5g?ZWUZ6vCnI1fV5AGo#5dD^t6|pcSh&Rg= z;{Wtb(F)V=SSTJ$hB45_ai`r_=GRd6?md@Owbb(es2{#Oz}9P=yN7H}pa&bQeNlffxFhiV8G<-JUQ)F2-VY!d3?wD_GVY&1 zN};A$=AmLFvN?fajUp?@3z2K8?e&DIdg0Ck#e2bu3dz-VL{{A~o4kfwdVp6dZ>%2} z=aGnr4!Z;9X!jfK2dO zeN4eMDn=qz5imJJ_U{3CGI>(X<+s)WcOK~f7xb|3Ks)CH0fDbmeB#4PrJrWm9zYVP zJeQQ@%ec$kkV`6}C=;cq7>T$fu>9u_y7NGB9Vo3AetW`OD_vw>KOgYvfgcI6tlxuN REsX#G002ovPDHLkV1mXJ)#m^J literal 0 HcmV?d00001 -- 2.39.2