X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.cpp;h=57ff3270d170daab546e8c51c461bcb6195b5ba3;hb=0b11a24a8b08c49d6e4301573602fb6d01e7a8c8;hp=085a85371530678e0d578fa1fb8560aeb3299382;hpb=60e0fe29ce6cd033edc78b181d9d07fa72c11172;p=l2e.git diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 085a853..57ff327 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -12,6 +12,7 @@ #include "../common/Spell.h" #include "../graphics/Frame.h" #include "../graphics/Sprite.h" +#include "../math/Vector.h" #include #include @@ -24,7 +25,7 @@ using common::Inventory; using common::Item; using common::Spell; using common::Stats; -using geometry::Vector; +using math::Vector; using graphics::Menu; using std::rand; @@ -72,7 +73,9 @@ void BattleState::SwapHeroes(int lhs, int rhs) { void BattleState::OnResize(int w, int h) { - + offset = Vector( + (w - background->w) / 2, + (h - background->h) / 2); } @@ -110,6 +113,8 @@ void BattleState::OnEnterState(SDL_Surface *screen) { smallHeroTagPositions[2] = Vector(xOffset + tagWidth, yOffset); smallHeroTagPositions[3] = Vector(xOffset + 3 * tagWidth, yOffset); + OnResize(screen->w, screen->h); + itemMenu = *res->itemMenuProperties; LoadInventory(); ClearAllAttacks(); @@ -389,18 +394,17 @@ void BattleState::HandleEvents(const Input &input) { } -void BattleState::UpdateWorld(float deltaT) { +void BattleState::UpdateWorld(Uint32 deltaT) { } void BattleState::Render(SDL_Surface *screen) { assert(screen); - Vector offset(CalculateScreenOffset(screen)); - RenderBackground(screen, offset); - RenderMonsters(screen, offset); + RenderBackground(screen); + RenderMonsters(screen); } -void BattleState::RenderBackground(SDL_Surface *screen, const Vector &offset) { +void BattleState::RenderBackground(SDL_Surface *screen) { assert(screen); // black for now SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); @@ -412,7 +416,7 @@ void BattleState::RenderBackground(SDL_Surface *screen, const Vector &offse SDL_BlitSurface(background, 0, screen, &destRect); } -void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) { +void BattleState::RenderMonsters(SDL_Surface *screen) { assert(screen); for (vector::size_type i(0), end(monsters.size()); i < end; ++i) { if (MonsterPositionOccupied(i)) { @@ -425,7 +429,7 @@ void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) } } -void BattleState::RenderHeroes(SDL_Surface *screen, const Vector &offset) { +void BattleState::RenderHeroes(SDL_Surface *screen) { assert(screen); for (int i(0); i < numHeroes; ++i) { if (heroes[i].GetAnimation().Running()) { @@ -437,7 +441,7 @@ void BattleState::RenderHeroes(SDL_Surface *screen, const Vector &offset) { } } -void BattleState::RenderCapsule(SDL_Surface *screen, const Vector &offset) { +void BattleState::RenderCapsule(SDL_Surface *screen) { if (!capsule.Active() || capsule.Health() <= 0) return; if (capsule.GetAnimation().Running()) { capsule.GetAnimation().DrawCenter(screen, capsule.Position() + offset); @@ -446,7 +450,7 @@ void BattleState::RenderCapsule(SDL_Surface *screen, const Vector &offset) } } -void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector &offset) { +void BattleState::RenderHeroTags(SDL_Surface *screen) { assert(screen); int tagHeight(attackTypeMenu.Height()); int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2); @@ -456,7 +460,7 @@ void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector &offset) } } -void BattleState::RenderSmallHeroTags(SDL_Surface *screen, const Vector &offset) { +void BattleState::RenderSmallHeroTags(SDL_Surface *screen) { assert(screen); int tagHeight(res->normalFont->CharHeight() * 4 + res->smallHeroTagFrame->BorderHeight() * 2); int tagWidth(res->normalFont->CharWidth() * 6 + res->smallHeroTagFrame->BorderWidth() * 2);