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.
48
main.cpp
48
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;
|
BATTLE_STATE=BattleState::WAIT;
|
||||||
}
|
}
|
||||||
}break;
|
}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.x-=36*0.08;
|
||||||
cursorOffset.y-=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);
|
DrawDecal((vi2d)((PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->GetPosWithOrigin()-cameraPos)/32)*32+cursorOffset,SPRITES["crosshair.png"],cursorScale);
|
||||||
}
|
}
|
||||||
for (auto numb:DAMAGE_NUMBERS) {
|
for (auto numb:DAMAGE_NUMBERS) {
|
||||||
@ -3339,7 +3362,6 @@ 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) {
|
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) {
|
if (pos.x<0||pos.x>=WIDTH||pos.y<0||pos.y>=HEIGHT-64) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3347,6 +3369,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
for (int yy=0;yy<32;yy++) {
|
for (int yy=0;yy<32;yy++) {
|
||||||
vi2d offset={xx,yy};
|
vi2d offset={xx,yy};
|
||||||
if (Collision(pos+offset)) {
|
if (Collision(pos+offset)) {
|
||||||
|
std::cout<<x<<","<<y<<"\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3362,6 +3385,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
|
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
|
||||||
if (pos==(vi2d)(BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()-cameraPos)/32*32) {
|
if (pos==(vi2d)(BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()-cameraPos)/32*32) {
|
||||||
nonSolid=true;
|
nonSolid=true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3380,32 +3404,12 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
CheckGrid(x,y+1,pos+offsetDown,lifetime-1);
|
CheckGrid(x,y+1,pos+offsetDown,lifetime-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void PopulateMovementGrid(vd2d pos,int range) {
|
void PopulateMovementGrid(vd2d pos,int range) {
|
||||||
vi2d gridCenter = (vi2d)pos/32*32;
|
vi2d gridCenter = (vi2d)pos/32*32;
|
||||||
MOVEMENT_GRID.clear();
|
MOVEMENT_GRID.clear();
|
||||||
CheckGrid(0,0,gridCenter-cameraPos,range);
|
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) {
|
vi2d grid(int x, int y) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user