From: Daniel Karbach Date: Mon, 6 Aug 2012 11:18:00 +0000 (+0200) Subject: added heroes' party layout to battle state X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=e1b949217f6cf25cb080e514a5f6a40935f0c8fa;p=l2e.git added heroes' party layout to battle state --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 21de625..d1a983f 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -28,15 +28,13 @@ void BattleState::AddMonster(const Monster &m) { void BattleState::Resize(int w, int h) { - width = w; - height = h; + } void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { monstersLayout->CalculatePositions(background->w, background->h, monsterPositions); - width = screen->w; - height = screen->h; + heroesLayout->CalculatePositions(background->w, background->h, heroesPositions); } void BattleState::ExitState() { @@ -56,8 +54,8 @@ void BattleState::Render(SDL_Surface *screen) { // black for now SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); SDL_Rect destRect; - destRect.x = (width - background->w) / 2; - destRect.y = (height - background->h) / 2; + destRect.x = (screen->w - background->w) / 2; + destRect.y = (screen->h - background->h) / 2; destRect.w = background->w; destRect.h = background->h; diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 52238eb..06b8fbd 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -23,11 +23,10 @@ class BattleState : public app::State { public: - BattleState(SDL_Surface *background, const PartyLayout &monstersLayout) + BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout) : background(background) , monstersLayout(&monstersLayout) - , width(0) - , height(0) { } + , heroesLayout(&heroesLayout) { } public: void AddMonster(const Monster &); @@ -45,10 +44,10 @@ public: private: SDL_Surface *background; const PartyLayout *monstersLayout; + const PartyLayout *heroesLayout; std::vector > monsterPositions; + std::vector > heroesPositions; std::vector monsters; - int width; - int height; }; diff --git a/src/main.cpp b/src/main.cpp index 8f92a35..2ecdbb6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,11 @@ int main(int argc, char **argv) { monstersLayout.AddPosition(Point(100, 100)); monstersLayout.AddPosition(Point(150, 100)); monstersLayout.AddPosition(Point(200, 100)); + PartyLayout heroesLayout; + heroesLayout.AddPosition(Point(45, 132)); + heroesLayout.AddPosition(Point(174, 136)); + heroesLayout.AddPosition(Point(110, 143)); + heroesLayout.AddPosition(Point(239, 148)); SDL_Surface *white100(SDL_CreateRGBSurface(0, 100, 100, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF)); SDL_FillRect(white100, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF)); Sprite dummyMonsterSprite(white100, 100, 100); @@ -59,7 +64,7 @@ int main(int argc, char **argv) { InitSDL sdl; InitScreen screen(width, height); - BattleState *battleState(new BattleState(bg, monstersLayout)); + BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout)); battleState->AddMonster(monster); battleState->AddMonster(monster); battleState->AddMonster(monster);