]> git.localhorst.tv Git - l2e.git/commitdiff
added test tileset, area and map
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 29 Sep 2012 19:02:34 +0000 (21:02 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 29 Sep 2012 19:02:34 +0000 (21:02 +0200)
src/main.cpp
test-data/tileset.png [new file with mode: 0644]

index a2cdae9da96f38112252ece108446c12c9153dc4..0a6882a5c4187897f46697d5b34e2337c6d2e744 100644 (file)
 #include "loader/ParsedSource.h"
 #include "loader/Parser.h"
 #include "loader/TypeDescription.h"
+#include "map/Area.h"
+#include "map/Map.h"
+#include "map/MapState.h"
+#include "map/Tile.h"
 #include "sdl/InitImage.h"
 #include "sdl/InitScreen.h"
 #include "sdl/InitSDL.h"
@@ -69,6 +73,10 @@ using loader::Interpreter;
 using loader::ParsedSource;
 using loader::Parser;
 using loader::TypeDescription;
+using map::Area;
+using map::Map;
+using map::MapState;
+using map::Tile;
 using sdl::InitImage;
 using sdl::InitScreen;
 using sdl::InitSDL;
@@ -224,8 +232,96 @@ int main(int argc, char **argv) {
                dekar.SetRing(caster.GetItem("rocketRingItem"));
                dekar.SetJewel(caster.GetItem("krakenRockItem"));
 
+               Tile tiles[64];
+
+               tiles[ 0].SetOffset(Vector<int>(2, 1));
+               tiles[ 1].SetOffset(Vector<int>(4, 0));
+               tiles[ 2].SetOffset(Vector<int>(3, 0));
+               tiles[ 3].SetOffset(Vector<int>(3, 0));
+               tiles[ 4].SetOffset(Vector<int>(0, 1));
+               tiles[ 5].SetOffset(Vector<int>(2, 0));
+               tiles[ 6].SetOffset(Vector<int>(2, 0));
+               tiles[ 7].SetOffset(Vector<int>(2, 0));
+
+               tiles[ 8].SetOffset(Vector<int>(2, 1));
+               tiles[ 9].SetOffset(Vector<int>(4, 0));
+               tiles[10].SetOffset(Vector<int>(3, 0));
+               tiles[11].SetOffset(Vector<int>(3, 0));
+               tiles[12].SetOffset(Vector<int>(0, 2));
+               tiles[13].SetOffset(Vector<int>(1, 2));
+               tiles[14].SetOffset(Vector<int>(1, 2));
+               tiles[15].SetOffset(Vector<int>(1, 2));
+
+               tiles[16].SetOffset(Vector<int>(2, 1));
+               tiles[17].SetOffset(Vector<int>(4, 0));
+               tiles[18].SetOffset(Vector<int>(3, 0));
+               tiles[19].SetOffset(Vector<int>(3, 0));
+               tiles[20].SetOffset(Vector<int>(0, 3));
+               tiles[21].SetOffset(Vector<int>(1, 3));
+               tiles[22].SetOffset(Vector<int>(1, 3));
+               tiles[23].SetOffset(Vector<int>(2, 3));
+
+               tiles[24].SetOffset(Vector<int>(2, 1));
+               tiles[25].SetOffset(Vector<int>(4, 0));
+               tiles[26].SetOffset(Vector<int>(3, 0));
+               tiles[27].SetOffset(Vector<int>(3, 0));
+               tiles[28].SetOffset(Vector<int>(0, 4));
+               tiles[29].SetOffset(Vector<int>(1, 4));
+               tiles[30].SetOffset(Vector<int>(1, 4));
+               tiles[31].SetOffset(Vector<int>(2, 4));
+
+               tiles[32].SetOffset(Vector<int>(2, 1));
+               tiles[33].SetOffset(Vector<int>(4, 0));
+               tiles[34].SetOffset(Vector<int>(3, 0));
+               tiles[35].SetOffset(Vector<int>(3, 0));
+               tiles[36].SetOffset(Vector<int>(3, 0));
+               tiles[37].SetOffset(Vector<int>(3, 0));
+               tiles[38].SetOffset(Vector<int>(3, 0));
+               tiles[39].SetOffset(Vector<int>(3, 0));
+
+               tiles[40].SetOffset(Vector<int>(2, 1));
+               tiles[41].SetOffset(Vector<int>(4, 0));
+               tiles[42].SetOffset(Vector<int>(3, 0));
+               tiles[43].SetOffset(Vector<int>(3, 0));
+               tiles[44].SetOffset(Vector<int>(3, 0));
+               tiles[45].SetOffset(Vector<int>(4, 0));
+               tiles[46].SetOffset(Vector<int>(4, 0));
+               tiles[47].SetOffset(Vector<int>(4, 0));
+
+               tiles[48].SetOffset(Vector<int>(2, 1));
+               tiles[49].SetOffset(Vector<int>(4, 0));
+               tiles[50].SetOffset(Vector<int>(3, 0));
+               tiles[51].SetOffset(Vector<int>(3, 0));
+               tiles[52].SetOffset(Vector<int>(0, 0));
+               tiles[53].SetOffset(Vector<int>(1, 0));
+               tiles[54].SetOffset(Vector<int>(1, 0));
+               tiles[55].SetOffset(Vector<int>(1, 0));
+
+               tiles[56].SetOffset(Vector<int>(2, 1));
+               tiles[57].SetOffset(Vector<int>(4, 0));
+               tiles[58].SetOffset(Vector<int>(3, 0));
+               tiles[59].SetOffset(Vector<int>(3, 0));
+               tiles[60].SetOffset(Vector<int>(0, 1));
+               tiles[61].SetOffset(Vector<int>(1, 1));
+               tiles[62].SetOffset(Vector<int>(1, 1));
+               tiles[63].SetOffset(Vector<int>(1, 1));
+
+               Area area;
+               area.SetTiles(tiles, 64);
+               area.SetWidth(8);
+
+               SDL_Surface *tilesetImg(IMG_Load("test-data/tileset.png"));
+               Sprite tileset(tilesetImg, 32, 32);
+
+               Map map;
+               map.SetAreas(&area, 1);
+               map.SetTileset(&tileset);
+               map.SetWidth(1);
+
                InitScreen screen(width, height);
 
+               app::State *state(0);
+
                if (battle) {
                        BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, battleRes));
                        battleState->AddMonster(monster);
@@ -236,24 +332,27 @@ int main(int argc, char **argv) {
                        battleState->AddHero(selan);
                        battleState->AddHero(guy);
                        battleState->AddHero(dekar);
-                       Application app(&screen, battleState);
-                       app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
-                       app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
-                       app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
-                       app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
-                       app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
-                       app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
-                       app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
-                       app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
-                       app.Buttons().MapKey(SDLK_RETURN, Input::START);
-                       app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
-                       app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
-                       app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
-                       app.Run();
+                       state = battleState;
                } else {
-
+                       MapState *mapState(new MapState(&map));
+                       state = mapState;
                }
 
+               Application app(&screen, state);
+               app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
+               app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
+               app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
+               app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
+               app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
+               app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
+               app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
+               app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
+               app.Buttons().MapKey(SDLK_RETURN, Input::START);
+               app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
+               app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
+               app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
+               app.Run();
+
                return 0;
        } catch (Parser::Error &e) {
                cerr << "parsing exception in file " << e.File() << " on line " << e.Line() << ": " << e.what() << endl;
diff --git a/test-data/tileset.png b/test-data/tileset.png
new file mode 100644 (file)
index 0000000..299f94f
Binary files /dev/null and b/test-data/tileset.png differ