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/InitScreen.h"
17 #include "sdl/InitSDL.h"
22 using app::Application;
24 using battle::BattleState;
26 using battle::Monster;
27 using battle::PartyLayout;
28 using geometry::Point;
29 using graphics::Sprite;
30 using sdl::InitScreen;
38 int main(int argc, char **argv) {
39 const int width = 800;
40 const int height = 480;
42 // temporary test data
43 SDL_Surface *bg(SDL_CreateRGBSurface(0, width, height, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
44 SDL_FillRect(bg, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
50 SDL_FillRect(bg, &r, SDL_MapRGB(bg->format, 0, 0, 0));
51 PartyLayout monstersLayout;
52 monstersLayout.AddPosition(Point<Uint8>(50, 100));
53 monstersLayout.AddPosition(Point<Uint8>(100, 100));
54 monstersLayout.AddPosition(Point<Uint8>(150, 100));
55 monstersLayout.AddPosition(Point<Uint8>(200, 100));
56 PartyLayout heroesLayout;
57 heroesLayout.AddPosition(Point<Uint8>(27, 219));
58 heroesLayout.AddPosition(Point<Uint8>(104, 227));
59 heroesLayout.AddPosition(Point<Uint8>(66, 238));
60 heroesLayout.AddPosition(Point<Uint8>(143, 246));
61 SDL_Surface *white96(SDL_CreateRGBSurface(0, 96, 96, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
62 SDL_FillRect(white96, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
63 Sprite dummySprite(white96, 96, 96);
65 monster.SetSprite(&dummySprite);
67 hero.SetSprite(&dummySprite);
71 InitScreen screen(width, height);
73 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout));
74 battleState->AddMonster(monster);
75 battleState->AddMonster(monster);
76 battleState->AddMonster(monster);
77 battleState->AddMonster(monster);
78 battleState->AddHero(hero);
79 battleState->AddHero(hero);
80 battleState->AddHero(hero);
81 battleState->AddHero(hero);
82 Application app(&screen, battleState);
83 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
84 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
85 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
86 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
87 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
88 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
89 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
90 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
91 app.Buttons().MapKey(SDLK_RETURN, Input::START);
92 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
93 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
94 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
98 } catch (exception &e) {
99 cerr << "exception in main(): " << e.what() << endl;