|
|
|
@ -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,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) { |
|
|
|
|
if (!MOVEMENT_GRID.count({x,y})) { |
|
|
|
|
if (pos.x<0||pos.x>=WIDTH||pos.y<0||pos.y>=HEIGHT-64) { |
|
|
|
|
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++) { |
|
|
|
|
vi2d offset={xx,yy}; |
|
|
|
|
if (Collision(pos+offset)) { |
|
|
|
|
std::cout<<x<<","<<y<<"\n"; |
|
|
|
|
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++) { |
|
|
|
|
if (pos==(vi2d)(BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()-cameraPos)/32*32) { |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PopulateMovementGrid(vd2d pos,int range) { |
|
|
|
|
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) { |
|
|
|
|