Limpieza y organización de código

This commit is contained in:
2022-10-19 10:34:33 +02:00
parent 7288792940
commit d5dfc952c2
13 changed files with 19 additions and 140 deletions

View File

@@ -38,12 +38,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i
anchor.middle = gameCanvasHeight / 2;
}
// Destructor
Screen::~Screen()
{
renderer = nullptr;
}
// Limpia la pantalla
void Screen::clean(color_t color)
{
@@ -293,30 +287,12 @@ void Screen::iniSpectrumFade()
spectrumColor.clear();
color_t c;
c = stringToColor("black");
spectrumColor.push_back(c);
c = stringToColor("blue");
spectrumColor.push_back(c);
c = stringToColor("red");
spectrumColor.push_back(c);
c = stringToColor("magenta");
spectrumColor.push_back(c);
c = stringToColor("green");
spectrumColor.push_back(c);
c = stringToColor("cyan");
spectrumColor.push_back(c);
c = stringToColor("yellow");
spectrumColor.push_back(c);
c = stringToColor("bright_white");
spectrumColor.push_back(c);
// Inicializa el vector de colores
const std::vector<std::string> vColors = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
for (auto v : vColors)
{
spectrumColor.push_back(stringToColor(v));
}
}
// Actualiza el spectrum fade

View File

@@ -70,9 +70,6 @@ public:
// Constructor
Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, int gameInternalResX, int gameInternalResY);
// Destructor
~Screen();
// Limpia la pantalla
void clean(color_t color = {0x00, 0x00, 0x00});

View File

@@ -47,13 +47,6 @@ Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
enabled = true;
}
// Destructor
Sprite::~Sprite()
{
texture = nullptr;
renderer = nullptr;
}
// Muestra el sprite por pantalla
void Sprite::render()
{

View File

@@ -27,9 +27,6 @@ public:
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer);
// Destructor
~Sprite();
// Muestra el sprite por pantalla
void render();

View File

@@ -57,11 +57,6 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, D
Game::~Game()
{
// Borra las referencias a los punteros
renderer = nullptr;
asset = nullptr;
input = nullptr;
// Libera la memoria de los objetos
delete scoreboard;
delete itemTracker;

View File

@@ -71,8 +71,6 @@ Intro::~Intro()
JA_DeleteMusic(loadingSound1);
JA_DeleteMusic(loadingSound2);
JA_DeleteMusic(loadingSound3);
// delete text;
}
// Comprueba el manejador de eventos

View File

@@ -29,14 +29,6 @@ Item::Item(item_t item)
c = item.color2;
color.push_back(c);
color.push_back(c);
/*
const std::vector<std::string> vColors = {"blue", "red", "magenta", "green", "cyan", "yellow"};
for (auto v:vColors)
{
color.push_back(stringToColor(v));
}
*/
}
// Destructor

View File

@@ -1,10 +1,5 @@
#include "item_tracker.h"
// Constructor
ItemTracker::ItemTracker()
{
}
// Destructor
ItemTracker::~ItemTracker()
{

View File

@@ -26,9 +26,6 @@ private:
int findByPos(int index, SDL_Point pos);
public:
// Constructor
ItemTracker();
// Destructor
~ItemTracker();

View File

@@ -40,29 +40,12 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int subsection)
endLogo = 400;
postLogo = 20;
color_t c = stringToColor("black");
color.push_back(c);
c = stringToColor("blue");
color.push_back(c);
c = stringToColor("red");
color.push_back(c);
c = stringToColor("magenta");
color.push_back(c);
c = stringToColor("green");
color.push_back(c);
c = stringToColor("cyan");
color.push_back(c);
c = stringToColor("yellow");
color.push_back(c);
c = stringToColor("bright_white");
color.push_back(c);
// Inicializa el vector de colores
const std::vector<std::string> vColors = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
for (auto v : vColors)
{
color.push_back(stringToColor(v));
}
// Cambia el color del borde
screen->setBorderColor(stringToColor("black"));

View File

@@ -24,48 +24,12 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, board_t *board)
timePaused = 0;
totalTimePaused = 0;
// Inicializa los colores
color_t c = stringToColor("blue");
color.push_back(c);
// c = stringToColor("red");
// color.push_back(c);
c = stringToColor("magenta");
color.push_back(c);
c = stringToColor("green");
color.push_back(c);
c = stringToColor("cyan");
color.push_back(c);
c = stringToColor("yellow");
color.push_back(c);
c = stringToColor("white");
color.push_back(c);
c = stringToColor("bright_blue");
color.push_back(c);
// c = stringToColor("bright_red");
// color.push_back(c);
c = stringToColor("bright_magenta");
color.push_back(c);
c = stringToColor("bright_green");
color.push_back(c);
c = stringToColor("bright_cyan");
color.push_back(c);
c = stringToColor("bright_yellow");
color.push_back(c);
c = stringToColor("bright_white");
color.push_back(c);
// Inicializa el vector de colores
const std::vector<std::string> vColors = {"blue", "magenta", "green", "cyan", "yellow", "white", "bright_blue", "bright_magenta", "bright_green", "bright_cyan", "bright_yellow", "bright_white"};
for (auto v : vColors)
{
color.push_back(stringToColor(v));
}
}
// Destructor

View File

@@ -25,11 +25,6 @@ Test::Test(SDL_Renderer *renderer, Screen *screen, Asset *asset, Debug *debug)
}
}
// Destructor
Test::~Test()
{
}
// Actualiza las variables
void Test::update()
{

View File

@@ -36,9 +36,6 @@ public:
// Constructor
Test(SDL_Renderer *renderer, Screen *screen, Asset *asset, Debug *debug);
// Destructor
~Test();
// Actualiza las variables
void update();