]> git.localhorst.tv Git - l2e.git/blob - src/main.cpp
added basic vector class + a small set of operators
[l2e.git] / src / main.cpp
1 /*
2  * main.cpp
3  *
4  *  Created on: Aug 1, 2012
5  *      Author: holy
6  */
7
8 #include "app/Application.h"
9 #include "battle/BattleState.h"
10 #include "battle/Hero.h"
11 #include "battle/Monster.h"
12 #include "battle/PartyLayout.h"
13 #include "geometry/Point.h"
14 #include "graphics/Sprite.h"
15 #include "sdl/InitScreen.h"
16 #include "sdl/InitSDL.h"
17
18 #include <exception>
19 #include <iostream>
20
21 using app::Application;
22 using battle::BattleState;
23 using battle::Hero;
24 using battle::Monster;
25 using battle::PartyLayout;
26 using geometry::Point;
27 using graphics::Sprite;
28 using sdl::InitScreen;
29 using sdl::InitSDL;
30
31 using std::cerr;
32 using std::cout;
33 using std::endl;
34 using std::exception;
35
36 int main(int argc, char **argv) {
37         const int width = 800;
38         const int height = 480;
39
40         // temporary test data
41         SDL_Surface *bg(SDL_CreateRGBSurface(0, width, height, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
42         SDL_FillRect(bg, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
43         SDL_Rect r;
44         r.x = 1;
45         r.y = 1;
46         r.w = width - 2;
47         r.h = height - 2;
48         SDL_FillRect(bg, &r, SDL_MapRGB(bg->format, 0, 0, 0));
49         PartyLayout monstersLayout;
50         monstersLayout.AddPosition(Point<Uint8>(50, 100));
51         monstersLayout.AddPosition(Point<Uint8>(100, 100));
52         monstersLayout.AddPosition(Point<Uint8>(150, 100));
53         monstersLayout.AddPosition(Point<Uint8>(200, 100));
54         PartyLayout heroesLayout;
55         heroesLayout.AddPosition(Point<Uint8>(27, 219));
56         heroesLayout.AddPosition(Point<Uint8>(104, 227));
57         heroesLayout.AddPosition(Point<Uint8>(66, 238));
58         heroesLayout.AddPosition(Point<Uint8>(143, 246));
59         SDL_Surface *white96(SDL_CreateRGBSurface(0, 96, 96, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
60         SDL_FillRect(white96, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
61         Sprite dummySprite(white96, 96, 96);
62         Monster monster;
63         monster.SetSprite(&dummySprite);
64         Hero hero;
65         hero.SetSprite(&dummySprite);
66
67         try {
68                 InitSDL sdl;
69                 InitScreen screen(width, height);
70
71                 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout));
72                 battleState->AddMonster(monster);
73                 battleState->AddMonster(monster);
74                 battleState->AddMonster(monster);
75                 battleState->AddMonster(monster);
76                 battleState->AddHero(hero);
77                 battleState->AddHero(hero);
78                 battleState->AddHero(hero);
79                 battleState->AddHero(hero);
80                 Application app(&screen, battleState);
81                 app.Run();
82
83                 return 0;
84         } catch (exception &e) {
85                 cerr << "exception in main(): " << e.what() << endl;
86                 return 1;
87         }
88 }