#include "map/Map.h"
#include "map/MapState.h"
#include "map/Tile.h"
+#include "map/Trigger.h"
#include "sdl/InitImage.h"
#include "sdl/InitScreen.h"
#include "sdl/InitSDL.h"
using map::Map;
using map::MapState;
using map::Tile;
+using map::Trigger;
using sdl::InitImage;
using sdl::InitScreen;
using sdl::InitSDL;
const int width = 800;
const int height = 480;
+ const int tileSize = 32;
const float walkSpeed = 128.0f;
const bool battle(false);
tiles[62].SetOffset(Vector<int>(1, 1));
tiles[63].SetOffset(Vector<int>(1, 1));
- Area area;
- area.SetTiles(tiles, 64);
- area.SetWidth(8);
+ Area areas[1];
+ areas[0].SetTiles(tiles, 64);
+ areas[0].SetWidth(8);
+
+ Trigger triggers[1];
+ triggers[0].SetTilePosition(Vector<int>(2, 0));
SDL_Surface *tilesetImg(IMG_Load("test-data/tileset.png"));
- Sprite tileset(tilesetImg, 32, 32);
+ Sprite tileset(tilesetImg, tileSize, tileSize);
Map map;
- map.SetAreas(&area, 1);
+ map.SetAreas(areas, 1);
map.SetTileset(&tileset);
+ map.SetTriggers(triggers, 1);
map.SetWidth(1);
SDL_Surface *mapMaximImg(IMG_Load("test-data/maxim-map.png"));
Sprite mapMaximSprite(mapMaximImg, 32, 64);
+ SimpleAnimation mapMaximAnimation(&mapMaximSprite, (tileSize/walkSpeed) / 2 * 1000, 2, 0, 0, true);
Entity mapMaxim;
- mapMaxim.SetSprite(&mapMaximSprite);
- mapMaxim.Position() = Vector<float>(80, 160);
+ mapMaxim.SetAnimation(&mapMaximAnimation);
+ mapMaxim.Position() = Vector<float>(64, 128);
+ mapMaxim.SpriteOffset() = Vector<float>(0, -32);
+
+ SDL_Surface *mapSelanImg(IMG_Load("test-data/selan-map.png"));
+ Sprite mapSelanSprite(mapSelanImg, 32, 64);
+ SimpleAnimation mapSelanAnimation(&mapSelanSprite, (tileSize/walkSpeed) / 2 * 1000, 2, 0, 0, true);
+ Entity mapSelan;
+ mapSelan.SetAnimation(&mapSelanAnimation);
+ mapSelan.Position() = Vector<float>(64, 128);
+ mapSelan.SpriteOffset() = Vector<float>(0, -32);
+ mapSelan.SetFlags(Entity::FLAG_NONBLOCKING);
+ mapMaxim.AddFollower(&mapSelan);
+
+ SDL_Surface *mapGuyImg(IMG_Load("test-data/guy-map.png"));
+ Sprite mapGuySprite(mapGuyImg, 32, 64);
+ SimpleAnimation mapGuyAnimation(&mapGuySprite, (tileSize/walkSpeed) / 2 * 1000, 2, 0, 0, true);
+ Entity mapGuy;
+ mapGuy.SetAnimation(&mapGuyAnimation);
+ mapGuy.Position() = Vector<float>(64, 128);
+ mapGuy.SpriteOffset() = Vector<float>(0, -32);
+ mapGuy.SetFlags(Entity::FLAG_NONBLOCKING);
+ mapSelan.AddFollower(&mapGuy);
+
+ SDL_Surface *mapDekarImg(IMG_Load("test-data/dekar-map.png"));
+ Sprite mapDekarSprite(mapDekarImg, 32, 64);
+ SimpleAnimation mapDekarAnimation(&mapDekarSprite, (tileSize/walkSpeed) / 2 * 1000, 2, 0, 0, true);
+ Entity mapDekar;
+ mapDekar.SetAnimation(&mapDekarAnimation);
+ mapDekar.Position() = Vector<float>(64, 128);
+ mapDekar.SpriteOffset() = Vector<float>(0, -32);
+ mapDekar.SetFlags(Entity::FLAG_NONBLOCKING);
+ mapGuy.AddFollower(&mapDekar);
+
+ SDL_Surface *mapMonsterImg(IMG_Load("test-data/monster-map.png"));
+ Sprite mapMonsterSprite(mapMonsterImg, 32, 32);
+ SimpleAnimation mapMonsterAnimation(&mapMonsterSprite, 500, 2, 0, 0, true);
+ Entity mapMonster;
+ mapMonster.SetAnimation(&mapMonsterAnimation);
+ mapMonster.Position() = Vector<float>(64, 32);
+ mapMonster.SetOrientation(Entity::ORIENTATION_SOUTH);
InitScreen screen(width, height);
state = battleState;
} else {
MapState *mapState(new MapState(&map));
+
mapState->AddEntity(&mapMaxim);
+ mapState->AddEntity(&mapSelan);
+ mapState->AddEntity(&mapGuy);
+ mapState->AddEntity(&mapDekar);
+
mapState->ControlEntity(&mapMaxim);
mapState->SetWalkingSpeed(walkSpeed);
+
+ mapState->AddEntity(&mapMonster);
+ mapMonster.StartAnimation(*mapState);
+
state = mapState;
}