From: Daniel Karbach Date: Tue, 9 Oct 2012 20:43:37 +0000 (+0200) Subject: closed the gap between battle and map state (yay) X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=0ad5ca97b5df217329bc319d62564a9f46ba11d7;p=l2e.git closed the gap between battle and map state (yay) also introduces a GameConfig struct that should hold all global game data --- diff --git a/Debug/src/common/subdir.mk b/Debug/src/common/subdir.mk index 78f304e..e0e6bd3 100644 --- a/Debug/src/common/subdir.mk +++ b/Debug/src/common/subdir.mk @@ -4,6 +4,7 @@ # Add inputs and outputs from these tool invocations to the build variables CPP_SRCS += \ +../src/common/GameConfig.cpp \ ../src/common/GameState.cpp \ ../src/common/Hero.cpp \ ../src/common/Ikari.cpp \ @@ -14,6 +15,7 @@ CPP_SRCS += \ ../src/common/TargetingMode.cpp OBJS += \ +./src/common/GameConfig.o \ ./src/common/GameState.o \ ./src/common/Hero.o \ ./src/common/Ikari.o \ @@ -24,6 +26,7 @@ OBJS += \ ./src/common/TargetingMode.o CPP_DEPS += \ +./src/common/GameConfig.d \ ./src/common/GameState.d \ ./src/common/Hero.d \ ./src/common/Ikari.d \ diff --git a/Release/src/common/subdir.mk b/Release/src/common/subdir.mk index 910092d..cc64cb3 100644 --- a/Release/src/common/subdir.mk +++ b/Release/src/common/subdir.mk @@ -4,6 +4,7 @@ # Add inputs and outputs from these tool invocations to the build variables CPP_SRCS += \ +../src/common/GameConfig.cpp \ ../src/common/GameState.cpp \ ../src/common/Hero.cpp \ ../src/common/Ikari.cpp \ @@ -14,6 +15,7 @@ CPP_SRCS += \ ../src/common/TargetingMode.cpp OBJS += \ +./src/common/GameConfig.o \ ./src/common/GameState.o \ ./src/common/Hero.o \ ./src/common/Ikari.o \ @@ -24,6 +26,7 @@ OBJS += \ ./src/common/TargetingMode.o CPP_DEPS += \ +./src/common/GameConfig.d \ ./src/common/GameState.d \ ./src/common/Hero.d \ ./src/common/Ikari.d \ diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index d309502..dcd824e 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -12,6 +12,7 @@ #include "states/PerformAttacks.h" #include "../app/Application.h" #include "../app/Input.h" +#include "../common/GameState.h" #include "../common/Ikari.h" #include "../common/Inventory.h" #include "../common/Item.h" @@ -115,7 +116,7 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { } void BattleState::LoadInventory() { - const Inventory &inv(*res->inventory); + const Inventory &inv(game->state->inventory); itemMenu.Clear(); itemMenu.Reserve(inv.MaxItems()); for (int i(0); i < inv.MaxItems(); ++i) { diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index e002b7c..60c24bc 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -18,6 +18,7 @@ #include "SmallHeroTag.h" #include "../app/fwd.h" #include "../app/State.h" +#include "../common/GameConfig.h" #include "../common/fwd.h" #include "../common/Stats.h" #include "../geometry/Vector.h" @@ -35,11 +36,12 @@ class BattleState : public app::State { public: - BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const Resources *res) - : background(background) - , monstersLayout(&monstersLayout) - , heroesLayout(&heroesLayout) - , res(res) + BattleState(common::GameConfig *game, SDL_Surface *background, const PartyLayout *monstersLayout) + : game(game) + , background(background) + , monstersLayout(monstersLayout) + , heroesLayout(game->heroesLayout) + , res(game->battleResources) , attackTypeMenu(res->attackIcons) , moveMenu(res->moveIcons) , numHeroes(0) @@ -47,7 +49,7 @@ public: , attackCursor(-1) , expReward(0) , goldReward(0) - , ranAway(false) { assert(background && res); } + , ranAway(false) { assert(background && monstersLayout && game); } public: void AddMonster(const Monster &); @@ -143,6 +145,7 @@ private: Uint16 CalculateDamage(const common::Stats &attacker, const common::Stats &defender) const; private: + common::GameConfig *game; SDL_Surface *background; const PartyLayout *monstersLayout; const PartyLayout *heroesLayout; diff --git a/src/battle/Resources.cpp b/src/battle/Resources.cpp index bb0c0ad..3320c9f 100644 --- a/src/battle/Resources.cpp +++ b/src/battle/Resources.cpp @@ -47,7 +47,6 @@ Resources::Resources() , spellMenuHeadline("") , spellMenuProperties(0) -, inventory(0) , itemMenuHeadline("") , itemMenuProperties(0) , ikariMenuHeadline("") diff --git a/src/battle/Resources.h b/src/battle/Resources.h index 5ef036f..051879c 100644 --- a/src/battle/Resources.h +++ b/src/battle/Resources.h @@ -52,7 +52,6 @@ struct Resources { const char *spellMenuHeadline; graphics::MenuProperties *spellMenuProperties; - common::Inventory *inventory; const char *itemMenuHeadline; graphics::MenuProperties *itemMenuProperties; diff --git a/src/common/GameConfig.cpp b/src/common/GameConfig.cpp new file mode 100644 index 0000000..b35e991 --- /dev/null +++ b/src/common/GameConfig.cpp @@ -0,0 +1,19 @@ +/* + * GameConfig.cpp + * + * Created on: Oct 9, 2012 + * Author: holy + */ + +#include "GameConfig.h" + +namespace common { + +GameConfig::GameConfig() +: state(0) +, battleResources(0) +, heroesLayout(0) { + +} + +} diff --git a/src/common/GameConfig.h b/src/common/GameConfig.h new file mode 100644 index 0000000..16b0142 --- /dev/null +++ b/src/common/GameConfig.h @@ -0,0 +1,29 @@ +/* + * GameConfig.h + * + * Created on: Oct 9, 2012 + * Author: holy + */ + +#ifndef COMMON_GAMECONFIG_H_ +#define COMMON_GAMECONFIG_H_ + +#include "fwd.h" +#include "../battle/fwd.h" + +namespace common { + +struct GameConfig { + + GameConfig(); + + GameState *state; + + battle::Resources *battleResources; + battle::PartyLayout *heroesLayout; + +}; + +} + +#endif /* COMMON_GAMECONFIG_H_ */ diff --git a/src/common/GameState.h b/src/common/GameState.h index f1edf48..fca50c1 100644 --- a/src/common/GameState.h +++ b/src/common/GameState.h @@ -9,6 +9,7 @@ #define COMMON_GAMESTATE_H_ #include "Hero.h" +#include "Inventory.h" #include @@ -21,6 +22,8 @@ struct GameState { Hero heroes[7]; Hero *party[4]; + Inventory inventory; + Uint32 money; }; diff --git a/src/common/fwd.h b/src/common/fwd.h index 3f7e46f..053307e 100644 --- a/src/common/fwd.h +++ b/src/common/fwd.h @@ -10,6 +10,7 @@ namespace common { +struct GameConfig; struct GameState; class Hero; class HeroGroup; diff --git a/src/main.cpp b/src/main.cpp index 793a76f..8029a64 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include "battle/Monster.h" #include "battle/PartyLayout.h" #include "battle/Resources.h" +#include "common/GameConfig.h" #include "common/GameState.h" #include "common/Hero.h" #include "common/Ikari.h" @@ -58,6 +59,7 @@ using app::Input; using battle::BattleState; using battle::Monster; using battle::PartyLayout; +using common::GameConfig; using common::GameState; using common::Hero; using common::Ikari; @@ -194,15 +196,17 @@ int main(int argc, char **argv) { gameState.party[2] = &gameState.heroes[2]; gameState.party[3] = &gameState.heroes[3]; + GameConfig gameConfig; + gameConfig.state = &gameState; + gameConfig.heroesLayout = caster.GetPartyLayout("heroesLayout"); + gameConfig.battleResources = caster.GetBattleResources("battleResources"); + // temporary test data SDL_Surface *bg(IMG_Load("test-data/battle-bg.png")); PartyLayout monstersLayout(*caster.GetPartyLayout("monstersLayout")); - PartyLayout heroesLayout(*caster.GetPartyLayout("heroesLayout")); Monster monster(*caster.GetMonster("lizard")); - battle::Resources *battleRes(caster.GetBattleResources("battleResources")); - gameState.heroes[0].AddSpell(caster.GetSpell("resetSpell")); Spell *strongSpell(caster.GetSpell("strongSpell")); gameState.heroes[0].AddSpell(strongSpell); @@ -221,14 +225,12 @@ int main(int argc, char **argv) { gameState.heroes[0].AddSpell(valorSpell); gameState.heroes[1].AddSpell(valorSpell); - Inventory inventory; - inventory.Add(caster.GetItem("antidoteItem"), 9); - inventory.Add(caster.GetItem("magicJarItem"), 4); - inventory.Add(caster.GetItem("hiPotionItem"), 4); - inventory.Add(caster.GetItem("powerPotionItem"), 4); - inventory.Add(caster.GetItem("escapeItem"), 2); - inventory.Add(caster.GetItem("sleepBallItem"), 1); - battleRes->inventory = &inventory; + gameState.inventory.Add(caster.GetItem("antidoteItem"), 9); + gameState.inventory.Add(caster.GetItem("magicJarItem"), 4); + gameState.inventory.Add(caster.GetItem("hiPotionItem"), 4); + gameState.inventory.Add(caster.GetItem("powerPotionItem"), 4); + gameState.inventory.Add(caster.GetItem("escapeItem"), 2); + gameState.inventory.Add(caster.GetItem("sleepBallItem"), 1); gameState.heroes[0].SetWeapon(caster.GetItem("zircoSwordItem")); gameState.heroes[0].SetArmor(caster.GetItem("zirconArmorItem")); @@ -424,6 +426,7 @@ int main(int argc, char **argv) { map1.SetTileset(&tileset); map1.SetTriggers(triggers1, 1); map1.SetWidth(2); + map1.SetBattleBackground(bg); Tile tiles3[64]; @@ -511,6 +514,7 @@ int main(int argc, char **argv) { map2.SetTileset(&tileset); map2.SetTriggers(triggers2, 1); map2.SetWidth(1); + map2.SetBattleBackground(bg); triggers1[0].map = &map2; triggers1[0].target = Vector(6, 2); @@ -539,6 +543,8 @@ int main(int argc, char **argv) { mapMonster.SetAnimation(&mapMonsterAnimation); mapMonster.Position() = Vector(64, 32); mapMonster.SetOrientation(Entity::ORIENTATION_SOUTH); + mapMonster.SetPartyLayout(&monstersLayout); + mapMonster.SetMonsters(&monster, 1); map1.SetEntities(&mapMonster, 1); InitScreen screen(width, height); @@ -546,7 +552,7 @@ int main(int argc, char **argv) { app::State *state(0); if (battle) { - BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, battleRes)); + BattleState *battleState(new BattleState(&gameConfig, bg, &monstersLayout)); battleState->AddMonster(monster); battleState->AddMonster(monster); battleState->AddMonster(monster); @@ -557,7 +563,7 @@ int main(int argc, char **argv) { battleState->AddHero(gameState.heroes[3]); state = battleState; } else { - MapState *mapState(new MapState(&map1)); + MapState *mapState(new MapState(&gameConfig, &map1)); mapState->ControlEntity(&gameState.heroes[0].MapEntity()); mapState->SetWalkingSpeed(walkSpeed); diff --git a/src/map/Area.cpp b/src/map/Area.cpp index 9c066d6..985dea2 100644 --- a/src/map/Area.cpp +++ b/src/map/Area.cpp @@ -18,13 +18,23 @@ using geometry::Vector; namespace map { Area::Area() -: tiles(0) +: battlebg(0) +, tiles(0) , numTiles(0) , width(0) { } +Tile *Area::TileAt(const geometry::Vector &offset) { + int tileIndex(offset.Y() * width + offset.X()); + if (tileIndex < numTiles) { + return tiles +tileIndex; + } else { + return 0; + } +} + const Tile *Area::TileAt(const geometry::Vector &offset) const { int tileIndex(offset.Y() * width + offset.X()); if (tileIndex < numTiles) { diff --git a/src/map/Area.h b/src/map/Area.h index d9cc5d0..a044c8b 100644 --- a/src/map/Area.h +++ b/src/map/Area.h @@ -26,18 +26,22 @@ public: int Width() const { return width; } int Height() const { return numTiles / width + (numTiles % width ? 1 : 0); } geometry::Vector Size() const { return geometry::Vector(Width(), Height()); } + Tile *TileAt(const geometry::Vector &); const Tile *TileAt(const geometry::Vector &) const; + SDL_Surface *BattleBackground() { return battlebg; } + void Render(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector &offset) const; void RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const geometry::Vector &offset) const; // temporary setters public: - void SetTiles(const Tile *t, int num) { tiles = t; numTiles = num; } + void SetTiles(Tile *t, int num) { tiles = t; numTiles = num; } void SetWidth(int w) { width = w; } private: - const Tile *tiles; + SDL_Surface *battlebg; + Tile *tiles; int numTiles; int width; diff --git a/src/map/Entity.cpp b/src/map/Entity.cpp index c951f66..01a8e9c 100644 --- a/src/map/Entity.cpp +++ b/src/map/Entity.cpp @@ -18,6 +18,9 @@ namespace map { Entity::Entity() : follower(0) , animation(0) +, partyLayout(0) +, monsters(0) +, numMonsters(0) , orientation(ORIENTATION_NORTH) , speed(0) , flags(0) { @@ -118,6 +121,8 @@ void Entity::CreateTypeDescription() { Entity e; int animationId(TypeDescription::GetTypeId("Animation")); + int monsterId(TypeDescription::GetTypeId("Monster")); + int partyLayoutId(TypeDescription::GetTypeId("PartyLayout")); int vectorId(TypeDescription::GetTypeId("Vector")); TypeDescription &td(TypeDescription::CreateOrGet("Entity")); @@ -126,6 +131,8 @@ void Entity::CreateTypeDescription() { td.SetSize(sizeof(Entity)); td.AddField("animation", FieldDescription(((char *)&e.animation) - ((char *)&e), animationId).SetReferenced()); + td.AddField("partyLayout", FieldDescription(((char *)&e.partyLayout) - ((char *)&e), partyLayoutId).SetReferenced()); + td.AddField("monsters", FieldDescription(((char *)&e.monsters) - ((char *)&e), monsterId).SetReferenced().SetAggregate()); td.AddField("spriteOffset", FieldDescription(((char *)&e.spriteOffset) - ((char *)&e), vectorId)); } diff --git a/src/map/Entity.h b/src/map/Entity.h index 3ddc9cc..13ecaca 100644 --- a/src/map/Entity.h +++ b/src/map/Entity.h @@ -8,6 +8,8 @@ #ifndef MAP_ENTITY_H_ #define MAP_ENTITY_H_ +#include "../battle/fwd.h" +#include "../battle/Monster.h" #include "../geometry/Vector.h" #include "../graphics/fwd.h" #include "../graphics/Animation.h" @@ -56,10 +58,14 @@ public: void SetFlags(int f) { flags = f; } bool Blocking() const { return !(flags & FLAG_NONBLOCKING); } - bool Hostile() const { - // NOTE: this is a stub for testing! - return Blocking(); - } + bool Hostile() const { return partyLayout && numMonsters > 0; } + + void SetPartyLayout(battle::PartyLayout *l) { partyLayout = l; } + battle::PartyLayout *PartyLayout() { return partyLayout; } + + void SetMonsters(battle::Monster *m, int num) { monsters = m; numMonsters = num; } + battle::Monster *MonstersBegin() { return monsters; } + battle::Monster *MonstersEnd() { return monsters + numMonsters; } Entity *Follower() { return follower; } const Entity *Follower() const { return follower; } @@ -82,6 +88,9 @@ private: private: Entity *follower; const graphics::Animation *animation; + battle::PartyLayout *partyLayout; + battle::Monster *monsters; + int numMonsters; graphics::AnimationRunner runner; geometry::Vector spriteOffset; geometry::Vector position; diff --git a/src/map/Map.cpp b/src/map/Map.cpp index fc664c1..a9e11df 100644 --- a/src/map/Map.cpp +++ b/src/map/Map.cpp @@ -8,6 +8,7 @@ #include "Map.h" #include "Area.h" +#include "Tile.h" #include "Trigger.h" #include "../graphics/Sprite.h" @@ -19,6 +20,7 @@ namespace map { Map::Map() : tileset(0) +, battlebg(0) , areas(0) , numAreas(0) , triggers(0) @@ -30,6 +32,18 @@ Map::Map() } +Area *Map::AreaAt(const Vector &offset) { + if (numAreas > 0) { + Vector coords(TileCoordinates(offset)); + Vector areaOffset(coords / areas[0].Size()); + int areaIndex(areaOffset.Index(width)); + if (areaIndex < numAreas) { + return areas + areaIndex; + } + } + return 0; +} + const Area *Map::AreaAt(const Vector &offset) const { if (numAreas > 0) { Vector coords(TileCoordinates(offset)); @@ -42,6 +56,16 @@ const Area *Map::AreaAt(const Vector &offset) const { return 0; } +Tile *Map::TileAt(const Vector &offset) { + Area *area(AreaAt(offset)); + if (area) { + Vector tileOffset(TileCoordinates(offset) % area->Size()); + return area->TileAt(tileOffset); + } else { + return 0; + } +} + const Tile *Map::TileAt(const Vector &offset) const { const Area *area(AreaAt(offset)); if (area) { @@ -63,6 +87,18 @@ Trigger *Map::TriggerAt(const geometry::Vector &offset) { return 0; } +SDL_Surface *Map::BattleBackgroundAt(const geometry::Vector &position) { + Tile *tile(TileAt(position)); + if (tile && tile->BattleBackground()) { + return tile->BattleBackground(); + } + Area *area(AreaAt(position)); + if (area && area->BattleBackground()) { + return area->BattleBackground(); + } + return battlebg; +} + Vector Map::TileCoordinates(const Vector &position) const { return position / tileset->Size(); } diff --git a/src/map/Map.h b/src/map/Map.h index ab0728b..5eacc7b 100644 --- a/src/map/Map.h +++ b/src/map/Map.h @@ -24,9 +24,12 @@ public: public: const graphics::Sprite *Tileset() const { return tileset; } + Area *AreaAt(const geometry::Vector &); const Area *AreaAt(const geometry::Vector &) const; + Tile *TileAt(const geometry::Vector &); const Tile *TileAt(const geometry::Vector &) const; Trigger *TriggerAt(const geometry::Vector &); + SDL_Surface *BattleBackgroundAt(const geometry::Vector &); geometry::Vector TileCoordinates(const geometry::Vector &) const; Entity **EntitiesBegin() { return &entities; } @@ -38,6 +41,7 @@ public: // temporary setters public: void SetTileset(const graphics::Sprite *t) { tileset = t; } + void SetBattleBackground(SDL_Surface *bg) { battlebg = bg; } void SetAreas(Area *a, int num) { areas = a; numAreas = num; } void SetTriggers(Trigger *t, int num) { triggers = t; numTriggers = num; } void SetEntities(Entity *e, int num) { entities = e; numEntities = num; } @@ -45,6 +49,7 @@ public: private: const graphics::Sprite *tileset; + SDL_Surface *battlebg; Area *areas; int numAreas; Trigger *triggers; diff --git a/src/map/MapState.cpp b/src/map/MapState.cpp index ce14c29..773190e 100644 --- a/src/map/MapState.cpp +++ b/src/map/MapState.cpp @@ -13,19 +13,25 @@ #include "Trigger.h" #include "../app/Application.h" #include "../app/Input.h" +#include "../battle/BattleState.h" +#include "../common/GameConfig.h" +#include "../common/GameState.h" #include "../graphics/ColorFade.h" #include using app::Application; using app::Input; +using battle::BattleState; +using common::GameConfig; using geometry::Vector; using graphics::ColorFade; namespace map { -MapState::MapState(Map *map) -: ctrl(0) +MapState::MapState(GameConfig *g, Map *map) +: game(g) +, ctrl(0) , map(map) , controlled(0) , tempTarget(20, 20) @@ -95,16 +101,19 @@ void MapState::OnTileLock() { if (moveTimer.Running() && !moveTimer.JustHit()) return; Vector nowLock(controlled->Position()); + bool event(false); if (nowLock != lastLock) { - OnGridLock(); + event = OnGridLock(); afterLock = true; moveTimer.Clear(); } else if (moveTimer.JustHit()) { - OnGridLock(); + event = OnGridLock(); afterLock = true; } - // TODO: halt all activity if lock caused a state/map transition + if (event) { + return; + } if (nextDirection >= 0) { bool blocked(CheckBlocking()); @@ -193,13 +202,13 @@ bool MapState::CheckBlocking() const { return false; } -void MapState::OnGridLock() { +bool MapState::OnGridLock() { if (skipLock) { skipLock = false; + return false; } else { LockEntities(); - CheckMonster(); - CheckTrigger(); + return CheckMonster() || CheckTrigger(); } } @@ -213,7 +222,7 @@ void MapState::LockEntities() { } } -void MapState::CheckMonster() { +bool MapState::CheckMonster() { Vector coords(map->TileCoordinates(controlled->Position())); Vector neighbor[4]; neighbor[0] = Vector(coords.X(), coords.Y() - 1); // N @@ -225,17 +234,38 @@ void MapState::CheckMonster() { for (std::vector::iterator e(entities.begin()), end(entities.end()); e != end; ++e) { if ((*e)->Hostile() && map->TileCoordinates((*e)->Position()) == neighbor[i]) { // TODO: check for turn advantage, see #26 - // TODO: remove entity, push battle state and transition and halt all other activity + // TODO: other transition + BattleState *battleState(new BattleState(game, map->BattleBackgroundAt((*e)->Position()), (*e)->PartyLayout())); + for (int i(0); i < 4; ++i) { + if (game->state->party[i]) { + battleState->AddHero(*game->state->party[i]); + } + } + for (battle::Monster *monster((*e)->MonstersBegin()); monster != (*e)->MonstersEnd(); ++monster) { + battleState->AddMonster(*monster); + } + + ColorFade *fadeIn(new ColorFade(this, 0, 500, true)); + fadeIn->SetLeadInTime(500); + ColorFade *fadeOut(new ColorFade(this, 0, 500)); + fadeOut->SetLeadOutTime(500); + + ctrl->PushState(fadeIn); + ctrl->PushState(battleState); + ctrl->PushState(fadeOut); + // TODO: move entity erase to happen after the transition or battle + entities.erase(e); + return true; // needed information here: - // - battle background (from tile?) + // - battle background (from tile/area/map) // - monsters + layout (from entity) - // - battle resources (from global resources) } } } + return false; } -void MapState::CheckTrigger() { +bool MapState::CheckTrigger() { Trigger *trigger(map->TriggerAt(Vector(controlled->Position()))); if (trigger) { // TODO: run trigger script @@ -245,9 +275,10 @@ void MapState::CheckTrigger() { ColorFade *fadeOut(new ColorFade(this, 0, 500, false)); fadeOut->SetLeadOutTime(500); ctrl->PushState(fadeOut); + return true; } } - + return false; } void MapState::OnMove(bool realMove) { diff --git a/src/map/MapState.h b/src/map/MapState.h index dc352f6..a6d292b 100644 --- a/src/map/MapState.h +++ b/src/map/MapState.h @@ -11,6 +11,7 @@ #include "Entity.h" #include "fwd.h" #include "../app/State.h" +#include "../common/fwd.h" #include "../geometry/Vector.h" #include "../graphics/Camera.h" @@ -22,7 +23,7 @@ class MapState : public app::State { public: - explicit MapState(Map *); + explicit MapState(common::GameConfig *, Map *); virtual ~MapState() { } public: @@ -53,17 +54,18 @@ private: bool CheckBlocking() const; void OnTileLock(); - void OnGridLock(); + bool OnGridLock(); void OnMove(bool); void UpdateFollower(Entity &); void StopFollowers(Entity &); void LockEntities(); - void CheckMonster(); - void CheckTrigger(); + bool CheckMonster(); + bool CheckTrigger(); private: + common::GameConfig *game; app::Application *ctrl; Map *map; Entity *controlled; diff --git a/src/map/Tile.cpp b/src/map/Tile.cpp index 7b77fb1..303c9e5 100644 --- a/src/map/Tile.cpp +++ b/src/map/Tile.cpp @@ -10,7 +10,8 @@ namespace map { Tile::Tile() -: flags(0) { +: battlebg(0) +, flags(0) { } diff --git a/src/map/Tile.h b/src/map/Tile.h index 88db623..06b3b11 100644 --- a/src/map/Tile.h +++ b/src/map/Tile.h @@ -28,6 +28,8 @@ public: BLOCK_WEST = 0x08, }; + SDL_Surface *BattleBackground() { return battlebg; } + const geometry::Vector &Offset() const { return offset; } bool BlocksNorth() const { return flags & BLOCK_NORTH; } @@ -41,6 +43,7 @@ public: Tile &SetFlags(Uint32 f) { flags = f; return *this; } private: + SDL_Surface *battlebg; geometry::Vector offset; Uint32 flags;