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/Frame.h"
16 #include "graphics/Gauge.h"
17 #include "graphics/Sprite.h"
18 #include "sdl/InitImage.h"
19 #include "sdl/InitScreen.h"
20 #include "sdl/InitSDL.h"
25 #include <SDL_image.h>
27 using app::Application;
29 using battle::BattleState;
31 using battle::Monster;
32 using battle::PartyLayout;
33 using geometry::Point;
34 using graphics::Frame;
35 using graphics::Gauge;
36 using graphics::Sprite;
38 using sdl::InitScreen;
46 int main(int argc, char **argv) {
47 const int width = 800;
48 const int height = 480;
52 InitImage image(IMG_INIT_PNG);
53 InitScreen screen(width, height);
55 // temporary test data
56 SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
57 PartyLayout monstersLayout;
58 monstersLayout.AddPosition(Point<Uint8>(50, 100));
59 monstersLayout.AddPosition(Point<Uint8>(100, 108));
60 monstersLayout.AddPosition(Point<Uint8>(150, 100));
61 monstersLayout.AddPosition(Point<Uint8>(200, 108));
62 PartyLayout heroesLayout;
63 heroesLayout.AddPosition(Point<Uint8>(27, 219));
64 heroesLayout.AddPosition(Point<Uint8>(104, 227));
65 heroesLayout.AddPosition(Point<Uint8>(66, 238));
66 heroesLayout.AddPosition(Point<Uint8>(143, 246));
68 SDL_Surface *monsterImg(IMG_Load("test-data/monster.png"));
69 Sprite dummySprite(monsterImg, 96, 96);
71 monster.SetSprite(&dummySprite);
73 SDL_Surface *heroImg(IMG_Load("test-data/hero.png"));
74 Sprite heroSprite(heroImg, 64, 64);
78 hero.SetSprite(&heroSprite);
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);
89 SDL_Surface *tagFrames(IMG_Load("test-data/tag-frames.png"));
90 Frame heroTagFrame(tagFrames, 16, 16, 1, 1, 0, 33);
91 Frame activeHeroTagFrame(tagFrames, 16, 16);
93 SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
94 Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
95 Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
96 Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
98 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &attackIconsSprite, &moveIconsSprite, &heroTagFrame, &activeHeroTagFrame, &healthGauge, &manaGauge, &ikariGauge));
99 battleState->AddMonster(monster);
100 battleState->AddMonster(monster);
101 battleState->AddMonster(monster);
102 battleState->AddMonster(monster);
103 battleState->AddHero(hero);
104 battleState->AddHero(hero);
105 battleState->AddHero(hero);
106 battleState->AddHero(hero);
107 Application app(&screen, battleState);
108 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
109 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
110 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
111 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
112 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
113 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
114 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
115 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
116 app.Buttons().MapKey(SDLK_RETURN, Input::START);
117 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
118 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
119 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
123 } catch (exception &e) {
124 cerr << "exception in main(): " << e.what() << endl;