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() {
// 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;
: 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 &);
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;
};
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);
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);