4 * Created on: Aug 1, 2012
8 #include "app/Application.h"
10 #include "battle/BattleState.h"
11 #include "battle/Hero.h"
12 #include "battle/Monster.h"
13 #include "battle/PartyLayout.h"
14 #include "geometry/Point.h"
15 #include "graphics/Sprite.h"
16 #include "sdl/InitImage.h"
17 #include "sdl/InitScreen.h"
18 #include "sdl/InitSDL.h"
23 #include <SDL_image.h>
25 using app::Application;
27 using battle::BattleState;
29 using battle::Monster;
30 using battle::PartyLayout;
31 using geometry::Point;
32 using graphics::Sprite;
34 using sdl::InitScreen;
42 int main(int argc, char **argv) {
43 const int width = 800;
44 const int height = 480;
48 InitImage image(IMG_INIT_PNG);
49 InitScreen screen(width, height);
51 // temporary test data
52 SDL_Surface *bg(SDL_CreateRGBSurface(0, width, height, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
53 SDL_FillRect(bg, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
59 SDL_FillRect(bg, &r, SDL_MapRGB(bg->format, 0, 0, 0));
60 PartyLayout monstersLayout;
61 monstersLayout.AddPosition(Point<Uint8>(50, 100));
62 monstersLayout.AddPosition(Point<Uint8>(100, 100));
63 monstersLayout.AddPosition(Point<Uint8>(150, 100));
64 monstersLayout.AddPosition(Point<Uint8>(200, 100));
65 PartyLayout heroesLayout;
66 heroesLayout.AddPosition(Point<Uint8>(27, 219));
67 heroesLayout.AddPosition(Point<Uint8>(104, 227));
68 heroesLayout.AddPosition(Point<Uint8>(66, 238));
69 heroesLayout.AddPosition(Point<Uint8>(143, 246));
70 SDL_Surface *white96(SDL_CreateRGBSurface(0, 96, 96, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
71 SDL_FillRect(white96, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
72 Sprite dummySprite(white96, 96, 96);
74 monster.SetSprite(&dummySprite);
78 hero.SetSprite(&dummySprite);
79 hero.SetMaxHealth(100);
85 SDL_Surface *attackIcons(IMG_Load("test-data/attack-type-icons.png"));
86 Sprite attackIconsSprite(attackIcons, 32, 32);
87 SDL_Surface *moveIcons(IMG_Load("test-data/move-icons.png"));
88 Sprite moveIconsSprite(moveIcons, 32, 32);
90 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &attackIconsSprite, &moveIconsSprite));
91 battleState->AddMonster(monster);
92 battleState->AddMonster(monster);
93 battleState->AddMonster(monster);
94 battleState->AddMonster(monster);
95 battleState->AddHero(hero);
96 battleState->AddHero(hero);
97 battleState->AddHero(hero);
98 battleState->AddHero(hero);
99 Application app(&screen, battleState);
100 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
101 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
102 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
103 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
104 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
105 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
106 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
107 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
108 app.Buttons().MapKey(SDLK_RETURN, Input::START);
109 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
110 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
111 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
115 } catch (exception &e) {
116 cerr << "exception in main(): " << e.what() << endl;