diff --git a/data/gfx/player2_body.png b/data/gfx/player2_body.png deleted file mode 100644 index 55f137e..0000000 Binary files a/data/gfx/player2_body.png and /dev/null differ diff --git a/data/gfx/player2_head.png b/data/gfx/player2_head.png deleted file mode 100644 index 3ba0aec..0000000 Binary files a/data/gfx/player2_head.png and /dev/null differ diff --git a/data/gfx/player2_legs.png b/data/gfx/player2_legs.png deleted file mode 100644 index 55b2c86..0000000 Binary files a/data/gfx/player2_legs.png and /dev/null differ diff --git a/data/gfx/player_arounder_body.png b/data/gfx/player_arounder_body.png new file mode 100644 index 0000000..ec8aa4c Binary files /dev/null and b/data/gfx/player_arounder_body.png differ diff --git a/data/gfx/player2_death.png b/data/gfx/player_arounder_death.png similarity index 100% rename from data/gfx/player2_death.png rename to data/gfx/player_arounder_death.png diff --git a/data/gfx/player_arounder_head.png b/data/gfx/player_arounder_head.png new file mode 100644 index 0000000..de58b3a Binary files /dev/null and b/data/gfx/player_arounder_head.png differ diff --git a/data/gfx/player_arounder_legs.png b/data/gfx/player_arounder_legs.png new file mode 100644 index 0000000..cbc353b Binary files /dev/null and b/data/gfx/player_arounder_legs.png differ diff --git a/data/gfx/new_player1_body.png b/data/gfx/player_bal1_body.png similarity index 100% rename from data/gfx/new_player1_body.png rename to data/gfx/player_bal1_body.png diff --git a/data/gfx/new_player1_death.png b/data/gfx/player_bal1_death.png similarity index 100% rename from data/gfx/new_player1_death.png rename to data/gfx/player_bal1_death.png diff --git a/data/gfx/new_player1_head.png b/data/gfx/player_bal1_head.png similarity index 100% rename from data/gfx/new_player1_head.png rename to data/gfx/player_bal1_head.png diff --git a/data/gfx/new_player1_legs.png b/data/gfx/player_bal1_legs.png similarity index 100% rename from data/gfx/new_player1_legs.png rename to data/gfx/player_bal1_legs.png diff --git a/data/gfx/new_player1_body.ani b/data/gfx/player_body.ani similarity index 100% rename from data/gfx/new_player1_body.ani rename to data/gfx/player_body.ani diff --git a/data/gfx/new_player1_death.ani b/data/gfx/player_death.ani similarity index 100% rename from data/gfx/new_player1_death.ani rename to data/gfx/player_death.ani diff --git a/data/gfx/new_player1_head.ani b/data/gfx/player_head.ani similarity index 100% rename from data/gfx/new_player1_head.ani rename to data/gfx/player_head.ani diff --git a/data/gfx/new_player1_legs.ani b/data/gfx/player_legs.ani similarity index 100% rename from data/gfx/new_player1_legs.ani rename to data/gfx/player_legs.ani diff --git a/source/director.cpp b/source/director.cpp index f10270c..3693cb0 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -230,19 +230,20 @@ bool Director::setFileList() asset->add("data/gfx/title_dust.ani", t_data); asset->add("data/gfx/title_gradient.png", t_bitmap); - asset->add("data/gfx/new_player1_head.png", t_bitmap); - asset->add("data/gfx/new_player1_head.ani", t_data); - asset->add("data/gfx/new_player1_body.png", t_bitmap); - asset->add("data/gfx/new_player1_body.ani", t_data); - asset->add("data/gfx/new_player1_legs.png", t_bitmap); - asset->add("data/gfx/new_player1_legs.ani", t_data); - asset->add("data/gfx/new_player1_death.png", t_bitmap); - asset->add("data/gfx/new_player1_death.ani", t_data); + asset->add("data/gfx/player_head.ani", t_data); + asset->add("data/gfx/player_body.ani", t_data); + asset->add("data/gfx/player_legs.ani", t_data); + asset->add("data/gfx/player_death.ani", t_data); - asset->add("data/gfx/player2_head.png", t_bitmap); - asset->add("data/gfx/player2_body.png", t_bitmap); - asset->add("data/gfx/player2_legs.png", t_bitmap); - asset->add("data/gfx/player2_death.png", t_bitmap); + asset->add("data/gfx/player_bal1_head.png", t_bitmap); + asset->add("data/gfx/player_bal1_body.png", t_bitmap); + asset->add("data/gfx/player_bal1_legs.png", t_bitmap); + asset->add("data/gfx/player_bal1_death.png", t_bitmap); + + asset->add("data/gfx/player_arounder_head.png", t_bitmap); + asset->add("data/gfx/player_arounder_body.png", t_bitmap); + asset->add("data/gfx/player_arounder_legs.png", t_bitmap); + asset->add("data/gfx/player_arounder_death.png", t_bitmap); // Fuentes asset->add("data/font/8bithud.png", t_font); diff --git a/source/game.cpp b/source/game.cpp index b768ed5..fb01c39 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -24,13 +24,13 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr difficulty = options->difficulty; // Crea los objetos - balloon1Animation = new std::vector; - balloon2Animation = new std::vector; - balloon3Animation = new std::vector; - balloon4Animation = new std::vector; fade = new Fade(renderer); eventHandler = new SDL_Event(); + std::vector *> *itemAnimations; + std::vector *> *playerAnimations; + std::vector *> *balloonAnimations; + // Carga los recursos loadMedia(); @@ -79,11 +79,6 @@ Game::~Game() balloon4Texture->unload(); delete balloon4Texture; - delete balloon1Animation; - delete balloon2Animation; - delete balloon3Animation; - delete balloon4Animation; - bulletTexture->unload(); delete bulletTexture; @@ -108,6 +103,45 @@ Game::~Game() itemTexture->unload(); delete itemTexture; + for (auto texture : itemsTexture) + { + texture->unload(); + delete texture; + } + itemsTexture.clear(); + + for (auto animation : playerAnimations) + { + delete animation; + } + playerAnimations.clear(); + + for (auto animation : balloonAnimations) + { + delete animation; + } + balloonAnimations.clear(); + + for (auto animation : itemAnimations) + { + delete animation; + } + itemAnimations.clear(); + + for (auto texture : player1Texture) + { + texture->unload(); + delete texture; + } + player1Texture.clear(); + + for (auto texture : player2Texture) + { + texture->unload(); + delete texture; + } + player2Texture.clear(); + delete text; delete textBig; delete textScoreBoard; @@ -351,11 +385,106 @@ void Game::loadMedia() gameTextTexture = new LTexture(renderer, asset->get("game_text.png")); itemTexture = new LTexture(renderer, asset->get("items.png")); - // Animaciones + LTexture *item1 = new LTexture(renderer, asset->get("item_points1_disk.png")); + itemsTexture.push_back(item1); + + LTexture *item2 = new LTexture(renderer, asset->get("item_points2_gavina.png")); + itemsTexture.push_back(item2); + + LTexture *item3 = new LTexture(renderer, asset->get("item_points3_pacmar.png")); + itemsTexture.push_back(item3); + + LTexture *item4 = new LTexture(renderer, asset->get("item_clock.png")); + itemsTexture.push_back(item4); + + LTexture *item5 = new LTexture(renderer, asset->get("item_coffee.png")); + itemsTexture.push_back(item5); + + LTexture *item6 = new LTexture(renderer, asset->get("item_coffee_machine.png")); + itemsTexture.push_back(item6); + + LTexture *player1Head = new LTexture(renderer, asset->get("player_bal1_head.png")); + player1Texture.push_back(player1Head); + + LTexture *player1Body = new LTexture(renderer, asset->get("player_bal1_body.png")); + player1Texture.push_back(player1Body); + + LTexture *player1Legs = new LTexture(renderer, asset->get("player_bal1_legs.png")); + player1Texture.push_back(player1Legs); + + LTexture *player1Death = new LTexture(renderer, asset->get("player_bal1_death.png")); + player1Texture.push_back(player1Death); + + LTexture *player2Head = new LTexture(renderer, asset->get("player_arounder_head.png")); + player2Texture.push_back(player2Head); + + LTexture *player2Body = new LTexture(renderer, asset->get("player_arounder_body.png")); + player2Texture.push_back(player2Body); + + LTexture *player2Legs = new LTexture(renderer, asset->get("player_arounder_legs.png")); + player2Texture.push_back(player2Legs); + + LTexture *player2Death = new LTexture(renderer, asset->get("player_arounder_death.png")); + player2Texture.push_back(player2Death); + + // Animaciones -- Jugador + std::vector *playerHeadAnimation = new std::vector; + loadAnimations(asset->get("player_head.ani"), playerHeadAnimation); + playerAnimations.push_back(playerHeadAnimation); + + std::vector *playerBodyAnimation = new std::vector; + loadAnimations(asset->get("player_body.ani"), playerBodyAnimation); + playerAnimations.push_back(playerBodyAnimation); + + std::vector *playerLegsAnimation = new std::vector; + loadAnimations(asset->get("player_legs.ani"), playerLegsAnimation); + playerAnimations.push_back(playerLegsAnimation); + + std::vector *playerDeathAnimation = new std::vector; + loadAnimations(asset->get("player_death.ani"), playerDeathAnimation); + playerAnimations.push_back(playerDeathAnimation); + + // Animaciones -- Globos + std::vector *balloon1Animation = new std::vector; loadAnimations(asset->get("balloon1.ani"), balloon1Animation); + balloonAnimations.push_back(balloon1Animation); + + std::vector *balloon2Animation = new std::vector; loadAnimations(asset->get("balloon2.ani"), balloon2Animation); + balloonAnimations.push_back(balloon2Animation); + + std::vector *balloon3Animation = new std::vector; loadAnimations(asset->get("balloon3.ani"), balloon3Animation); + balloonAnimations.push_back(balloon3Animation); + + std::vector *balloon4Animation = new std::vector; loadAnimations(asset->get("balloon4.ani"), balloon4Animation); + balloonAnimations.push_back(balloon4Animation); + + // Animaciones -- Items + std::vector *item1Animation = new std::vector; + loadAnimations(asset->get("item_points1_disk.ani"), item1Animation); + itemAnimations.push_back(item1Animation); + + std::vector *item2Animation = new std::vector; + loadAnimations(asset->get("item_points2_gavina.ani"), item2Animation); + itemAnimations.push_back(item2Animation); + + std::vector *item3Animation = new std::vector; + loadAnimations(asset->get("item_points3_pacmar.ani"), item3Animation); + itemAnimations.push_back(item3Animation); + + std::vector *item4Animation = new std::vector; + loadAnimations(asset->get("item_clock.ani"), item4Animation); + itemAnimations.push_back(item4Animation); + + std::vector *item5Animation = new std::vector; + loadAnimations(asset->get("item_coffee.ani"), item5Animation); + itemAnimations.push_back(item5Animation); + + std::vector *item6Animation = new std::vector; + loadAnimations(asset->get("item_coffee_machine.ani"), item6Animation); + itemAnimations.push_back(item6Animation); // Texto text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer); diff --git a/source/game.h b/source/game.h index 8c76965..22d7e83 100644 --- a/source/game.h +++ b/source/game.h @@ -125,12 +125,14 @@ private: std::vector items; // Vector con los items std::vector smartSprites; // Vector con los smartsprites - LTexture *balloon1Texture; // Textura para los globos - LTexture *balloon2Texture; // Textura para los globos - LTexture *balloon3Texture; // Textura para los globos - LTexture *balloon4Texture; // Textura para los globos - LTexture *bulletTexture; // Textura para las balas - std::vector itemTexture; // Vector con las texturas de los items + LTexture *balloon1Texture; // Textura para los globos + LTexture *balloon2Texture; // Textura para los globos + LTexture *balloon3Texture; // Textura para los globos + LTexture *balloon4Texture; // Textura para los globos + LTexture *bulletTexture; // Textura para las balas + std::vector itemsTexture; // Vector con las texturas de los items + std::vector player1Texture; // Vector con las texturas del jugador + std::vector player2Texture; // Vector con las texturas del jugador LTexture *gameBuildingsTexture; // Textura con los edificios de fondo LTexture *gameCloudsTexture; // Textura con las nubes de fondo @@ -141,11 +143,9 @@ private: LTexture *itemTexture; // Textura para los items - std::vector *balloon1Animation; // Información para la animación de los globos - std::vector *balloon2Animation; // Información para la animación de los globos - std::vector *balloon3Animation; // Información para la animación de los globos - std::vector *balloon4Animation; // Información para la animación de los globos - std::vector> *itemAnimations; // Vector con las animaciones de los items + std::vector *> *itemAnimations; // Vector con las animaciones de los items + std::vector *> *playerAnimations; // Vector con las animaciones del jugador + std::vector *> *balloonAnimations; // Vector con las animaciones de los globos Text *text; // Fuente para los textos del juego Text *textBig; // Fuente de texto grande diff --git a/source/player.cpp b/source/player.cpp index 1584721..9597fbf 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -2,7 +2,7 @@ #include "player.h" // Constructor -Player::Player(SDL_Renderer *renderer, Asset *asset, float x, int y) +Player::Player(float x, int y, SDL_Renderer *renderer, std::vector texture) { // Copia los punteros this->renderer = renderer; diff --git a/source/player.h b/source/player.h index 086347d..32c7cdd 100644 --- a/source/player.h +++ b/source/player.h @@ -106,7 +106,7 @@ public: Uint16 powerUpCounter; // Temporizador para el modo PowerUp // Constructor - Player(SDL_Renderer *renderer, Asset *asset, float x, int y); + Player(float x, int y, SDL_Renderer *renderer, std::vector texture, std::vector*> *animations); // Destructor ~Player();