From cf20874f973521e84fc2aaa6cd47c56a278d9de7 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 8 Aug 2012 13:44:46 +0200 Subject: [PATCH] changed gauge level interpretation also added an original monster sprite --- src/battle/HeroTag.cpp | 6 +++--- src/graphics/Gauge.cpp | 3 +-- src/graphics/Gauge.h | 2 +- src/main.cpp | 12 ++++++------ test-data/monster.png | Bin 3000 -> 971 bytes 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 851e88e..4c34402 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -39,13 +39,13 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point posi int gaugeWidth(width - gaugeX - (align == LEFT ? 1 : 5) * frameOffset.X()); // health gauge, second line Vector healthGaugeOffset(gaugeX, 2 * frameOffset.Y()); - healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero->RelativeHealth(256)); + healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero->RelativeHealth(gaugeWidth)); // mana gauge, third line Vector manaGaugeOffset(gaugeX, 3 * frameOffset.Y()); - manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero->RelativeMana(256)); + manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero->RelativeMana(gaugeWidth)); // ikari gauge, fourth line Vector ikariGaugeOffset(gaugeX, 4 * frameOffset.Y()); - ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(256)); + ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(gaugeWidth)); // hero Vector heroOffset( diff --git a/src/graphics/Gauge.cpp b/src/graphics/Gauge.cpp index 042dc27..65535f5 100644 --- a/src/graphics/Gauge.cpp +++ b/src/graphics/Gauge.cpp @@ -12,8 +12,7 @@ using geometry::Point; namespace graphics { // TODO: add start and end "ignore" offsets -void Gauge::Draw(SDL_Surface *dest, Point position, int width, Uint8 level) const { - int fullWidth(width * level / 255); +void Gauge::Draw(SDL_Surface *dest, Point position, int width, int fullWidth) const { SDL_Rect srcRect, destRect; // start diff --git a/src/graphics/Gauge.h b/src/graphics/Gauge.h index dde1db0..95b4b5b 100644 --- a/src/graphics/Gauge.h +++ b/src/graphics/Gauge.h @@ -23,7 +23,7 @@ public: public: int MinWidth() const { return startWidth + endWidth; } int Height() const { return height; } - void Draw(SDL_Surface *dest, geometry::Point position, int width, Uint8 level) const; + void Draw(SDL_Surface *dest, geometry::Point position, int width, int filled) const; private: SDL_Surface *surface; diff --git a/src/main.cpp b/src/main.cpp index e230433..ab02016 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,10 +55,10 @@ int main(int argc, char **argv) { // temporary test data SDL_Surface *bg(IMG_Load("test-data/battle-bg.png")); PartyLayout monstersLayout; - monstersLayout.AddPosition(Point(50, 100)); - monstersLayout.AddPosition(Point(100, 108)); - monstersLayout.AddPosition(Point(150, 100)); - monstersLayout.AddPosition(Point(200, 108)); + monstersLayout.AddPosition(Point(104, 109)); + monstersLayout.AddPosition(Point(140, 118)); + monstersLayout.AddPosition(Point(176, 109)); + monstersLayout.AddPosition(Point(212, 118)); PartyLayout heroesLayout; heroesLayout.AddPosition(Point(27, 219)); heroesLayout.AddPosition(Point(104, 227)); @@ -66,7 +66,7 @@ int main(int argc, char **argv) { heroesLayout.AddPosition(Point(143, 246)); SDL_Surface *monsterImg(IMG_Load("test-data/monster.png")); - Sprite dummySprite(monsterImg, 96, 96); + Sprite dummySprite(monsterImg, 64, 64); Monster monster; monster.SetSprite(&dummySprite); @@ -79,7 +79,7 @@ int main(int argc, char **argv) { hero.SetMaxHealth(100); hero.SetHealth(50); hero.SetMaxMana(100); - hero.SetMana(0); + hero.SetMana(100); hero.SetIP(255); SDL_Surface *attackIcons(IMG_Load("test-data/attack-type-icons.png")); diff --git a/test-data/monster.png b/test-data/monster.png index 2a76e9aae73f47adb4dba85b1f617f9f0971b320..94391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