]> git.localhorst.tv Git - l2e.git/blob - src/main.cpp
better positioning of monsters
[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/Monster.h"
11 #include "battle/PartyLayout.h"
12 #include "geometry/Point.h"
13 #include "graphics/Sprite.h"
14 #include "sdl/InitScreen.h"
15 #include "sdl/InitSDL.h"
16
17 #include <exception>
18 #include <iostream>
19
20 using app::Application;
21 using battle::BattleState;
22 using battle::Monster;
23 using battle::PartyLayout;
24 using geometry::Point;
25 using graphics::Sprite;
26 using sdl::InitScreen;
27 using sdl::InitSDL;
28
29 using std::cerr;
30 using std::cout;
31 using std::endl;
32 using std::exception;
33
34 int main(int argc, char **argv) {
35         const int width = 800;
36         const int height = 480;
37
38         // temporary test data
39         SDL_Surface *bg(SDL_CreateRGBSurface(0, width, height, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
40         SDL_FillRect(bg, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
41         SDL_Rect r;
42         r.x = 1;
43         r.y = 1;
44         r.w = width - 2;
45         r.h = height - 2;
46         SDL_FillRect(bg, &r, SDL_MapRGB(bg->format, 0, 0, 0));
47         PartyLayout monstersLayout;
48         monstersLayout.AddPosition(Point<Uint8>(50, 100));
49         monstersLayout.AddPosition(Point<Uint8>(100, 100));
50         monstersLayout.AddPosition(Point<Uint8>(150, 100));
51         monstersLayout.AddPosition(Point<Uint8>(200, 100));
52         SDL_Surface *white100(SDL_CreateRGBSurface(0, 100, 100, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
53         SDL_FillRect(white100, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
54         Sprite dummyMonsterSprite(white100, 100, 100);
55         Monster monster;
56         monster.SetSprite(&dummyMonsterSprite);
57
58         try {
59                 InitSDL sdl;
60                 InitScreen screen(width, height);
61
62                 BattleState *battleState(new BattleState(bg, monstersLayout));
63                 battleState->AddMonster(monster);
64                 battleState->AddMonster(monster);
65                 battleState->AddMonster(monster);
66                 battleState->AddMonster(monster);
67                 Application app(screen.Screen(), battleState);
68                 app.Run();
69
70                 return 0;
71         } catch (exception &e) {
72                 cerr << "exception in main(): " << e.what() << endl;
73                 return 1;
74         }
75 }