Corregido un bug con las colisiones entre un punto y una linea diagonal

This commit is contained in:
2022-09-14 21:18:50 +02:00
parent 2ff12f7db1
commit d5e5d142a4
10 changed files with 97 additions and 25 deletions

View File

@@ -25,6 +25,8 @@ Room::Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset
texture = new LTexture(renderer, asset->get(tileset));
itemSound = JA_LoadSound(asset->get("item.wav").c_str());
debug->clearLog();
debug->addToLog(tileset);
// Calcula las superficies
setBottomSurfaces();
setTopSurfaces();
@@ -43,6 +45,7 @@ Room::Room(std::string file_path, SDL_Renderer *renderer, Screen *screen, Asset
// Establece el color del borde
screen->setBorderColor(borderColor);
}
// Destructor
@@ -937,6 +940,7 @@ void Room::setLeftSlopes()
line.x2 = ((lastOneFound % mapWidth) * tileSize) + tileSize - 1;
line.y2 = ((lastOneFound / mapWidth) * tileSize) + tileSize - 1;
leftSlopes.push_back(line);
debug->addToLog("LS: " + std::to_string(line.x1) + "," + std::to_string(line.y1) + "," + std::to_string(line.x2) + "," + std::to_string(line.y2));
}
}
@@ -978,6 +982,7 @@ void Room::setRightSlopes()
line.x2 = (lastOneFound % mapWidth) * tileSize;
line.y2 = ((lastOneFound / mapWidth) * tileSize) + tileSize - 1;
rightSlopes.push_back(line);
debug->addToLog("RS: " + std::to_string(line.x1) + "," + std::to_string(line.y1) + "," + std::to_string(line.x2) + "," + std::to_string(line.y2));
}
}