]> git.localhorst.tv Git - l2e.git/blob - src/main.cpp
added monster drawing routine in battle state
[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, 0, 0, 0));
41         PartyLayout monstersLayout;
42         monstersLayout.AddPosition(Point<Uint8>(50, 50));
43         monstersLayout.AddPosition(Point<Uint8>(100, 50));
44         monstersLayout.AddPosition(Point<Uint8>(150, 50));
45         monstersLayout.AddPosition(Point<Uint8>(200, 50));
46         SDL_Surface *white100(SDL_CreateRGBSurface(0, 100, 100, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF));
47         SDL_FillRect(white100, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF));
48         Sprite dummyMonsterSprite(white100, 100, 100);
49         Monster monster;
50         monster.SetSprite(&dummyMonsterSprite);
51
52         try {
53                 InitSDL sdl;
54                 InitScreen screen(width, height);
55
56                 BattleState *battleState(new BattleState(bg, monstersLayout));
57                 battleState->AddMonster(monster);
58                 battleState->AddMonster(monster);
59                 battleState->AddMonster(monster);
60                 battleState->AddMonster(monster);
61                 Application app(screen.Screen(), battleState);
62                 app.Run();
63
64                 return 0;
65         } catch (exception &e) {
66                 cerr << "exception in main(): " << e.what() << endl;
67                 return 1;
68         }
69 }