Bridge flags properly enabled and working. Fix image paths in maps.

This commit is contained in:
2023-07-06 14:59:21 -05:00
parent 3939ee5693
commit ef83e7f865
16 changed files with 1771 additions and 840 deletions
+4 -2
View File
@@ -13,6 +13,8 @@ void Pathfinding::Initialize(){
nodes[y * game->WORLD_SIZE.x + x].y = y;
geom2d::rect<int>tile=game->GetTileCollision(game->GetCurrentLevel(),{float(x*24),float(y*24)});
nodes[y * game->WORLD_SIZE.x + x].bObstacle = tile.pos!=game->NO_COLLISION.pos||tile.size!=game->NO_COLLISION.size;
tile=game->GetTileCollision(game->GetCurrentLevel(),{float(x*24),float(y*24)},true);
nodes[y * game->WORLD_SIZE.x + x].bObstacleUpper = tile.pos!=game->NO_COLLISION.pos||tile.size!=game->NO_COLLISION.size;
nodes[y * game->WORLD_SIZE.x + x].parent = nullptr;
nodes[y * game->WORLD_SIZE.x + x].bVisited = false;
}
@@ -43,7 +45,7 @@ void Pathfinding::Initialize(){
nodeEnd = &nodes[(game->WORLD_SIZE.y / 2) * game->WORLD_SIZE.x + game->WORLD_SIZE.x-2];
}
int Pathfinding::Solve_AStar(vf2d startPos,vf2d endPos,float maxRange){
int Pathfinding::Solve_AStar(vf2d startPos,vf2d endPos,float maxRange,bool upperLevel){
float dist=sqrt(pow(endPos.x-startPos.x,2)+pow(endPos.y-startPos.y,2));
if(dist>maxRange*24)return maxRange;
@@ -98,7 +100,7 @@ int Pathfinding::Solve_AStar(vf2d startPos,vf2d endPos,float maxRange){
nodeCurrent->bVisited = true;
for (auto nodeNeighbour : nodeCurrent->vecNeighbours)
{
if (!nodeNeighbour->bVisited && nodeNeighbour->bObstacle == 0)
if (!nodeNeighbour->bVisited && ((!upperLevel && nodeNeighbour->bObstacle == 0)||(upperLevel && nodeNeighbour->bObstacleUpper==0)))
listNotTestedNodes.push_back(nodeNeighbour);
float fPossiblyLowerGoal = nodeCurrent->fLocalGoal + distance(nodeCurrent, nodeNeighbour);