]> git.localhorst.tv Git - l2e.git/commitdiff
added heroes' party layout to battle state
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 6 Aug 2012 11:18:00 +0000 (13:18 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 6 Aug 2012 11:18:00 +0000 (13:18 +0200)
src/battle/BattleState.cpp
src/battle/BattleState.h
src/main.cpp

index 21de625354487e21694bba6bdf853271c8903405..d1a983f23d198787daef4af3aac198e1d08db759 100644 (file)
@@ -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;
 
index 52238ebe5d3594b964cd656aa10bd5094e793e51..06b8fbd8291fbf3cd41136013d901da28028b3aa 100644 (file)
@@ -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<geometry::Point<int> > monsterPositions;
+       std::vector<geometry::Point<int> > heroesPositions;
        std::vector<Monster> monsters;
-       int width;
-       int height;
 
 };
 
index 8f92a357dacb74830cd0350cc15ec55149c09c17..2ecdbb64ed02e100d4083b949a0033498b9441e7 100644 (file)
@@ -49,6 +49,11 @@ int main(int argc, char **argv) {
        monstersLayout.AddPosition(Point<Uint8>(100, 100));
        monstersLayout.AddPosition(Point<Uint8>(150, 100));
        monstersLayout.AddPosition(Point<Uint8>(200, 100));
+       PartyLayout heroesLayout;
+       heroesLayout.AddPosition(Point<Uint8>(45, 132));
+       heroesLayout.AddPosition(Point<Uint8>(174, 136));
+       heroesLayout.AddPosition(Point<Uint8>(110, 143));
+       heroesLayout.AddPosition(Point<Uint8>(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);