diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 5235108..2b6b057 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/assets/maps/map0 b/assets/maps/map0 index 4adc677..02d5432 100644 --- a/assets/maps/map0 +++ b/assets/maps/map0 @@ -80,6 +80,6 @@ OBJECT256.000000;256.000000;2 OBJECT224.000000;256.000000;2 OBJECT192.000000;256.000000;2 OBJECT160.000000;256.000000;2 -ENCOUNTER64;64;75;0 -ENCOUNTER64;256;30;1 -ENCOUNTER64;512;40;2 \ No newline at end of file +ENCOUNTER64;64;90;0 +ENCOUNTER64;256;90;1 +ENCOUNTER64;512;90;2 \ No newline at end of file diff --git a/main.cpp b/main.cpp index edfc02c..9b931d6 100644 --- a/main.cpp +++ b/main.cpp @@ -277,8 +277,9 @@ class Encounter{ vd2d pos; int chance; //Chance of the encounter existing. std::vectorobjs; - Encounter(vd2d pos,std::vectorobjs,int chance=25) - :pos(pos),objs(objs),chance(chance){} + std::array playerPos; + Encounter(vd2d pos,std::array playerPos,std::vectorobjs,int chance=25) + :pos(pos),objs(objs),chance(chance),playerPos(playerPos){} }; @@ -357,6 +358,7 @@ public: bool OnUserCreate() override { + srand(time(NULL)); GAME=this; for (int i=1;i<6;i++) { CreateLayer(); @@ -1035,7 +1037,15 @@ goes on a very long time, I hope you can understand this is only for testing pur lastMarker=marker; int pct=id; split4>>id; - printf("Encounter %d (%d%) Loaded.\n",id,pct); + + if (rand()%100 tiles; @@ -1544,22 +1554,85 @@ goes on a very long time, I hope you can understand this is only for testing pur } void LoadEncounter(Map*map,vd2d pos,int chance,int id) { + Encounter*data; switch (id) { case encounter::ENCOUNTER_1:{ - map->encounters.push_back( - new Encounter(pos, - std::vector{new Entity( - new Object( - NPC1_4,"Test Obj",{pos.x+20,pos.y+48},ANIMATIONS["player.png"] - ),70,70,14,std::array{0,0,0,0},0,std::vector{ - MOVELIST[BattleMoveName::TESTMOVE1], - MOVELIST[BattleMoveName::TESTMOVE2], - MOVELIST[BattleMoveName::TESTMOVE3], - } - )} - ,chance) - ); + data=new Encounter(pos,std::array{vd2d + {pos.x+10,pos.y+24},{pos.x+30,pos.y+24},{pos.x+50,pos.y+24},{pos.x+70,pos.y+24}}, + std::vector{ + new Entity(new Object( + NPC1_4,"Test Obj",{pos.x+20,pos.y+48},ANIMATIONS["player.png"]), + 70,70,14,std::array{0,0,0,0},0,std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }), + new Entity(new Object( + NPC1_4,"Test Obj 2",{pos.x+40,pos.y+64},ANIMATIONS["player.png"]), + 70,70,14,std::array{0,0,0,0},0,std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }), + new Entity(new Object( + NPC1_4,"Test Obj 3",{pos.x+60,pos.y+24},ANIMATIONS["player.png"]), + 70,70,14,std::array{0,0,0,0},0,std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }), + } + ,chance); }break; + case encounter::ENCOUNTER_2:{ + data=new Encounter(pos,std::array{vd2d + {pos.x+10,pos.y+24},{pos.x+30,pos.y+24},{pos.x+50,pos.y+24},{pos.x+70,pos.y+24}}, + std::vector{ + new Entity(new Object( + NPC1_4,"Test Obj",{pos.x+20,pos.y+48},ANIMATIONS["player.png"],{2,2},GREEN), + 70,70,14,std::array{0,0,0,0},0,std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }), + new Entity(new Object( + NPC1_4,"Test Obj 2",{pos.x+40,pos.y+64},ANIMATIONS["player.png"],{2,2},GREEN), + 70,70,14,std::array{0,0,0,0},0,std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }), + new Entity(new Object( + NPC1_4,"Test Obj 3",{pos.x+60,pos.y+24},ANIMATIONS["player.png"],{2,2},GREEN), + 70,70,14,std::array{0,0,0,0},0,std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }), + } + ,chance); + }break; + case encounter::ENCOUNTER_3:{ + data=new Encounter(pos,std::array{vd2d + {pos.x+10,pos.y+24},{pos.x+30,pos.y+24},{pos.x+50,pos.y+24},{pos.x+70,pos.y+24}}, + std::vector{ + new Entity(new Object( + NPC1_4,"Test Obj",{pos.x+20,pos.y+48},ANIMATIONS["player.png"],{1,1},MAGENTA), + 70,70,14,std::array{0,0,0,0},0,std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }), + } + ,chance); + }break; + default:{ + printf("WARNING! Dead encounter found! THIS SHOULD NOT BE HAPPENING!"); + } + } + map->encounters.push_back(data); + for (int i=0;iobjs.size();i++) { + AddObjectToWorld(data->objs[i]->obj); } } };