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>(88, 104));
59 monstersLayout.AddPosition(Point<Uint8>(128, 104));
60 monstersLayout.AddPosition(Point<Uint8>(168, 104));
61 monstersLayout.AddPosition(Point<Uint8>(208, 104));
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, 64, 64);
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 *heroTagSprites(IMG_Load("test-data/hero-tag-sprites.png"));
90 Sprite heroTagSprite(heroTagSprites, 32, 16);
91 SDL_Surface *tagFrames(IMG_Load("test-data/tag-frames.png"));
92 Frame heroTagFrame(tagFrames, 16, 16, 1, 1, 0, 33);
93 Frame activeHeroTagFrame(tagFrames, 16, 16);
95 SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
96 Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
97 Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
98 Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
100 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &attackIconsSprite, &moveIconsSprite, &heroTagFrame, &activeHeroTagFrame, &healthGauge, &manaGauge, &ikariGauge, &heroTagSprite));
101 battleState->AddMonster(monster);
102 battleState->AddMonster(monster);
103 battleState->AddMonster(monster);
104 battleState->AddMonster(monster);
105 battleState->AddHero(hero);
106 battleState->AddHero(hero);
107 battleState->AddHero(hero);
108 battleState->AddHero(hero);
109 Application app(&screen, battleState);
110 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
111 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
112 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
113 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
114 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
115 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
116 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
117 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
118 app.Buttons().MapKey(SDLK_RETURN, Input::START);
119 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
120 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
121 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
125 } catch (exception &e) {
126 cerr << "exception in main(): " << e.what() << endl;