diff --git a/data/ending/ending1.png b/data/ending/ending1.png index 39df179..d3c6470 100644 Binary files a/data/ending/ending1.png and b/data/ending/ending1.png differ diff --git a/data/ending/ending1_zxarne.png b/data/ending/ending1_zxarne.png new file mode 100644 index 0000000..e6e4944 Binary files /dev/null and b/data/ending/ending1_zxarne.png differ diff --git a/data/ending/ending2_zxarne.png b/data/ending/ending2_zxarne.png new file mode 100644 index 0000000..ba44af1 Binary files /dev/null and b/data/ending/ending2_zxarne.png differ diff --git a/data/ending/ending3_zxarne.png b/data/ending/ending3_zxarne.png new file mode 100644 index 0000000..00374d6 Binary files /dev/null and b/data/ending/ending3_zxarne.png differ diff --git a/data/ending/ending4.png b/data/ending/ending4.png index bbf97bd..55c88af 100644 Binary files a/data/ending/ending4.png and b/data/ending/ending4.png differ diff --git a/data/ending/ending4_zxarne.png b/data/ending/ending4_zxarne.png new file mode 100644 index 0000000..f262b9e Binary files /dev/null and b/data/ending/ending4_zxarne.png differ diff --git a/data/ending/ending5.png b/data/ending/ending5.png index 64895b1..da39918 100644 Binary files a/data/ending/ending5.png and b/data/ending/ending5.png differ diff --git a/data/ending/ending5_zxarne.png b/data/ending/ending5_zxarne.png new file mode 100644 index 0000000..4bddd7f Binary files /dev/null and b/data/ending/ending5_zxarne.png differ diff --git a/data/title/loading_screen_bn.png b/data/title/loading_screen_bn.png index 11c0e3c..0f0b283 100644 Binary files a/data/title/loading_screen_bn.png and b/data/title/loading_screen_bn.png differ diff --git a/data/title/loading_screen_color.png b/data/title/loading_screen_color.png index 92c55f8..aa7e97a 100644 Binary files a/data/title/loading_screen_color.png and b/data/title/loading_screen_color.png differ diff --git a/source/common/resource.cpp b/source/common/resource.cpp index 15d7239..a40e15f 100644 --- a/source/common/resource.cpp +++ b/source/common/resource.cpp @@ -27,6 +27,15 @@ void Resource::loadTextures(std::vector list) } } +// Vuelve a cargar las texturas +void Resource::reLoadTextures() +{ + for (auto texture : textures) + { + texture.texture->reLoad(); + } +} + // Carga las animaciones desde una lista void Resource::loadAnimations(std::vector list) { @@ -50,6 +59,21 @@ void Resource::loadAnimations(std::vector list) } } +// Vuelve a cargar las animaciones +void Resource::reLoadAnimations() +{ + reLoadTextures(); + + for (auto a:animations) + { + // Extrae el nombre del fichero sin la extension para crear el nombre del fichero de la textura + const size_t lastIndex = a.name.find_last_of("."); + const std::string pngFile = a.name.substr(0, lastIndex) + ".png"; + delete a.animation; + a.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(a.name), options->console)); + } +} + // Carga los offsets desde una lista void Resource::loadOffsets(std::vector list) { @@ -62,6 +86,16 @@ void Resource::loadOffsets(std::vector list) } } +// Vuelve a cargar los offsets +void Resource::reLoadOffsets() +{ + for (auto o:offsets) + { + delete o.textFile; + o.textFile = new textFile_t(LoadTextFile(asset->get(o.name), options->console)); + } +} + // Carga los mapas de tiles desde una lista void Resource::loadTileMaps(std::vector list) { @@ -74,6 +108,16 @@ void Resource::loadTileMaps(std::vector list) } } +// Vuelve a cargar los mapas de tiles +void Resource::reLoadTileMaps() +{ + for (auto tm:tileMaps) + { + delete tm.tileMap; + tm.tileMap = new std::vector(loadRoomTileFile(asset->get(tm.name), options->console)); + } +} + // Carga las habitaciones desde una lista void Resource::loadRooms(std::vector list) { @@ -97,18 +141,11 @@ void Resource::loadRooms(std::vector list) } } -// Recarga las texturas -void Resource::reLoadTextures() -{ - for (auto texture : textures) - { - texture.texture->reLoad(); - } -} - -// Recarga las habitaciones +// Vuelve a cargar las habitaciones void Resource::reLoadRooms() { + reLoadTileMaps(); + for (auto r : rooms) { delete r.room; @@ -127,6 +164,14 @@ void Resource::reLoadRooms() } } +// Vuelve a cargar todos los recursos +void Resource::reLoad() +{ + reLoadAnimations(); + reLoadOffsets(); + reLoadRooms(); +} + // Libera las texturas void Resource::freeTextures() { diff --git a/source/common/resource.h b/source/common/resource.h index 691d49e..8772af6 100644 --- a/source/common/resource.h +++ b/source/common/resource.h @@ -66,24 +66,36 @@ public: // Carga las texturas de una lista void loadTextures(std::vector list); + // Vuelve a cargar las texturas + void reLoadTextures(); + // Carga las animaciones desde una lista void loadAnimations(std::vector list); + // Vuelve a cargar las animaciones + void reLoadAnimations(); + // Carga los offsets desde una lista void loadOffsets(std::vector list); + // Vuelve a cargar los offsets + void reLoadOffsets(); + // Carga los mapas de tiles desde una lista void loadTileMaps(std::vector list); + // Vuelve a cargar los mapas de tiles + void reLoadTileMaps(); + // Carga las habitaciones desde una lista void loadRooms(std::vector list); - // Recarga las texturas - void reLoadTextures(); - - // Recarga las habitaciones + // Vuelve a cargar las habitaciones void reLoadRooms(); + // Vuelve a cargar todos los recursos + void reLoad(); + // Libera las texturas void freeTextures(); diff --git a/source/game.cpp b/source/game.cpp index b98b734..17780cc 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -101,7 +101,7 @@ void Game::checkEventHandler() break; case SDL_SCANCODE_R: - resource->reLoadRooms(); + resource->reLoad(); break; case SDL_SCANCODE_M: diff --git a/source/room.cpp b/source/room.cpp index acb3792..fb03f2b 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -402,7 +402,7 @@ Room::Room(room_t *room, SDL_Renderer *renderer, Screen *screen, Asset *asset, o autoSurfaceDirection = room->autoSurfaceDirection; textureA = room->textureA; textureB = room->textureB; - tileMap = room->tileMap; + tileMap = *room->tileMap; texture = (options->palette == p_zxspectrum) ? textureA : textureB; this->jailEnabled = jailEnabled; @@ -533,13 +533,13 @@ void Room::fillMapTexture() // Al cargar el mapa en memoria, se resta uno, por tanto los tiles vacios son -1 // Tampoco hay que dibujar los tiles animados que estan en la fila 19 (indices) const int index = (y * mapWidth) + x; - const bool a = (tileMap->at(index) >= 18 * tileSetWidth) && (tileMap->at(index) < 19 * tileSetWidth); - const bool b = tileMap->at(index) > -1; + const bool a = (tileMap.at(index) >= 18 * tileSetWidth) && (tileMap.at(index) < 19 * tileSetWidth); + const bool b = tileMap.at(index) > -1; if (b && !a) { - clip.x = (tileMap->at(index) % tileSetWidth) * tileSize; - clip.y = (tileMap->at(index) / tileSetWidth) * tileSize; + clip.x = (tileMap.at(index) % tileSetWidth) * tileSize; + clip.y = (tileMap.at(index) / tileSetWidth) * tileSize; texture->render(renderer, x * tileSize, y * tileSize, &clip); // **** @@ -739,37 +739,37 @@ tile_e Room::getTile(int index) if (index < maxTile) { // Las filas 0-8 son de tiles t_wall - if ((tileMap->at(index) >= 0) && (tileMap->at(index) < 9 * tileSetWidth)) + if ((tileMap.at(index) >= 0) && (tileMap.at(index) < 9 * tileSetWidth)) { return t_wall; } // Las filas 9-17 son de tiles t_passable - else if ((tileMap->at(index) >= 9 * tileSetWidth) && (tileMap->at(index) < 18 * tileSetWidth)) + else if ((tileMap.at(index) >= 9 * tileSetWidth) && (tileMap.at(index) < 18 * tileSetWidth)) { return t_passable; } // Las filas 18-20 es de tiles t_animated - else if ((tileMap->at(index) >= 18 * tileSetWidth) && (tileMap->at(index) < 21 * tileSetWidth)) + else if ((tileMap.at(index) >= 18 * tileSetWidth) && (tileMap.at(index) < 21 * tileSetWidth)) { return t_animated; } // La fila 21 es de tiles t_slope_r - else if ((tileMap->at(index) >= 21 * tileSetWidth) && (tileMap->at(index) < 22 * tileSetWidth)) + else if ((tileMap.at(index) >= 21 * tileSetWidth) && (tileMap.at(index) < 22 * tileSetWidth)) { return t_slope_r; } // La fila 22 es de tiles t_slope_l - else if ((tileMap->at(index) >= 22 * tileSetWidth) && (tileMap->at(index) < 23 * tileSetWidth)) + else if ((tileMap.at(index) >= 22 * tileSetWidth) && (tileMap.at(index) < 23 * tileSetWidth)) { return t_slope_l; } // La fila 23 es de tiles t_kill - else if ((tileMap->at(index) >= 23 * tileSetWidth) && (tileMap->at(index) < 24 * tileSetWidth)) + else if ((tileMap.at(index) >= 23 * tileSetWidth) && (tileMap.at(index) < 24 * tileSetWidth)) { return t_kill; } @@ -897,7 +897,7 @@ void Room::setBottomSurfaces() // Busca todos los tiles de tipo muro que no tengan debajo otro muro // Hay que recorrer la habitación por filas (excepto los de la última fila) - for (int i = 0; i < (int)tileMap->size() - mapWidth; ++i) + for (int i = 0; i < (int)tileMap.size() - mapWidth; ++i) { if (getTile(i) == t_wall && getTile(i + mapWidth) != t_wall) { @@ -960,7 +960,7 @@ void Room::setTopSurfaces() // Busca todos los tiles de tipo muro o pasable que no tengan encima un muro // Hay que recorrer la habitación por filas (excepto los de la primera fila) - for (int i = mapWidth; i < (int)tileMap->size(); ++i) + for (int i = mapWidth; i < (int)tileMap.size(); ++i) { if ((getTile(i) == t_wall || getTile(i) == t_passable) && getTile(i - mapWidth) != t_wall) { @@ -1117,7 +1117,7 @@ void Room::setLeftSlopes() { // Recorre la habitación entera por filas buscando tiles de tipo t_slope_l std::vector found; - for (int i = 0; i < (int)tileMap->size(); ++i) + for (int i = 0; i < (int)tileMap.size(); ++i) { if (getTile(i) == t_slope_l) { @@ -1158,7 +1158,7 @@ void Room::setRightSlopes() { // Recorre la habitación entera por filas buscando tiles de tipo t_slope_r std::vector found; - for (int i = 0; i < (int)tileMap->size(); ++i) + for (int i = 0; i < (int)tileMap.size(); ++i) { if (getTile(i) == t_slope_r) { @@ -1201,7 +1201,7 @@ void Room::setAutoSurfaces() // Busca todos los tiles de tipo animado // Hay que recorrer la habitación por filas (excepto los de la primera fila) - for (int i = mapWidth; i < (int)tileMap->size(); ++i) + for (int i = mapWidth; i < (int)tileMap.size(); ++i) { if (getTile(i) == t_animated) { @@ -1258,7 +1258,7 @@ void Room::setAutoSurfaces() void Room::setAnimatedTiles() { // Recorre la habitación entera por filas buscando tiles de tipo t_animated - for (int i = 0; i < (int)tileMap->size(); ++i) + for (int i = 0; i < (int)tileMap.size(); ++i) { if (getTile(i) == t_animated) { @@ -1266,9 +1266,9 @@ void Room::setAnimatedTiles() const int x = (i % mapWidth) * tileSize; const int y = (i / mapWidth) * tileSize; - // TileMap->at(i) es el tile a poner - const int xc = (tileMap->at(i) % tileSetWidth) * tileSize; - const int yc = (tileMap->at(i) / tileSetWidth) * tileSize; + // TileMap.at(i) es el tile a poner + const int xc = (tileMap.at(i) % tileSetWidth) * tileSize; + const int yc = (tileMap.at(i) / tileSetWidth) * tileSize; aTile_t at; at.sprite = new Sprite(x, y, 8, 8, texture, renderer); @@ -1499,7 +1499,7 @@ void Room::openTheJail() // Abre las puertas const int tileA = 16 + (13 * 32); const int tileB = 16 + (14 * 32); - tileMap->at(tileA) = -1; - tileMap->at(tileB) = -1; + tileMap.at(tileA) = -1; + tileMap.at(tileB) = -1; } } \ No newline at end of file diff --git a/source/room.h b/source/room.h index c93e23e..b2637dc 100644 --- a/source/room.h +++ b/source/room.h @@ -76,7 +76,6 @@ private: // Objetos y punteros std::vector enemies; // Listado con los enemigos de la habitación std::vector items; // Listado con los items que hay en la habitación - std::vector *tileMap; // Indice de los tiles a dibujar en la habitación Texture *texture; // Textura con los graficos de la habitación Texture *textureA; // Textura con los graficos de la habitación Texture *textureB; // Textura con los graficos de la habitación @@ -101,6 +100,7 @@ private: std::string roomRight; // Identificador de la habitación que se encuentra a la derecha std::string tileSetFile; // Imagen con los graficos para la habitación std::string tileMapFile; // Fichero con el mapa de indices de tile + std::vector tileMap; // Indice de los tiles a dibujar en la habitación int autoSurfaceDirection; // Sentido en el que arrastran las superficies automáticas de la habitación JA_Sound itemSound; // Sonido producido al coger un objeto std::vector bottomSurfaces; // Lista con las superficies inferiores de la habitación