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/Font.h"
16 #include "graphics/Frame.h"
17 #include "graphics/Gauge.h"
18 #include "graphics/Sprite.h"
19 #include "sdl/InitImage.h"
20 #include "sdl/InitScreen.h"
21 #include "sdl/InitSDL.h"
26 #include <SDL_image.h>
28 using app::Application;
30 using battle::BattleState;
32 using battle::Monster;
33 using battle::PartyLayout;
34 using geometry::Point;
36 using graphics::Frame;
37 using graphics::Gauge;
38 using graphics::Sprite;
40 using sdl::InitScreen;
48 int main(int argc, char **argv) {
49 const int width = 800;
50 const int height = 480;
54 InitImage image(IMG_INIT_PNG);
55 InitScreen screen(width, height);
57 // temporary test data
58 SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
59 PartyLayout monstersLayout;
60 monstersLayout.AddPosition(Point<Uint8>(88, 104));
61 monstersLayout.AddPosition(Point<Uint8>(128, 104));
62 monstersLayout.AddPosition(Point<Uint8>(168, 104));
63 monstersLayout.AddPosition(Point<Uint8>(208, 104));
64 PartyLayout heroesLayout;
65 heroesLayout.AddPosition(Point<Uint8>(27, 219));
66 heroesLayout.AddPosition(Point<Uint8>(104, 227));
67 heroesLayout.AddPosition(Point<Uint8>(66, 238));
68 heroesLayout.AddPosition(Point<Uint8>(143, 246));
70 SDL_Surface *monsterImg(IMG_Load("test-data/monster.png"));
71 Sprite dummySprite(monsterImg, 64, 64);
73 monster.SetSprite(&dummySprite);
75 SDL_Surface *maximImg(IMG_Load("test-data/maxim.png"));
76 Sprite maximSprite(maximImg, 64, 64);
78 maxim.SetName("Maxim");
80 maxim.SetSprite(&maximSprite);
81 maxim.SetMaxHealth(33);
87 SDL_Surface *selanImg(IMG_Load("test-data/selan.png"));
88 Sprite selanSprite(selanImg, 64, 64);
90 selan.SetName("Selan");
92 selan.SetSprite(&selanSprite);
93 selan.SetMaxHealth(28);
99 SDL_Surface *guyImg(IMG_Load("test-data/guy.png"));
100 Sprite guySprite(guyImg, 64, 64);
104 guy.SetSprite(&guySprite);
105 guy.SetMaxHealth(38);
111 SDL_Surface *dekarImg(IMG_Load("test-data/dekar.png"));
112 Sprite dekarSprite(dekarImg, 64, 64);
114 dekar.SetName("Dekar");
116 dekar.SetSprite(&dekarSprite);
117 dekar.SetMaxHealth(38);
123 SDL_Surface *attackIcons(IMG_Load("test-data/attack-type-icons.png"));
124 Sprite attackIconsSprite(attackIcons, 32, 32);
125 SDL_Surface *moveIcons(IMG_Load("test-data/move-icons.png"));
126 Sprite moveIconsSprite(moveIcons, 32, 32);
127 SDL_Surface *heroTagSprites(IMG_Load("test-data/hero-tag-sprites.png"));
128 Sprite heroTagSprite(heroTagSprites, 32, 16);
129 SDL_Surface *numbers(IMG_Load("test-data/numbers.png"));
130 Sprite numbersSprite(numbers, 16, 16);
131 Font heroTagFont(&numbersSprite);
132 SDL_Surface *tagFrames(IMG_Load("test-data/tag-frames.png"));
133 Frame heroTagFrame(tagFrames, 16, 16, 1, 1, 0, 33);
134 Frame activeHeroTagFrame(tagFrames, 16, 16);
136 SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
137 Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
138 Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
139 Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
141 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &attackIconsSprite, &moveIconsSprite, &heroTagFrame, &activeHeroTagFrame, &healthGauge, &manaGauge, &ikariGauge, &heroTagSprite, &heroTagFont));
142 battleState->AddMonster(monster);
143 battleState->AddMonster(monster);
144 battleState->AddMonster(monster);
145 battleState->AddMonster(monster);
146 battleState->AddHero(maxim);
147 battleState->AddHero(selan);
148 battleState->AddHero(guy);
149 battleState->AddHero(dekar);
150 Application app(&screen, battleState);
151 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
152 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
153 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
154 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
155 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
156 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
157 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
158 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
159 app.Buttons().MapKey(SDLK_RETURN, Input::START);
160 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
161 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
162 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
166 } catch (exception &e) {
167 cerr << "exception in main(): " << e.what() << endl;