diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 5361fab..2e62890 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/assets/maps/map0 b/assets/maps/map0 index 901eaed..2e13a6f 100644 --- a/assets/maps/map0 +++ b/assets/maps/map0 @@ -5,12 +5,12 @@ ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????91:1;1?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????92:2;2?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? -????????????????????????92:2;2?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? -???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? -???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? -???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? +??00????????????????????92:2;2?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? +??66???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? +??????66???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? +??66???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? @@ -75,13 +75,13 @@ OBJECT160.000000;224.000000;8 OBJECT288.000000;224.000000;8 OBJECT224.000000;224.000000;8 OBJECT256.000000;224.000000;7 +OBJECT328.000000;215.000000;0 OBJECT288.000000;256.000000;8 OBJECT256.000000;256.000000;8 OBJECT224.000000;256.000000;8 OBJECT192.000000;256.000000;8 OBJECT160.000000;256.000000;8 OBJECT512.000000;288.000000;158 -OBJECT333.000000;286.000000;0 OBJECT256.000000;288.000000;90 OBJECT128.000000;288.000000;90 OBJECT192.000000;320.000000;90 @@ -90,4 +90,8 @@ OBJECT160.000000;384.000000;90 OBJECT96.000000;416.000000;159 ENCOUNTER64.000000;512.000000;90;2 ENCOUNTER192.000000;352.000000;100;1 -ENCOUNTER480.000000;160.000000;100;3 \ No newline at end of file +ENCOUNTER480.000000;160.000000;100;3 +TRIGGER32;288;1;32;32 +TRIGGER96;352;1;32;32 +TRIGGER32;384;1;32;32 +TRIGGER32;288;1;32;32 \ No newline at end of file diff --git a/main.cpp b/main.cpp index 57e3250..990f847 100644 --- a/main.cpp +++ b/main.cpp @@ -156,6 +156,8 @@ int MONEY=0; int ENEMY_MONEY_SUM=0; int SHOP_MENU_CURSOR=0; Object*SHOPKEEPER_INTERACTING_WITH=nullptr; +extern std::map TRIGGERS; +TriggerName::Trigger SELECTED_TRIGGER; /* [Choice1,Choice2,Choice3] @@ -191,8 +193,6 @@ std::vector> MAP2={}; std::vector> MAP3={}; std::vector> MAP4={}; std::vector> MAP5={}; //Collision Layer -std::vector TRIGGERS={}; -std::map Trigger::TRIGGERLIST={}; std::map SPRITES; std::map ANIMATIONS={}; std::map OBJ_INFO={}; @@ -793,7 +793,6 @@ void SeasonI::LoadMap(Map*map) { delete OBJECTS[i]; } OBJECTS.clear(); - TRIGGERS.clear(); for (int i=0;i<4;i++) { PARTY_MEMBER_OBJ[i]=nullptr; PARTY_MEMBER_ID[i]=0; @@ -848,7 +847,6 @@ void SeasonI::LoadMap(Map*map) { lastMarker=marker; int pct=id; split4>>id; - LoadEncounter(map,{x,y},pct,id,rand()%100>size_y; - TRIGGERS.push_back(new Trigger({(int)x,(int)y},{size_x,size_y},id)); - map->triggers.push_back(Trigger::TRIGGERLIST[(TriggerName::Trigger)id]); + map->triggers.push_back(new Trigger({(int)x,(int)y},{size_x,size_y},(TriggerName::Trigger)id)); printf("Trigger %d Loaded.\n",id); } } else { @@ -989,7 +986,7 @@ void SeasonI::SaveMap(Map*map) { for (int i=0;itriggers.size();i++) { f.put('\n'); - const std::string trigger="TRIGGER"+std::to_string(map->triggers[i]->GetPosX())+";"+std::to_string(map->triggers[i]->GetPosY())+";"+";"+std::to_string(map->triggers[i]->GetID())+std::to_string(map->triggers[i]->GetSizeX())+";"+std::to_string(map->triggers[i]->GetSizeY()); + const std::string trigger="TRIGGER"+std::to_string(map->triggers[i]->GetPosX())+";"+std::to_string(map->triggers[i]->GetPosY())+";"+std::to_string(map->triggers[i]->GetID())+";"+std::to_string(map->triggers[i]->GetSizeX())+";"+std::to_string(map->triggers[i]->GetSizeY()); for (int j=0;j0) { if (PARTY_MEMBER_OBJ[0]->SmoothMove(movementComponents)) { UpdatePlayerTrail(movementComponents); + for (int i=0;itriggers.size();i++) { + if (CURRENT_MAP->triggers[i]->IsInside(PARTY_MEMBER_OBJ[0]->GetPosWithOrigin())) { + CURRENT_MAP->triggers[i]->Interact(); + } + } moved=true; } } @@ -1274,6 +1281,10 @@ void SeasonI::updateGame(){ if (GetKey(SHIFT).bHeld) { GAME_STATE=GameState::ENCOUNTER_SELECT; } + if (GetKey(CTRL).bHeld) { + GAME_STATE=GameState::TRIGGER_SELECT; + SELECTED_TRIGGER=TriggerName::NONE; + } if (PlayerCanMove()) { if (GetKey(I).bHeld) { if (PARTY_MEMBER_OBJ[0]->SmoothMove({0,-1})) { @@ -1304,9 +1315,19 @@ void SeasonI::updateGame(){ if (GetMouse(0).bHeld) { switch (EDITING_LAYER) { case layer::COLLISION:{ - TILE*tile=MAP5[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; - tile->tileX=SELECTED_TILE.x; - tile->tileY=SELECTED_TILE.y; + if (EDITING_LAYER==layer::COLLISION&&SELECTED_TRIGGER!=TriggerName::NONE) { + for (int i=0;itriggers.size();i++) { + if (CURRENT_MAP->triggers[i]->GetPos()==HIGHLIGHTED_TILE*32) { + delete CURRENT_MAP->triggers[i]; + CURRENT_MAP->triggers.erase(CURRENT_MAP->triggers.begin()+i--); + } + } + CURRENT_MAP->triggers.push_back(new Trigger(HIGHLIGHTED_TILE*32,{32,32},SELECTED_TRIGGER)); + } else { + TILE*tile=MAP5[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; + tile->tileX=SELECTED_TILE.x; + tile->tileY=SELECTED_TILE.y; + } }break; case layer::HIGH:{ TILE*tile=MAP[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; @@ -2487,7 +2508,6 @@ void SeasonI::drawGame(){ bool underAttack=false; if (BATTLE_ENCOUNTER!=nullptr) { std::vector attackedAllies; - if (CURRENT_TURN>=0&&BATTLE_STATE==BattleState::WAIT_ANIMATION&&BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget<0) { attackedAllies=GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->channelPos,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove); } @@ -2728,6 +2748,15 @@ void SeasonI::drawGame(){ DrawGameWorld(); SetDrawTarget(nullptr); DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW); + if (EDITING_LAYER==layer::COLLISION&&SELECTED_TRIGGER!=TriggerName::NONE) { + DrawStringPropDecal({2,2},Wrap("Editing Triggers - Selected "+TRIGGERS[SELECTED_TRIGGER],WIDTH-4,true,{1,1})); + for (auto&trigger:CURRENT_MAP->triggers) { + FillRectDecal(trigger->GetPos()-cameraPos,trigger->GetSize(),Pixel(255,0,0,64)); + DrawRectDecal(trigger->GetPos()-cameraPos,trigger->GetSize(),YELLOW); + vi2d textOffset={2,2}; + DrawStringDecal(trigger->GetPos()-cameraPos+textOffset,TRIGGERS[(TriggerName::Trigger)trigger->GetID()],WHITE,{28.f/GetTextSize(TRIGGERS[(TriggerName::Trigger)trigger->GetID()]).x,1.f}); + } + } else if (EDITING_LAYER==layer::ENCOUNTER) { if (IsTextEntryEnabled()) { DrawStringPropDecal({2,2},"Input Chance: "+TextEntryGetString()+"%",YELLOW); @@ -2827,6 +2856,40 @@ void SeasonI::drawGame(){ counter++; } }break; + case GameState::TRIGGER_SELECT:{ + vd2d drawpos={0,0}; + int counter=0; + for (std::map::const_iterator it = TRIGGERS.cbegin();it!=TRIGGERS.cend();++it){ + if (counterHEIGHT) { + break; + } + TriggerName::Trigger trigger = it->first; + if (GetMouse(0).bHeld&& + GetMousePos().x>=drawpos.x&& + GetMousePos().x=drawpos.y&& + GetMousePos().ysecond,WHITE,{(float)(12.0/GetTextSize(it->second).x),1.0}); + if (SELECTED_TRIGGER==it->first) { + 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/states.h b/states.h index 180dbcb..9b5d898 100644 --- a/states.h +++ b/states.h @@ -20,6 +20,7 @@ namespace GameState{ SHOPKEEPER_MENU, SHOPKEEPER_SELL_MENU, SHOPKEEPER_CONFIRM_SELL_MENU, + TRIGGER_SELECT, }; } diff --git a/trigger.cpp b/trigger.cpp new file mode 100644 index 0000000..3f4e363 --- /dev/null +++ b/trigger.cpp @@ -0,0 +1,8 @@ +#include "pixelGameEngine.h" +#include "trigger.h" + +int i=1; + +std::map TRIGGERS={ + {(TriggerName::Trigger)i++,"START_CUTSCENE_1"}, +}; \ No newline at end of file diff --git a/trigger.h b/trigger.h index 4bf1e71..b8324dc 100644 --- a/trigger.h +++ b/trigger.h @@ -1,22 +1,41 @@ +#ifndef TRIGGER_H +#define TRIGGER_H #include "pixelGameEngine.h" +#include "flags.h" +#include "SeasonI.h" using namespace olc; namespace TriggerName{ + //When adding new triggers to the list, you will have to add a new line to trigger.cpp to get it to appear in the editor. enum Trigger{ + NONE, START_CUTSCENE_1 }; } +extern void DisplayMessageBox(std::string targetT); +extern SeasonI*GAME; + class Trigger{ vi2d pos; vi2d size; - int id; + TriggerName::Trigger id; public: - Trigger(vi2d pos,vi2d size,int id) + Trigger(vi2d pos,vi2d size,TriggerName::Trigger id) :pos(pos),size(size),id(id){} bool IsInside(vd2d point) { - return point>pos&&pointpos.x&&point.xpos.y&&point.yGetGameFlag(Flag::TEST_FLAG1)) { + DisplayMessageBox("You have triggered this scene."); + GAME->SetGameFlag(Flag::TEST_FLAG1,true); + } + }break; + } } vi2d GetPos() { return pos; @@ -39,4 +58,5 @@ class Trigger{ int GetID() { return id; } -}; \ No newline at end of file +}; +#endif \ No newline at end of file