Trabajando en tener todos los recursos cargados previamente

This commit is contained in:
JailDesigner committed 2022-10-05 19:17:45 +02:00
1 parent 8076d8a765
commit 83a34d61bf
20 files changed
+165 -35

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

File renamed without changes.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+13 -12
View File
@@ -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);
+139 -10
View File
@@ -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<std::string>;
balloon2Animation = new std::vector<std::string>;
balloon3Animation = new std::vector<std::string>;
balloon4Animation = new std::vector<std::string>;
fade = new Fade(renderer);
eventHandler = new SDL_Event();
std::vector<std::vector<std::string> *> *itemAnimations;
std::vector<std::vector<std::string> *> *playerAnimations;
std::vector<std::vector<std::string> *> *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<std::string> *playerHeadAnimation = new std::vector<std::string>;
loadAnimations(asset->get("player_head.ani"), playerHeadAnimation);
playerAnimations.push_back(playerHeadAnimation);
std::vector<std::string> *playerBodyAnimation = new std::vector<std::string>;
loadAnimations(asset->get("player_body.ani"), playerBodyAnimation);
playerAnimations.push_back(playerBodyAnimation);
std::vector<std::string> *playerLegsAnimation = new std::vector<std::string>;
loadAnimations(asset->get("player_legs.ani"), playerLegsAnimation);
playerAnimations.push_back(playerLegsAnimation);
std::vector<std::string> *playerDeathAnimation = new std::vector<std::string>;
loadAnimations(asset->get("player_death.ani"), playerDeathAnimation);
playerAnimations.push_back(playerDeathAnimation);
// Animaciones -- Globos
std::vector<std::string> *balloon1Animation = new std::vector<std::string>;
loadAnimations(asset->get("balloon1.ani"), balloon1Animation);
balloonAnimations.push_back(balloon1Animation);
std::vector<std::string> *balloon2Animation = new std::vector<std::string>;
loadAnimations(asset->get("balloon2.ani"), balloon2Animation);
balloonAnimations.push_back(balloon2Animation);
std::vector<std::string> *balloon3Animation = new std::vector<std::string>;
loadAnimations(asset->get("balloon3.ani"), balloon3Animation);
balloonAnimations.push_back(balloon3Animation);
std::vector<std::string> *balloon4Animation = new std::vector<std::string>;
loadAnimations(asset->get("balloon4.ani"), balloon4Animation);
balloonAnimations.push_back(balloon4Animation);
// Animaciones -- Items
std::vector<std::string> *item1Animation = new std::vector<std::string>;
loadAnimations(asset->get("item_points1_disk.ani"), item1Animation);
itemAnimations.push_back(item1Animation);
std::vector<std::string> *item2Animation = new std::vector<std::string>;
loadAnimations(asset->get("item_points2_gavina.ani"), item2Animation);
itemAnimations.push_back(item2Animation);
std::vector<std::string> *item3Animation = new std::vector<std::string>;
loadAnimations(asset->get("item_points3_pacmar.ani"), item3Animation);
itemAnimations.push_back(item3Animation);
std::vector<std::string> *item4Animation = new std::vector<std::string>;
loadAnimations(asset->get("item_clock.ani"), item4Animation);
itemAnimations.push_back(item4Animation);
std::vector<std::string> *item5Animation = new std::vector<std::string>;
loadAnimations(asset->get("item_coffee.ani"), item5Animation);
itemAnimations.push_back(item5Animation);
std::vector<std::string> *item6Animation = new std::vector<std::string>;
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);
+11 -11
View File
@@ -125,12 +125,14 @@ private:
std::vector<Item *> items; // Vector con los items
std::vector<SmartSprite *> 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<LTexture *> 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<LTexture *> itemsTexture; // Vector con las texturas de los items
std::vector<LTexture *> player1Texture; // Vector con las texturas del jugador
std::vector<LTexture *> 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<std::string> *balloon1Animation; // Información para la animación de los globos
std::vector<std::string> *balloon2Animation; // Información para la animación de los globos
std::vector<std::string> *balloon3Animation; // Información para la animación de los globos
std::vector<std::string> *balloon4Animation; // Información para la animación de los globos
std::vector<std::vector<std::string>> *itemAnimations; // Vector con las animaciones de los items
std::vector<std::vector<std::string> *> *itemAnimations; // Vector con las animaciones de los items
std::vector<std::vector<std::string> *> *playerAnimations; // Vector con las animaciones del jugador
std::vector<std::vector<std::string> *> *balloonAnimations; // Vector con las animaciones de los globos
Text *text; // Fuente para los textos del juego
Text *textBig; // Fuente de texto grande
+1 -1
View File
@@ -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<LTexture *> texture)
{
// Copia los punteros
this->renderer = renderer;
+1 -1
View File
@@ -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<LTexture *> texture, std::vector<std::vector<std::string>*> *animations);
// Destructor
~Player();