X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.cpp;h=57ff3270d170daab546e8c51c461bcb6195b5ba3;hb=0b11a24a8b08c49d6e4301573602fb6d01e7a8c8;hp=66097fbd46d05a8d5315196fb161fef1bc5a34cb;hpb=092a2dd175a4001a495c84ee85211734fb928c83;p=l2e.git diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 66097fb..57ff327 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -73,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); } @@ -111,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(); @@ -396,12 +400,11 @@ 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)); @@ -413,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)) { @@ -426,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()) { @@ -438,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); @@ -447,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); @@ -457,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);