corregides cridades a SDL3 i migrat casi tot de int a float. Falta jail_shader

This commit is contained in:
2025-10-15 12:16:50 +02:00
parent 7c102e42cc
commit e4a08d2ec7
52 changed files with 879 additions and 823 deletions

View File

@@ -338,7 +338,7 @@ void Room::initializeRoom(const RoomData& room) {
// Crear los items
for (const auto& item : room.items) {
const SDL_Point itemPos = {item.x, item.y};
const SDL_FPoint itemPos = {item.x, item.y};
if (!ItemTracker::get()->hasBeenPicked(room.name, itemPos)) {
// Crear una copia local de los datos del item
@@ -361,7 +361,7 @@ void Room::fillMapTexture() {
// Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo
SDL_Rect clip = {0, 0, TILE_SIZE_, TILE_SIZE_};
SDL_FRect clip = {0, 0, TILE_SIZE_, TILE_SIZE_};
for (int y = 0; y < MAP_HEIGHT_; ++y)
for (int x = 0; x < MAP_WIDTH_; ++x) {
// Tiled pone los tiles vacios del mapa como cero y empieza a contar de 1 a n.
@@ -439,7 +439,7 @@ void Room::fillMapTexture() {
// Dibuja el mapa en pantalla
void Room::renderMap() {
// Dibuja la textura con el mapa en pantalla
SDL_Rect dest = {0, 0, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT};
SDL_FRect dest = {0, 0, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT};
map_surface_->render(nullptr, &dest);
// Dibuja los tiles animados
@@ -516,7 +516,7 @@ std::string Room::getRoom(RoomBorder border) {
}
// Devuelve el tipo de tile que hay en ese pixel
TileType Room::getTile(SDL_Point point) {
TileType Room::getTile(SDL_FPoint point) {
const int pos = ((point.y / TILE_SIZE_) * MAP_WIDTH_) + (point.x / TILE_SIZE_);
return getTile(pos);
}
@@ -562,7 +562,7 @@ TileType Room::getTile(int index) {
}
// Indica si hay colision con un enemigo a partir de un rectangulo
bool Room::enemyCollision(SDL_Rect& rect) {
bool Room::enemyCollision(SDL_FRect& rect) {
for (const auto& enemy : enemies_) {
if (checkCollision(rect, enemy->getCollider())) {
return true;
@@ -572,7 +572,7 @@ bool Room::enemyCollision(SDL_Rect& rect) {
}
// Indica si hay colision con un objeto a partir de un rectangulo
bool Room::itemCollision(SDL_Rect& rect) {
bool Room::itemCollision(SDL_FRect& rect) {
for (int i = 0; i < static_cast<int>(items_.size()); ++i) {
if (checkCollision(rect, items_.at(i)->getCollider())) {
ItemTracker::get()->addItem(name_, items_.at(i)->getPos());
@@ -588,7 +588,7 @@ bool Room::itemCollision(SDL_Rect& rect) {
}
// Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile
int Room::getSlopeHeight(SDL_Point p, TileType slope) {
int Room::getSlopeHeight(SDL_FPoint p, TileType slope) {
// Calcula la base del tile
int base = ((p.y / TILE_SIZE_) * TILE_SIZE_) + TILE_SIZE_;
#ifdef DEBUG
@@ -596,7 +596,7 @@ int Room::getSlopeHeight(SDL_Point p, TileType slope) {
#endif
// Calcula cuanto se ha entrado en el tile horizontalmente
const int pos = (p.x % TILE_SIZE_); // Esto da un valor entre 0 y 7
const int pos = (static_cast<int>(p.x) % TILE_SIZE_); // Esto da un valor entre 0 y 7
#ifdef DEBUG
Debug::get()->add("POS = " + std::to_string(pos));
#endif
@@ -950,7 +950,7 @@ void Room::updateAnimatedTiles() {
}
for (auto& a : animated_tiles_) {
SDL_Rect rect = a.sprite->getClip();
SDL_FRect rect = a.sprite->getClip();
rect.x = a.x_orig + offset;
a.sprite->setClip(rect);
}
@@ -964,7 +964,7 @@ void Room::renderAnimatedTiles() {
}
// Comprueba las colisiones
int Room::checkRightSurfaces(SDL_Rect* rect) {
int Room::checkRightSurfaces(SDL_FRect* rect) {
for (const auto& s : right_walls_) {
if (checkCollision(s, *rect)) {
return s.x;
@@ -975,7 +975,7 @@ int Room::checkRightSurfaces(SDL_Rect* rect) {
}
// Comprueba las colisiones
int Room::checkLeftSurfaces(SDL_Rect* rect) {
int Room::checkLeftSurfaces(SDL_FRect* rect) {
for (const auto& s : left_walls_) {
if (checkCollision(s, *rect)) {
return s.x;
@@ -986,7 +986,7 @@ int Room::checkLeftSurfaces(SDL_Rect* rect) {
}
// Comprueba las colisiones
int Room::checkTopSurfaces(SDL_Rect* rect) {
int Room::checkTopSurfaces(SDL_FRect* rect) {
for (const auto& s : top_floors_) {
if (checkCollision(s, *rect)) {
return s.y;
@@ -997,7 +997,7 @@ int Room::checkTopSurfaces(SDL_Rect* rect) {
}
// Comprueba las colisiones
int Room::checkBottomSurfaces(SDL_Rect* rect) {
int Room::checkBottomSurfaces(SDL_FRect* rect) {
for (const auto& s : bottom_floors_) {
if (checkCollision(s, *rect)) {
return s.y;
@@ -1008,7 +1008,7 @@ int Room::checkBottomSurfaces(SDL_Rect* rect) {
}
// Comprueba las colisiones
int Room::checkAutoSurfaces(SDL_Rect* rect) {
int Room::checkAutoSurfaces(SDL_FRect* rect) {
for (const auto& s : conveyor_belt_floors_) {
if (checkCollision(s, *rect)) {
return s.y;
@@ -1019,7 +1019,7 @@ int Room::checkAutoSurfaces(SDL_Rect* rect) {
}
// Comprueba las colisiones
bool Room::checkTopSurfaces(SDL_Point* p) {
bool Room::checkTopSurfaces(SDL_FPoint* p) {
for (const auto& s : top_floors_) {
if (checkCollision(s, *p)) {
return true;
@@ -1030,7 +1030,7 @@ bool Room::checkTopSurfaces(SDL_Point* p) {
}
// Comprueba las colisiones
bool Room::checkAutoSurfaces(SDL_Point* p) {
bool Room::checkAutoSurfaces(SDL_FPoint* p) {
for (const auto& s : conveyor_belt_floors_) {
if (checkCollision(s, *p)) {
return true;
@@ -1043,7 +1043,7 @@ bool Room::checkAutoSurfaces(SDL_Point* p) {
// Comprueba las colisiones
int Room::checkLeftSlopes(const LineVertical* line) {
for (const auto& slope : left_slopes_) {
const SDL_Point p = checkCollision(slope, *line);
const SDL_FPoint p = checkCollision(slope, *line);
if (p.x != -1) {
return p.y;
}
@@ -1053,7 +1053,7 @@ int Room::checkLeftSlopes(const LineVertical* line) {
}
// Comprueba las colisiones
bool Room::checkLeftSlopes(SDL_Point* p) {
bool Room::checkLeftSlopes(SDL_FPoint* p) {
for (const auto& slope : left_slopes_) {
if (checkCollision(*p, slope)) {
return true;
@@ -1066,7 +1066,7 @@ bool Room::checkLeftSlopes(SDL_Point* p) {
// Comprueba las colisiones
int Room::checkRightSlopes(const LineVertical* line) {
for (const auto& slope : right_slopes_) {
const SDL_Point p = checkCollision(slope, *line);
const SDL_FPoint p = checkCollision(slope, *line);
if (p.x != -1) {
return p.y;
}
@@ -1076,7 +1076,7 @@ int Room::checkRightSlopes(const LineVertical* line) {
}
// Comprueba las colisiones
bool Room::checkRightSlopes(SDL_Point* p) {
bool Room::checkRightSlopes(SDL_FPoint* p) {
for (const auto& slope : right_slopes_) {
if (checkCollision(*p, slope)) {
return true;