diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 33e4777..c4bed8e 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/assets/maps/map0 b/assets/maps/map0 index 8f59220..7837545 100644 --- a/assets/maps/map0 +++ b/assets/maps/map0 @@ -80,6 +80,8 @@ OBJECT256.000000;256.000000;8 OBJECT224.000000;256.000000;8 OBJECT192.000000;256.000000;8 OBJECT160.000000;256.000000;8 -ENCOUNTER64.000000;64.000000;90;0 -ENCOUNTER64.000000;256.000000;90;1 -ENCOUNTER64.000000;512.000000;90;2 \ No newline at end of file +ENCOUNTER64.000000;512.000000;90;2 +ENCOUNTER320.000000;288.000000;25;1 +ENCOUNTER64.000000;64.000000;25;1 +ENCOUNTER64.000000;256.000000;25;1 +ENCOUNTER192.000000;352.000000;25;1 \ No newline at end of file diff --git a/main.cpp b/main.cpp index 05b6f29..13446df 100644 --- a/main.cpp +++ b/main.cpp @@ -296,8 +296,8 @@ class Encounter{ std::vectorobjs; std::array playerPos; int id; - Encounter(vd2d pos,std::array playerPos,std::vectorobjs,int chance=25) - :pos(pos),objs(objs),chance(chance),playerPos(playerPos){} + Encounter(int id,vd2d pos,std::array playerPos,std::vectorobjs,int chance=25) + :id(id),pos(pos),objs(objs),chance(chance),playerPos(playerPos){} }; @@ -880,7 +880,24 @@ goes on a very long time, I hope you can understand this is only for testing pur GAME_STATE=GameState::OBJ_SELECT; } if (EDITING_LAYER==layer::ENCOUNTER&&GetMouse(0).bPressed) { - //LoadEncounter(CURRENT_MAP,HIGHLIGHTED_TILE*32,CURRENT_MAP->encounters) //TODO Make up the encounter reference list and then come back. + LoadEncounter(CURRENT_MAP,HIGHLIGHTED_TILE*32,ENCOUNTER_LIST[ENCOUNTER_SELECTED]->chance,ENCOUNTER_SELECTED,true); + } else + if (EDITING_LAYER==layer::ENCOUNTER&&GetMouse(1).bPressed) { + for (int i=0;iencounters.size();i++) { + if(CURRENT_MAP->encounters[i]->pos==HIGHLIGHTED_TILE*32) { + for (int j=0;jencounters[i]->objs.size();j++) { + int index=CURRENT_MAP->encounters[i]->objs[j]->obj->objArrElement; + delete OBJECTS[index]; + OBJECTS.erase(OBJECTS.begin()+index); + for (int k=0;kobjArrElement=k; + } + } + delete CURRENT_MAP->encounters[i]; + CURRENT_MAP->encounters.erase(CURRENT_MAP->encounters.begin()+i--); + continue; + } + } } else if (EDITING_LAYER==layer::OBJECT&&GetMouse(0).bPressed) { AddObjectToWorld(CreateObject(SELECTED_OBJ_ID,HIGHLIGHTED_TILE*32)); @@ -924,6 +941,10 @@ goes on a very long time, I hope you can understand this is only for testing pur DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW); if (EDITING_LAYER==layer::ENCOUNTER) { DrawStringPropDecal({2,2},"Editing Encounters"); + for (auto&enc:CURRENT_MAP->encounters) { + FillRectDecal(enc->pos-cameraPos,{WIDTH,HEIGHT},Pixel(255,0,0,64)); + DrawRectDecal(enc->pos-cameraPos,{WIDTH,HEIGHT},YELLOW); + } } else if (EDITING_LAYER==layer::OBJECT) { DrawStringPropDecal({2,2},"Editing Objects"); @@ -973,7 +994,7 @@ goes on a very long time, I hope you can understand this is only for testing pur case GameState::ENCOUNTER_SELECT:{ vd2d drawpos={0,0}; int counter=0; - for (int i=0;iencounters.size();i++){ + for (int i=0;iHEIGHT) { break; } - Encounter*enc = CURRENT_MAP->encounters[i]; + Encounter*enc = ENCOUNTER_LIST[i]; if (GetMouse(0).bHeld&& GetMousePos().x>=drawpos.x&& GetMousePos().x{vd2d + ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_1,{0,0},std::array{vd2d {+10,+24},{+30,+24},{+50,+24},{+70,+24}}, std::vector{ new Entity(new Object( @@ -1537,7 +1558,7 @@ goes on a very long time, I hope you can understand this is only for testing pur MOVELIST[BattleMoveName::TESTMOVE3], }), }));//ENCOUNTER_1 - ENCOUNTER_LIST.push_back(new Encounter({0,0},std::array{vd2d + ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_2,{0,0},std::array{vd2d {10,24},{30,24},{50,24},{70,24}}, std::vector{ new Entity(new Object( @@ -1562,7 +1583,7 @@ goes on a very long time, I hope you can understand this is only for testing pur MOVELIST[BattleMoveName::TESTMOVE3], }), }));//ENCOUNTER_2 - ENCOUNTER_LIST.push_back(new Encounter({0,0},std::array{vd2d + ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_3,{0,0},std::array{vd2d {10,24},{30,24},{50,24},{70,24}}, std::vector{ new Entity(new Object( @@ -1797,7 +1818,7 @@ goes on a very long time, I hope you can understand this is only for testing pur Object*newObj=new Object(ent->obj->id,ent->obj->name,ent->obj->GetPos(),ent->obj->spr,ent->obj->GetScale(),ent->obj->color,ent->obj->animationSpd,ent->obj->temp); ents.push_back(new Entity(newObj,ent->HP,ent->maxHP,ent->baseAtk,ent->resistances,ent->speed,ent->moveSet,ent->damageReduction,ent->smart,ent->dumb)); } - Encounter*data=new Encounter(pos,ENCOUNTER_LIST[id]->playerPos,ents,chance); + Encounter*data=new Encounter(id,pos,ENCOUNTER_LIST[id]->playerPos,ents,chance); data->chance=chance; data->id=id; for (int i=0;iobjs.size();i++) { @@ -1808,9 +1829,7 @@ goes on a very long time, I hope you can understand this is only for testing pur } map->encounters.push_back(data); for (int i=0;iobjs.size();i++) { - if (successful) { - AddObjectToWorld(data->objs[i]->obj); - } + AddObjectToWorld(data->objs[i]->obj); data->objs[i]->obj->SetPos(data->objs[i]->obj->GetPos()+pos); } }