diff --git a/C++ProjectTemplate b/C++ProjectTemplate index c54d72c..75b9882 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 19a8794..435edbc 100644 --- a/main.cpp +++ b/main.cpp @@ -34,6 +34,7 @@ #define 액션 (CutsceneAction*)new std::vector OBJECTS; +const vd2d NO_NEIGHBOR = {-999,-999}; using namespace olc; @@ -548,6 +549,7 @@ public: std::vector PARTICLES; std::vector DAMAGE_NUMBERS; + std::map,vd2d> MOVEMENT_GRID; Effect*CURRENT_EFFECT=nullptr; @@ -1022,8 +1024,9 @@ goes on a very long time, I hope you can understand this is only for testing pur DisplayMessageBox("Not implemented yet."); }break; case 4:{ //Move selected. - DisplayMessageBox("Not implemented yet."); - //BATTLE_STATE=BattleState::MOVE_SELECT; + //DisplayMessageBox("Not implemented yet."); + BATTLE_STATE=BattleState::MOVE_SELECT; + PopulateMovementGrid(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->obj->GetPosWithOrigin(),PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->speed/2); }break; case 5:{ //Run selected. DisplayMessageBox("Not implemented yet."); @@ -1332,6 +1335,9 @@ goes on a very long time, I hope you can understand this is only for testing pur Pixel(128,0,0,255),Pixel(128,0,0,64),Pixel(200,90,90,64),true); } } + if (BATTLE_STATE==BattleState::MOVE_SELECT) { + DrawMovementGrid(YELLOW,BLUE,BLUE); + } } switch (GAME_STATE) { case GameState::GAME_WORLD:{ @@ -2812,7 +2818,7 @@ goes on a very long time, I hope you can understand this is only for testing pur if (!MoveObjectTowardsPoint(PARTY_MEMBER_OBJ[i], {BATTLE_ENCOUNTER->playerPos[i].x+BATTLE_ENCOUNTER->pos.x-PARTY_MEMBER_OBJ[i]->spr->width*0.5*(PARTY_MEMBER_OBJ[i]->GetScale().x-1), BATTLE_ENCOUNTER->playerPos[i].y+BATTLE_ENCOUNTER->pos.y-(PARTY_MEMBER_OBJ[i]->spr->spr->sprite->height-4)*1*(PARTY_MEMBER_OBJ[i]->GetScale().y-1)}, - PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD)) { + PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD)) { allDone=false; } } @@ -3306,6 +3312,66 @@ goes on a very long time, I hope you can understand this is only for testing pur DrawTargetRangeGrid(pos,range,Pixel(abs(cos(M_PI/240*frameCount)*128),200,0,255),Pixel(0,161,255,abs(sin(M_PI/240*frameCount)*32)),Pixel(139,234,255,abs(sin(M_PI/240*frameCount)*64)),false); } + void DrawMovementGrid(Pixel outlinecol,Pixel box1col,Pixel box2col) { + for (std::map,vd2d>::const_iterator it = MOVEMENT_GRID.cbegin();it!=MOVEMENT_GRID.cend();++it) { + if (it->second!=NO_NEIGHBOR) { + GradientFillRectDecal(MOVEMENT_GRID[it->first],{32,32},box1col,box2col,box1col,box2col); + const vi2d outlineOffset = {1,1}; + DrawRectDecal(MOVEMENT_GRID[it->first],{32,32},outlinecol); + DrawRectDecal(MOVEMENT_GRID[it->first]+outlineOffset,{30,30},outlinecol); + } + } + } + + void PopulateMovementGrid(vd2d pos,int range) { + vi2d gridCenter = (vi2d)pos/32*32; + MOVEMENT_GRID.clear(); + for (int x=-range+1;x,vd2d>::const_iterator it = MOVEMENT_GRID.cbegin();it!=MOVEMENT_GRID.cend();++it) { + vi2d offset = {it->first.first,it->first.second}; + for (int i=0;ifirst]==(vi2d)(BATTLE_ENCOUNTER->pos-PARTY_MEMBER_OBJ[i]->GetPosWithOrigin())/32*32) { + MOVEMENT_GRID[it->first]=NO_NEIGHBOR; + break; + } + } + for (int i=0;iobjs.size();i++) { + if (MOVEMENT_GRID[it->first]==(vi2d)(BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()-cameraPos)/32*32) { + MOVEMENT_GRID[it->first]=NO_NEIGHBOR; + break; + } + } + } + for (std::map,vd2d>::const_iterator it = MOVEMENT_GRID.cbegin();it!=MOVEMENT_GRID.cend();++it) { + int gridX = it->first.first; + int gridY = it->first.second; + vd2d pos = it->second; + bool neighborExists=false; + for (int x=-1;x<=1;x++) { + for (int y=-1;y<=1;y++) { + if (abs(x)+abs(y)==1&&MOVEMENT_GRID.count({gridX+x,gridY+y})&&MOVEMENT_GRID[{gridX+x,gridY+y}]!=NO_NEIGHBOR) { + neighborExists=true; + break; + } + } + if (neighborExists) { + break; + } + } + if (!neighborExists) { + MOVEMENT_GRID[{gridX,gridY}]=NO_NEIGHBOR; //No neighbor found. + } + } + } + vi2d grid(int x, int y) { return {x*32,y*32}; }