generated from sigonasr2/CPlusPlusProjectTemplate
Fixed blocking conditional code
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
29a57f5850
commit
c60146b898
Binary file not shown.
110
main.cpp
110
main.cpp
@ -1196,6 +1196,28 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
BATTLE_STATE=BattleState::WAIT;
|
||||
}
|
||||
}break;
|
||||
case BattleState::MOVE_SELECT:{
|
||||
if (LeftPressed()) {
|
||||
if (MOVEMENT_GRID.count({SELECTED_MOVE_SQUARE.x-1,SELECTED_MOVE_SQUARE.y})) {
|
||||
SELECTED_MOVE_SQUARE.x-=1;
|
||||
}
|
||||
}
|
||||
if (RightPressed()) {
|
||||
if (MOVEMENT_GRID.count({SELECTED_MOVE_SQUARE.x+1,SELECTED_MOVE_SQUARE.y})) {
|
||||
SELECTED_MOVE_SQUARE.x+=1;
|
||||
}
|
||||
}
|
||||
if (UpPressed()) {
|
||||
if (MOVEMENT_GRID.count({SELECTED_MOVE_SQUARE.x,SELECTED_MOVE_SQUARE.y-1})) {
|
||||
SELECTED_MOVE_SQUARE.y-=1;
|
||||
}
|
||||
}
|
||||
if (DownPressed()) {
|
||||
if (MOVEMENT_GRID.count({SELECTED_MOVE_SQUARE.x,SELECTED_MOVE_SQUARE.y+1})) {
|
||||
SELECTED_MOVE_SQUARE.y+=1;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1667,6 +1689,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
cursorOffset.x-=36*0.08;
|
||||
cursorOffset.y-=36*0.08;
|
||||
}
|
||||
cursorOffset+=SELECTED_MOVE_SQUARE*32;
|
||||
DrawDecal((vi2d)((PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->GetPosWithOrigin()-cameraPos)/32)*32+cursorOffset,SPRITES["crosshair.png"],cursorScale);
|
||||
}
|
||||
for (auto numb:DAMAGE_NUMBERS) {
|
||||
@ -3339,46 +3362,46 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
|
||||
void CheckGrid(int x,int y,vd2d pos,int lifetime) {
|
||||
if (!MOVEMENT_GRID.count({x,y})) {
|
||||
if (pos.x<0||pos.x>=WIDTH||pos.y<0||pos.y>=HEIGHT-64) {
|
||||
return;
|
||||
}
|
||||
for (int xx=0;xx<32;xx++) {
|
||||
for (int yy=0;yy<32;yy++) {
|
||||
vi2d offset={xx,yy};
|
||||
if (Collision(pos+offset)) {
|
||||
return;
|
||||
}
|
||||
if (pos.x<0||pos.x>=WIDTH||pos.y<0||pos.y>=HEIGHT-64) {
|
||||
return;
|
||||
}
|
||||
for (int xx=0;xx<32;xx++) {
|
||||
for (int yy=0;yy<32;yy++) {
|
||||
vi2d offset={xx,yy};
|
||||
if (Collision(pos+offset)) {
|
||||
std::cout<<x<<","<<y<<"\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
bool nonSolid=false; //Ran into a non-solid instance, which means we can't mark the tile, but we can continue moving through.
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
if (CURRENT_TURN!=-i-1&&pos==(vi2d)(PARTY_MEMBER_OBJ[i]->GetPosWithOrigin()-cameraPos)/32*32) {
|
||||
}
|
||||
bool nonSolid=false; //Ran into a non-solid instance, which means we can't mark the tile, but we can continue moving through.
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
if (CURRENT_TURN!=-i-1&&pos==(vi2d)(PARTY_MEMBER_OBJ[i]->GetPosWithOrigin()-cameraPos)/32*32) {
|
||||
nonSolid=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!nonSolid) {
|
||||
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
|
||||
if (pos==(vi2d)(BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()-cameraPos)/32*32) {
|
||||
nonSolid=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!nonSolid) {
|
||||
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
|
||||
if (pos==(vi2d)(BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()-cameraPos)/32*32) {
|
||||
nonSolid=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!nonSolid) {
|
||||
MOVEMENT_GRID[{x,y}]=pos;
|
||||
}
|
||||
if (lifetime>0) {
|
||||
vi2d offsetLeft = {-32,0};
|
||||
CheckGrid(x-1,y,pos+offsetLeft,lifetime-1);
|
||||
vi2d offsetRight = {32,0};
|
||||
CheckGrid(x+1,y,pos+offsetRight,lifetime-1);
|
||||
vi2d offsetUp = {0,-32};
|
||||
CheckGrid(x,y-1,pos+offsetUp,lifetime-1);
|
||||
vi2d offsetDown = {0,32};
|
||||
CheckGrid(x,y+1,pos+offsetDown,lifetime-1);
|
||||
}
|
||||
if (!nonSolid) {
|
||||
MOVEMENT_GRID[{x,y}]=pos;
|
||||
}
|
||||
if (lifetime>0) {
|
||||
vi2d offsetLeft = {-32,0};
|
||||
CheckGrid(x-1,y,pos+offsetLeft,lifetime-1);
|
||||
vi2d offsetRight = {32,0};
|
||||
CheckGrid(x+1,y,pos+offsetRight,lifetime-1);
|
||||
vi2d offsetUp = {0,-32};
|
||||
CheckGrid(x,y-1,pos+offsetUp,lifetime-1);
|
||||
vi2d offsetDown = {0,32};
|
||||
CheckGrid(x,y+1,pos+offsetDown,lifetime-1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3386,26 +3409,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
vi2d gridCenter = (vi2d)pos/32*32;
|
||||
MOVEMENT_GRID.clear();
|
||||
CheckGrid(0,0,gridCenter-cameraPos,range);
|
||||
for (std::map<std::pair<int,int>,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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user