diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 2e62890..7752134 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 990f847..bf5cda7 100644 --- a/main.cpp +++ b/main.cpp @@ -54,7 +54,7 @@ const float TARGET_RATE = 1/60.0; int MAP_WIDTH=-1; int MAP_HEIGHT=-1; Map*CURRENT_MAP=nullptr; -Map*MAP_ONETT=nullptr; +extern std::map MAPS; int GAME_STATE = GameState::EDITOR; vi2d SELECTED_TILE={0,0}; vi2d HIGHLIGHTED_TILE={0,0}; @@ -158,6 +158,8 @@ int SHOP_MENU_CURSOR=0; Object*SHOPKEEPER_INTERACTING_WITH=nullptr; extern std::map TRIGGERS; TriggerName::Trigger SELECTED_TRIGGER; +int TRIGGER_OFFSET=0; +int WORLD_DISPLAY_OFFSET=0; /* [Choice1,Choice2,Choice3] @@ -246,11 +248,9 @@ bool SeasonI::OnUserCreate(){ additionalChars[Σ]={24,0}; additionalChars[γ]={32,0}; - MAP_ONETT=new Map("map0","map0_2","map0_3","map0_4","map0_5",SPRITES["terrainmap.png"]); - - CURRENT_MAP=MAP_ONETT; + CURRENT_MAP=MAPS[MapName::ONETT]; //OBJ_INFO["PLAYER"]=PLAYER_ANIMATION; - LoadMap(MAP_ONETT); + LoadMap(CURRENT_MAP); TestCutscene=new Cutscene({ 액션 Fade(), @@ -762,33 +762,50 @@ void SeasonI::LoadMap(Map*map) { } MAP[i].clear(); } - for (int i=0;iencounters.size();i++) { + for (int j=0;jencounters[i]->objs.size();j++) { + delete map->encounters[i]->objs[j]; + } + map->encounters[i]->objs.clear(); + delete map->encounters[i]; + } + map->encounters.clear(); + for (int i=0;itriggers.size();i++) { + delete map->triggers[i]; + } + map->triggers.clear(); MAP_WIDTH=-1; MAP_HEIGHT=-1; MAP.clear(); + MAP2.clear(); + MAP3.clear(); + MAP4.clear(); + MAP5.clear(); for (int i=0;i>data; @@ -876,6 +894,7 @@ void SeasonI::LoadMap(Map*map) { MAP_HEIGHT++; } } + while (f2.good()) { f2>>data; std::vector tiles; @@ -2261,6 +2280,9 @@ void SeasonI::keyUpdates() { EDITING_LAYER=layer::BACKGROUND; EnableLayer(layer::COLLISION,false); } + if (GetKey(HOME).bPressed) { + GAME_STATE=GameState::MAP_SELECT; + } if (GetKey(ESCAPE).bPressed) { GAME_STATE=GameState::OBJ_SELECT; } @@ -2307,6 +2329,17 @@ void SeasonI::keyUpdates() { } } }break; + case GameState::MAP_SELECT:{ + if (GetKey(ESCAPE).bPressed) { + GAME_STATE=GameState::EDITOR; + } + if ((GetMouseWheel()<0||GetKey(PGDN).bHeld)&&WORLD_DISPLAY_OFFSET+(WIDTH/16)0||GetKey(PGUP).bHeld)&&WORLD_DISPLAY_OFFSET-(WIDTH/16)>=0) { + WORLD_DISPLAY_OFFSET-=WIDTH/16; + } + }break; case GameState::OBJ_SELECT:{ if (GetKey(ESCAPE).bPressed) { GAME_STATE=GameState::EDITOR; @@ -2318,6 +2351,28 @@ void SeasonI::keyUpdates() { OBJ_DISPLAY_OFFSET-=WIDTH/16; } }break; + case GameState::ENCOUNTER_SELECT:{ + if (GetKey(ESCAPE).bPressed) { + GAME_STATE=GameState::EDITOR; + } + if ((GetMouseWheel()<0||GetKey(PGDN).bHeld)&&ENCOUNTER_OFFSET+(WIDTH/16)0||GetKey(PGUP).bHeld)&&ENCOUNTER_OFFSET-(WIDTH/16)>=0) { + ENCOUNTER_OFFSET-=WIDTH/16; + } + }break; + case GameState::TRIGGER_SELECT:{ + if (GetKey(ESCAPE).bPressed) { + GAME_STATE=GameState::EDITOR; + } + if ((GetMouseWheel()<0||GetKey(PGDN).bHeld)&&TRIGGER_OFFSET+(WIDTH/16)0||GetKey(PGUP).bHeld)&&TRIGGER_OFFSET-(WIDTH/16)>=0) { + TRIGGER_OFFSET-=WIDTH/16; + } + }break; case GameState::OVERWORLD_EQUIP_PLAYER_MENU:{ if (LeftPressed()) { OVERWORLD_POWER_SELECTION_MEMBER--; @@ -2860,7 +2915,7 @@ void SeasonI::drawGame(){ vd2d drawpos={0,0}; int counter=0; for (std::map::const_iterator it = TRIGGERS.cbegin();it!=TRIGGERS.cend();++it){ - if (counter::const_iterator it = MAPS.cbegin();it!=MAPS.cend();++it){ + if (counterHEIGHT) { + break; + } + Map*map = it->second; + if (GetMouse(0).bHeld&& + GetMousePos().x>=drawpos.x&& + GetMousePos().x=drawpos.y&& + GetMousePos().ysecond->mapname,WHITE,{(float)(12.0/GetTextSize(it->second->mapname).x),1.0}); + if (CURRENT_MAP==it->second) { + DrawRectDecal(drawpos,{16,24},YELLOW); + } + drawpos.x+=16; + if (drawpos.x>=WIDTH) { + drawpos.x=0; + drawpos.y+=24; + } + counter++; + } + }break; } if (BATTLE_ENCOUNTER!=nullptr&&BATTLE_STATE==BattleState::TARGET_SELECT||GAME_STATE==GameState::OVERWORLD_TARGET_MENU) { SetDrawTarget(layer::GROUND); diff --git a/map.cpp b/map.cpp new file mode 100644 index 0000000..ccabf4a --- /dev/null +++ b/map.cpp @@ -0,0 +1,11 @@ +#include "pixelGameEngine.h" +#include "map.h" + +using namespace olc; + +extern std::map SPRITES; + +int MAP_ENUM_COUNT=0; +std::map MAPS={ + {(MapName::Map)MAP_ENUM_COUNT++,new Map("map0","map0_2","map0_3","map0_4","map0_5",SPRITES["terrainmap.png"],"Onett")}, +}; \ No newline at end of file diff --git a/map.h b/map.h index d245e59..0976fa5 100644 --- a/map.h +++ b/map.h @@ -6,6 +6,12 @@ using namespace olc; +namespace MapName{ + enum Map{ + ONETT, + }; +} + class Map{ public: std::string filename; @@ -13,16 +19,11 @@ class Map{ std::string l3filename; std::string l4filename; std::string l5filename; + std::string mapname; Decal*tileset; std::vector encounters; std::vector triggers; - Map(std::string fname,std::string layer2_fname,std::string layer3_fname,std::string layer4_fname,std::string layer5_fname,Decal*tileset) { - this->filename=fname; - this->l2filename=layer2_fname; - this->l3filename=layer3_fname; - this->l4filename=layer4_fname; - this->l5filename=layer5_fname; - this->tileset=tileset; - } + Map(std::string fname,std::string layer2_fname,std::string layer3_fname,std::string layer4_fname,std::string layer5_fname,Decal*tileset,std::string mapname) + :filename(fname),l2filename(layer2_fname),l3filename(layer3_fname),l4filename(layer4_fname),l5filename(layer5_fname),mapname(mapname),tileset(tileset) {} }; #endif \ No newline at end of file diff --git a/states.h b/states.h index 9b5d898..8f29adb 100644 --- a/states.h +++ b/states.h @@ -21,6 +21,10 @@ namespace GameState{ SHOPKEEPER_SELL_MENU, SHOPKEEPER_CONFIRM_SELL_MENU, TRIGGER_SELECT, + MAP_SELECT, + NEW_MAP_INPUT_NAME, + NEW_MAP_INPUT_WIDTH, + NEW_MAP_INPUT_HEIGHT, }; } diff --git a/test/test.cpp b/test/test.cpp index 51f0634..61063a0 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -21,6 +21,7 @@ #include "../battleproperty.h" #include "test.h" #include "../SeasonI.h" +#include "../map.h" extern std::array PARTY_MEMBER_STATS; extern Entity::pstats_t partyMemberDefaultStats; @@ -31,6 +32,7 @@ extern std::map OBJ_INFO; extern std::mapMOVELIST; extern std::vectorENCOUNTER_LIST; extern std::map BATTLE_PROPERTIES; +extern std::map MAPS; int testCount=0; @@ -202,7 +204,10 @@ bool SeasonI::OnUserCreate(){ Test("Freeze Packet description is set properly", ITEMLIST[ItemName::FREEZE_PACKET]->description=="Lets out some blistering cold weather."); Test("Freeze Packet drop chance is set properly", - ITEMLIST[ItemName::FREEZE_PACKET]->dropChance==2); + ITEMLIST[ItemName::FREEZE_PACKET]->dropChance==256); + for (int i=0;i<10000;i++) { + LoadMap(MAPS[MapName::ONETT]); + } return true; } diff --git a/trigger.cpp b/trigger.cpp index 3f4e363..889cddc 100644 --- a/trigger.cpp +++ b/trigger.cpp @@ -1,8 +1,8 @@ #include "pixelGameEngine.h" #include "trigger.h" -int i=1; +int TRIGGER_ENUM_COUNT=1; std::map TRIGGERS={ - {(TriggerName::Trigger)i++,"START_CUTSCENE_1"}, + {(TriggerName::Trigger)TRIGGER_ENUM_COUNT++,"START_CUTSCENE_1"}, }; \ No newline at end of file