X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=3ec99459014e6687127018e181b84b2c9b2bbea6;hb=d997e6743dfa0df245bc3f59ee97ecd63efb3c4f;hp=0fce8fe511640d4e9f3fdb7fa9feceaa224e7e1a;hpb=e411b1bbef7bc5bc383046e7bf294d2c5a17ac7e;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index 0fce8fe..3ec9945 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,84 @@ * Author: holy */ +#include "app/Application.h" +#include "battle/BattleState.h" +#include "battle/Hero.h" +#include "battle/Monster.h" +#include "battle/PartyLayout.h" +#include "geometry/Point.h" +#include "graphics/Sprite.h" +#include "sdl/InitScreen.h" +#include "sdl/InitSDL.h" + +#include +#include + +using app::Application; +using battle::BattleState; +using battle::Hero; +using battle::Monster; +using battle::PartyLayout; +using geometry::Point; +using graphics::Sprite; +using sdl::InitScreen; +using sdl::InitSDL; + +using std::cerr; +using std::cout; +using std::endl; +using std::exception; + int main(int argc, char **argv) { - return 0; + const int width = 800; + const int height = 480; + + // temporary test data + SDL_Surface *bg(SDL_CreateRGBSurface(0, width, height, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF)); + SDL_FillRect(bg, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF)); + SDL_Rect r; + r.x = 1; + r.y = 1; + r.w = width - 2; + r.h = height - 2; + SDL_FillRect(bg, &r, SDL_MapRGB(bg->format, 0, 0, 0)); + PartyLayout monstersLayout; + monstersLayout.AddPosition(Point(50, 100)); + monstersLayout.AddPosition(Point(100, 100)); + monstersLayout.AddPosition(Point(150, 100)); + monstersLayout.AddPosition(Point(200, 100)); + PartyLayout heroesLayout; + heroesLayout.AddPosition(Point(27, 219)); + heroesLayout.AddPosition(Point(104, 227)); + heroesLayout.AddPosition(Point(66, 238)); + heroesLayout.AddPosition(Point(143, 246)); + SDL_Surface *white96(SDL_CreateRGBSurface(0, 96, 96, 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF)); + SDL_FillRect(white96, 0, SDL_MapRGB(bg->format, 0xFF, 0xFF, 0xFF)); + Sprite dummySprite(white96, 96, 96); + Monster monster; + monster.SetSprite(&dummySprite); + Hero hero; + hero.SetSprite(&dummySprite); + + try { + InitSDL sdl; + InitScreen screen(width, height); + + BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout)); + battleState->AddMonster(monster); + battleState->AddMonster(monster); + battleState->AddMonster(monster); + battleState->AddMonster(monster); + battleState->AddHero(hero); + battleState->AddHero(hero); + battleState->AddHero(hero); + battleState->AddHero(hero); + Application app(&screen, battleState); + app.Run(); + + return 0; + } catch (exception &e) { + cerr << "exception in main(): " << e.what() << endl; + return 1; + } }