From 2ec163612042bfa5e4e1bf220b489506f7039677 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 18 Mar 2015 09:48:43 -0400 Subject: Game can now read map file from map editor (also added new map) --- src/map.h | 56 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 15 deletions(-) (limited to 'src/map.h') diff --git a/src/map.h b/src/map.h index 3b3d42c..1234dbb 100644 --- a/src/map.h +++ b/src/map.h @@ -8,37 +8,63 @@ class Entity; class Map { public: - Map(); - Map(std::string name); + Map(int id); + Map() : Map(-1) {} Map(const Map& map); Map(Map&& map); ~Map(); Map& operator= (Map other); friend void swap(Map& first, Map& second); - static Map& getNamedMap(std::string name); + enum class MoveType { + Wall, + Wrap, + Warp, + ReverseWarp + }; + + struct EntityData { + std::string name; + std::pair position; + }; + + static MoveType moveTypeForShort(std::string str); + static bool moveTypeTakesMap(MoveType type); + int getID() const; const int* getMapdata() const; std::string getTitle() const; - const Map* getLeftMap() const; - const Map* getRightMap() const; - void setLeftMap(const Map* m); - void setRightMap(const Map* m); + MoveType getLeftMoveType() const; + MoveType getRightMoveType() const; + MoveType getUpMoveType() const; + MoveType getDownMoveType() const; + int getLeftMapID() const; + int getRightMapID() const; + int getUpMapID() const; + int getDownMapID() const; + void createEntities(std::list>& entities) const; bool operator==(const Map& other) const; bool operator!=(const Map& other) const; - private: - struct EntityData { - std::string name; - std::pair position; - }; + void setMapdata(int* mapdata); + void setTitle(std::string title); + void setLeftMoveType(MoveType type); + void setRightMoveType(MoveType type); + void setUpMoveType(MoveType type); + void setDownMoveType(MoveType type); + void setLeftMapID(int id); + void setRightMapID(int id); + void setUpMapID(int id); + void setDownMapID(int id); + void addEntity(EntityData& data); + private: int* mapdata; std::string title; - std::string name; - const Map* leftMap = nullptr; - const Map* rightMap = nullptr; + int id; std::list entities; + MoveType leftType, rightType, upType, downType; + int leftMap, rightMap, upMap, downMap; }; #endif -- cgit 1.4.1