Muntat a c++14 per a make_unique

Mes autos, const i constexpr perl codi
Ara la classe Screen es un poc pitjor
This commit is contained in:
2024-10-06 14:58:00 +02:00
parent 25a2753b13
commit afe092c742
16 changed files with 290 additions and 381 deletions

View File

@@ -25,8 +25,8 @@ INCLUDES:= -I$(DIR_SOURCES)
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
FixPath = $(subst /,\,$1) FixPath = $(subst /,\,$1)
SOURCES := source/*.cpp SOURCES := source/*.cpp
CXXFLAGS:= -std=c++11 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows CXXFLAGS:= -std=c++14 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows
CXXFLAGS_DEBUG:= -std=c++11 -Wall CXXFLAGS_DEBUG:= -std=c++14 -Wall
LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32 LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32
RM = del /Q RM = del /Q
MKD:= mkdir MKD:= mkdir
@@ -34,8 +34,8 @@ else
FixPath = $1 FixPath = $1
SOURCES := $(shell find $(DIR_SOURCES) -name '*.cpp') SOURCES := $(shell find $(DIR_SOURCES) -name '*.cpp')
SOURCES := source/*.cpp SOURCES := source/*.cpp
CXXFLAGS:= -std=c++11 -Wall -Os -ffunction-sections -fdata-sections CXXFLAGS:= -std=c++14 -Wall -Os -ffunction-sections -fdata-sections
CXXFLAGS_DEBUG:= -std=c++11 -Wall CXXFLAGS_DEBUG:= -std=c++14 -Wall
LDFLAGS := -lSDL2 LDFLAGS := -lSDL2
RM = rm -f RM = rm -f
MKD:= mkdir -p MKD:= mkdir -p

View File

@@ -13,14 +13,13 @@ constexpr int BULLET_VELX_RIGHT = 2;
// Constructor // Constructor
Bullet::Bullet(int x, int y, BulletType kind, bool poweredUp, int owner, SDL_Rect *playArea, Texture *texture) Bullet::Bullet(int x, int y, BulletType kind, bool poweredUp, int owner, SDL_Rect *playArea, Texture *texture)
: posX(x), posY(y), width(BULLET_WIDTH), height(BULLET_HEIGHT), velX(0), velY(BULLET_VELY), : posX(x), posY(y), width(BULLET_WIDTH), height(BULLET_HEIGHT), velX(0), velY(BULLET_VELY),
kind(kind), owner(owner), playArea(playArea), kind(kind), owner(owner), playArea(playArea)
sprite(std::unique_ptr<Sprite>(new Sprite(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture))) // Crear manualmente el std::unique_ptr
{ {
velX = (kind == BulletType::LEFT) ? BULLET_VELX_LEFT : (kind == BulletType::RIGHT) ? BULLET_VELX_RIGHT velX = (kind == BulletType::LEFT) ? BULLET_VELX_LEFT : (kind == BulletType::RIGHT) ? BULLET_VELX_RIGHT : 0;
: 0;
auto spriteOffset = poweredUp ? 3 : 0; auto spriteOffset = poweredUp ? 3 : 0;
auto kindIndex = static_cast<int>(kind); auto kindIndex = static_cast<int>(kind);
sprite = std::make_unique<Sprite>(SDL_Rect{x, y, BULLET_WIDTH, BULLET_HEIGHT}, texture);
sprite->setSpriteClip((kindIndex + spriteOffset) * width, 0, sprite->getWidth(), sprite->getHeight()); sprite->setSpriteClip((kindIndex + spriteOffset) * width, 0, sprite->getWidth(), sprite->getHeight());
collider.r = width / 2; collider.r = width / 2;

View File

@@ -117,7 +117,7 @@ Director::~Director()
Asset::destroy(); Asset::destroy();
Input::destroy(); Input::destroy();
Screen::destroy(); //Screen::destroy();
OnScreenHelp::destroy(); OnScreenHelp::destroy();
deleteSounds(); deleteSounds();
@@ -275,7 +275,7 @@ bool Director::initSDL()
#endif #endif
// Establece el filtro de la textura // Establece el filtro de la textura
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(options.video.filter).c_str())) if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(static_cast<int>(options.video.filter)).c_str()))
{ {
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Warning: texture filtering not enabled!\n"; std::cout << "Warning: texture filtering not enabled!\n";
@@ -486,12 +486,6 @@ bool Director::setFileList()
void Director::loadParams(std::string filepath) void Director::loadParams(std::string filepath)
{ {
loadParamsFromFile(filepath); loadParamsFromFile(filepath);
// Modifica las opciones desde el fichero de parametros
options.video.window.width = options.video.window.size * param.game.width;
options.video.window.height = options.video.window.size * param.game.height;
options.video.gameWidth = param.game.width;
options.video.gameHeight = param.game.height;
} }
// Comprueba los parametros del programa // Comprueba los parametros del programa

View File

@@ -52,12 +52,14 @@ Game::Game(int playerID, int currentStage, bool demo, JA_Music_t *music)
difficulty = options.game.difficulty; difficulty = options.game.difficulty;
// Crea los objetos // Crea los objetos
fade = new Fade(renderer); Scoreboard::init(renderer);
eventHandler = new SDL_Event(); scoreboard = Scoreboard::get();
scoreboard = new Scoreboard(renderer); eventHandler = std::make_unique<SDL_Event>();
background = new Background(renderer); fade = std::make_unique<Fade>(renderer);
explosions = new Explosions();
enemyFormations = new EnemyFormations(); background = std::make_unique<Background>(renderer);
explosions = std::make_unique<Explosions>();
enemyFormations = std::make_unique<EnemyFormations>();
// Carga los recursos // Carga los recursos
loadMedia(); loadMedia();
@@ -65,17 +67,17 @@ Game::Game(int playerID, int currentStage, bool demo, JA_Music_t *music)
// Inicializa los vectores con los datos para la demo // Inicializa los vectores con los datos para la demo
if (demo) if (demo)
{ // Aleatoriza la asignación del fichero { // Aleatoriza la asignación del fichero
const int index1 = rand() % 2; const auto index1 = rand() % 2;
const int index2 = (index1 + 1) % 2; const auto index2 = (index1 + 1) % 2;
loadDemoFile(asset->get("demo1.bin"), &this->demo.dataFile[index1]); loadDemoFile(asset->get("demo1.bin"), &this->demo.dataFile[index1]);
loadDemoFile(asset->get("demo2.bin"), &this->demo.dataFile[index2]); loadDemoFile(asset->get("demo2.bin"), &this->demo.dataFile[index2]);
} }
background->setPos(param.game.playArea.rect); background->setPos(param.game.playArea.rect);
n1000Sprite = new SmartSprite(gameTextTexture); n1000Sprite = std::make_unique<SmartSprite>(gameTextTexture.get());
n2500Sprite = new SmartSprite(gameTextTexture); n2500Sprite = std::make_unique<SmartSprite>(gameTextTexture.get());
n5000Sprite = new SmartSprite(gameTextTexture); n5000Sprite = std::make_unique<SmartSprite>(gameTextTexture.get());
explosions->addTexture(1, explosionsTextures[0], explosionsAnimations[0]); explosions->addTexture(1, explosionsTextures[0], explosionsAnimations[0]);
explosions->addTexture(2, explosionsTextures[1], explosionsAnimations[1]); explosions->addTexture(2, explosionsTextures[1], explosionsAnimations[1]);
@@ -92,9 +94,8 @@ Game::Game(int playerID, int currentStage, bool demo, JA_Music_t *music)
Game::~Game() Game::~Game()
{ {
// Guarda las puntuaciones en un fichero // Guarda las puntuaciones en un fichero
ManageHiScoreTable *manager = new ManageHiScoreTable(&options.game.hiScoreTable); auto manager = std::make_unique<ManageHiScoreTable>(&options.game.hiScoreTable);
manager->saveToFile(asset->get("score.bin")); manager->saveToFile(asset->get("score.bin"));
delete manager;
#ifdef RECORDING #ifdef RECORDING
saveDemoFile(asset->get("demo1.bin")); saveDemoFile(asset->get("demo1.bin"));
#endif #endif
@@ -105,17 +106,7 @@ Game::~Game()
// Libera los recursos // Libera los recursos
unloadMedia(); unloadMedia();
delete scoreboard; Scoreboard::destroy();
delete background;
delete explosions;
delete enemyFormations;
delete fade;
delete eventHandler;
delete n1000Sprite;
delete n2500Sprite;
delete n5000Sprite;
SDL_DestroyTexture(canvas); SDL_DestroyTexture(canvas);
} }
@@ -163,7 +154,7 @@ void Game::init(int playerID)
// Variables relacionadas con la dificultad // Variables relacionadas con la dificultad
switch (difficulty) switch (difficulty)
{ {
case DIFFICULTY_EASY: case gameDifficulty::EASY:
{ {
defaultEnemySpeed = BALLOON_SPEED_1; defaultEnemySpeed = BALLOON_SPEED_1;
difficultyScoreMultiplier = 0.5f; difficultyScoreMultiplier = 0.5f;
@@ -172,7 +163,7 @@ void Game::init(int playerID)
break; break;
} }
case DIFFICULTY_NORMAL: case gameDifficulty::NORMAL:
{ {
defaultEnemySpeed = BALLOON_SPEED_1; defaultEnemySpeed = BALLOON_SPEED_1;
difficultyScoreMultiplier = 1.0f; difficultyScoreMultiplier = 1.0f;
@@ -181,7 +172,7 @@ void Game::init(int playerID)
break; break;
} }
case DIFFICULTY_HARD: case gameDifficulty::HARD:
{ {
defaultEnemySpeed = BALLOON_SPEED_5; defaultEnemySpeed = BALLOON_SPEED_5;
difficultyScoreMultiplier = 1.5f; difficultyScoreMultiplier = 1.5f;
@@ -312,10 +303,10 @@ void Game::init(int playerID)
evaluateAndSetMenace(); evaluateAndSetMenace();
// Inicializa el bitmap de 1000 puntos // Inicializa el bitmap de 1000 puntos
const int height = 15; constexpr int height = 15;
const int sprite1Width = 35; constexpr int sprite1Width = 35;
const int sprite2Width = 38; constexpr int sprite2Width = 38;
const int sprite3Width = 39; constexpr int sprite3Width = 39;
n1000Sprite->setPosX(0); n1000Sprite->setPosX(0);
n1000Sprite->setPosY(0); n1000Sprite->setPosY(0);
n1000Sprite->setWidth(sprite1Width); n1000Sprite->setWidth(sprite1Width);
@@ -379,8 +370,8 @@ void Game::loadMedia()
explosionsTextures.clear(); explosionsTextures.clear();
// Texturas // Texturas
bulletTexture = new Texture(renderer, asset->get("bullet.png")); bulletTexture = std::make_unique<Texture>(renderer, asset->get("bullet.png"));
gameTextTexture = new Texture(renderer, asset->get("game_text.png")); gameTextTexture = std::make_unique<Texture>(renderer, asset->get("game_text.png"));
// Texturas - Globos // Texturas - Globos
Texture *balloon1Texture = new Texture(renderer, asset->get("balloon1.png")); Texture *balloon1Texture = new Texture(renderer, asset->get("balloon1.png"));
@@ -566,9 +557,6 @@ void Game::loadMedia()
void Game::unloadMedia() void Game::unloadMedia()
{ {
// Texturas // Texturas
delete bulletTexture;
delete gameTextTexture;
for (auto texture : player1Textures) for (auto texture : player1Textures)
{ {
if (texture) if (texture)
@@ -1059,7 +1047,7 @@ void Game::setBalloonSpeed(float speed)
void Game::incBalloonSpeed() void Game::incBalloonSpeed()
{ {
// La velocidad solo se incrementa en el modo normal // La velocidad solo se incrementa en el modo normal
if (difficulty == DIFFICULTY_NORMAL) if (difficulty == gameDifficulty::NORMAL)
{ {
if (enemySpeed == BALLOON_SPEED_1) if (enemySpeed == BALLOON_SPEED_1)
{ {
@@ -1089,7 +1077,7 @@ void Game::incBalloonSpeed()
void Game::decBalloonSpeed() void Game::decBalloonSpeed()
{ {
// La velocidad solo se decrementa en el modo normal // La velocidad solo se decrementa en el modo normal
if (difficulty == DIFFICULTY_NORMAL) if (difficulty == gameDifficulty::NORMAL)
{ {
if (enemySpeed == BALLOON_SPEED_5) if (enemySpeed == BALLOON_SPEED_5)
{ {
@@ -1383,21 +1371,21 @@ void Game::checkPlayerItemCollision(Player *player)
case ITEM_POINTS_1_DISK: case ITEM_POINTS_1_DISK:
player->addScore(1000); player->addScore(1000);
updateHiScore(); updateHiScore();
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n1000Sprite->getWidth() / 2), player->getPosY(), n1000Sprite); createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n1000Sprite->getWidth() / 2), player->getPosY(), n1000Sprite.get());
JA_PlaySound(itemPickUpSound); JA_PlaySound(itemPickUpSound);
break; break;
case ITEM_POINTS_2_GAVINA: case ITEM_POINTS_2_GAVINA:
player->addScore(2500); player->addScore(2500);
updateHiScore(); updateHiScore();
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n2500Sprite->getWidth() / 2), player->getPosY(), n2500Sprite); createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n2500Sprite->getWidth() / 2), player->getPosY(), n2500Sprite.get());
JA_PlaySound(itemPickUpSound); JA_PlaySound(itemPickUpSound);
break; break;
case ITEM_POINTS_3_PACMAR: case ITEM_POINTS_3_PACMAR:
player->addScore(5000); player->addScore(5000);
updateHiScore(); updateHiScore();
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n5000Sprite->getWidth() / 2), player->getPosY(), n5000Sprite); createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n5000Sprite->getWidth() / 2), player->getPosY(), n5000Sprite.get());
JA_PlaySound(itemPickUpSound); JA_PlaySound(itemPickUpSound);
break; break;
@@ -1411,7 +1399,7 @@ void Game::checkPlayerItemCollision(Player *player)
{ {
player->addScore(5000); player->addScore(5000);
updateHiScore(); updateHiScore();
createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n5000Sprite->getWidth() / 2), player->getPosY(), n5000Sprite); createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n5000Sprite->getWidth() / 2), player->getPosY(), n5000Sprite.get());
} }
player->giveExtraHit(); player->giveExtraHit();
JA_PlaySound(itemPickUpSound); JA_PlaySound(itemPickUpSound);
@@ -1517,7 +1505,7 @@ void Game::renderBullets()
// Crea un objeto bala // Crea un objeto bala
void Game::createBullet(int x, int y, BulletType kind, bool poweredUp, int owner) void Game::createBullet(int x, int y, BulletType kind, bool poweredUp, int owner)
{ {
Bullet *b = new Bullet(x, y, kind, poweredUp, owner, &(param.game.playArea.rect), bulletTexture); Bullet *b = new Bullet(x, y, kind, poweredUp, owner, &(param.game.playArea.rect), bulletTexture.get());
bullets.push_back(b); bullets.push_back(b);
} }
@@ -2629,7 +2617,7 @@ bool Game::allPlayersAreNotPlaying()
// Comprueba los eventos que hay en cola // Comprueba los eventos que hay en cola
void Game::checkEvents() void Game::checkEvents()
{ {
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler.get()) != 0)
{ {
// Evento de salida de la aplicación // Evento de salida de la aplicación
if (eventHandler->type == SDL_QUIT) if (eventHandler->type == SDL_QUIT)
@@ -2815,11 +2803,10 @@ void Game::pause(bool value)
// Añade una puntuación a la tabla de records // Añade una puntuación a la tabla de records
void Game::addScoreToScoreBoard(std::string name, int score) void Game::addScoreToScoreBoard(std::string name, int score)
{ {
const hiScoreEntry_t entry = {trim(name), score}; const auto entry = (hiScoreEntry_t){trim(name), score};
ManageHiScoreTable *manager = new ManageHiScoreTable(&options.game.hiScoreTable); auto manager = std::make_unique<ManageHiScoreTable>(&options.game.hiScoreTable);
manager->add(entry); manager->add(entry);
manager->saveToFile(asset->get("score.bin")); manager->saveToFile(asset->get("score.bin"));
delete manager;
} }
// Comprueba el estado de los jugadores // Comprueba el estado de los jugadores
@@ -2860,7 +2847,6 @@ void Game::checkPlayersStatusPlaying()
{ {
const playerStatus nextPlayerStatus = IsEligibleForHighScore(player->getScore()) ? playerStatus::ENTERING_NAME : playerStatus::CONTINUE; const playerStatus nextPlayerStatus = IsEligibleForHighScore(player->getScore()) ? playerStatus::ENTERING_NAME : playerStatus::CONTINUE;
demo.enabled ? player->setStatusPlaying(playerStatus::WAITING) : player->setStatusPlaying(nextPlayerStatus); demo.enabled ? player->setStatusPlaying(playerStatus::WAITING) : player->setStatusPlaying(nextPlayerStatus);
// addScoreToScoreBoard(player->getName(), player->getScore());
break; break;
} }

View File

@@ -7,21 +7,22 @@
#include <vector> // for vector #include <vector> // for vector
#include "section.h" // for options_e #include "section.h" // for options_e
#include "utils.h" // for demoKeys_t, color_t, hiScoreEntry_t #include "utils.h" // for demoKeys_t, color_t, hiScoreEntry_t
class Asset; // lines 11-11 #include <memory>
class Background; // lines 12-12 class Asset; // lines 11-11
class Balloon; // lines 13-13 class Background; // lines 12-12
class Bullet; // lines 14-14 class Balloon; // lines 13-13
class EnemyFormations; // lines 15-15 class Bullet; // lines 14-14
class Explosions; // lines 16-16 class EnemyFormations; // lines 15-15
class Fade; // lines 17-17 class Explosions; // lines 16-16
class Input; // lines 18-18 class Fade; // lines 17-17
class Item; // lines 19-19 class Input; // lines 18-18
class Player; // lines 20-20 class Item; // lines 19-19
class Scoreboard; // lines 21-21 class Player; // lines 20-20
class Screen; // lines 22-22 class Scoreboard; // lines 21-21
class SmartSprite; // lines 23-23 class Screen; // lines 22-22
class Text; // lines 24-24 class SmartSprite; // lines 23-23
class Texture; // lines 25-25 class Text; // lines 24-24
class Texture; // lines 25-25
enum class BulletType; enum class BulletType;
struct JA_Music_t; // lines 26-26 struct JA_Music_t; // lines 26-26
struct JA_Sound_t; // lines 27-27 struct JA_Sound_t; // lines 27-27
@@ -105,15 +106,17 @@ private:
}; };
// Objetos y punteros // Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla Screen *screen; // Objeto encargado de dibujar en pantalla
Asset *asset; // Objeto que gestiona todos los ficheros de recursos Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Input *input; // Manejador de entrada Input *input; // Manejador de entrada
Scoreboard *scoreboard; // Objeto para dibujar el marcador Scoreboard *scoreboard; // Objeto para dibujar el marcador
Background *background; // Objeto para dibujar el fondo del juego
Explosions *explosions; // Objeto para dibujar explosiones std::unique_ptr<Background> background; // Objeto para dibujar el fondo del juego
EnemyFormations *enemyFormations; // Objeto para gestionar las oleadas enemigas std::unique_ptr<Explosions> explosions; // Objeto para dibujar explosiones
SDL_Texture *canvas; // Textura para dibujar la zona de juego std::unique_ptr<EnemyFormations> enemyFormations; // Objeto para gestionar las oleadas enemigas
SDL_Texture *canvas; // Textura para dibujar la zona de juego
std::vector<Player *> players; // Vector con los jugadores std::vector<Player *> players; // Vector con los jugadores
std::vector<Balloon *> balloons; // Vector con los globos std::vector<Balloon *> balloons; // Vector con los globos
@@ -121,7 +124,7 @@ private:
std::vector<Item *> items; // Vector con los items std::vector<Item *> items; // Vector con los items
std::vector<SmartSprite *> smartSprites; // Vector con los smartsprites std::vector<SmartSprite *> smartSprites; // Vector con los smartsprites
Texture *bulletTexture; // Textura para las balas std::unique_ptr<Texture> bulletTexture; // Textura para las balas
std::vector<Texture *> itemTextures; // Vector con las texturas de los items std::vector<Texture *> itemTextures; // Vector con las texturas de los items
std::vector<Texture *> balloonTextures; // Vector con las texturas de los globos std::vector<Texture *> balloonTextures; // Vector con las texturas de los globos
std::vector<Texture *> explosionsTextures; // Vector con las texturas de las explosiones std::vector<Texture *> explosionsTextures; // Vector con las texturas de las explosiones
@@ -129,7 +132,7 @@ private:
std::vector<Texture *> player2Textures; // Vector con las texturas del jugador std::vector<Texture *> player2Textures; // Vector con las texturas del jugador
std::vector<std::vector<Texture *>> playerTextures; // Vector con todas las texturas de los jugadores; std::vector<std::vector<Texture *>> playerTextures; // Vector con todas las texturas de los jugadores;
Texture *gameTextTexture; // Textura para los sprites con textos std::unique_ptr<Texture> gameTextTexture; // Textura para los sprites con textos
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> *> playerAnimations; // Vector con las animaciones del jugador
@@ -141,12 +144,12 @@ private:
Text *textNokia2; // Otra fuente de texto para mensajes Text *textNokia2; // Otra fuente de texto para mensajes
Text *textNokiaBig2; // Y la versión en grande Text *textNokiaBig2; // Y la versión en grande
Fade *fade; // Objeto para renderizar fades std::unique_ptr<Fade> fade; // Objeto para renderizar fades
SDL_Event *eventHandler; // Manejador de eventos std::unique_ptr<SDL_Event> eventHandler; // Manejador de eventos
SmartSprite *n1000Sprite; // Sprite con el texto 1.000 std::unique_ptr<SmartSprite> n1000Sprite; // Sprite con el texto 1.000
SmartSprite *n2500Sprite; // Sprite con el texto 2.500 std::unique_ptr<SmartSprite> n2500Sprite; // Sprite con el texto 2.500
SmartSprite *n5000Sprite; // Sprite con el texto 5.000 std::unique_ptr<SmartSprite> n5000Sprite; // Sprite con el texto 5.000
JA_Sound_t *balloonSound; // Sonido para la explosión del globo JA_Sound_t *balloonSound; // Sonido para la explosión del globo
JA_Sound_t *bulletSound; // Sonido para los disparos JA_Sound_t *bulletSound; // Sonido para los disparos
@@ -192,7 +195,7 @@ private:
bool coffeeMachineEnabled; // Indica si hay una máquina de café en el terreno de juego bool coffeeMachineEnabled; // Indica si hay una máquina de café en el terreno de juego
bool gameCompleted; // Indica si se ha completado la partida, llegando al final de la ultima pantalla bool gameCompleted; // Indica si se ha completado la partida, llegando al final de la ultima pantalla
int gameCompletedCounter; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos int gameCompletedCounter; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos
int difficulty; // Dificultad del juego gameDifficulty difficulty; // Dificultad del juego
float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad
color_t difficultyColor; // Color asociado a la dificultad color_t difficultyColor; // Color asociado a la dificultad
int lastStageReached; // Contiene el número de la última pantalla que se ha alcanzado int lastStageReached; // Contiene el número de la última pantalla que se ha alcanzado

View File

@@ -4,6 +4,7 @@
#include <string> // for basic_string, char_traits, string #include <string> // for basic_string, char_traits, string
#include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_Pla... #include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_Pla...
#include "options.h" // for options #include "options.h" // for options
#include "param.h"
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "text.h" // for Text #include "text.h" // for Text
#include "texture.h" // for Texture #include "texture.h" // for Texture
@@ -210,11 +211,11 @@ void Notify::showText(std::string text1, std::string text2, int icon)
} }
else if (options.notification.posH == pos_middle) else if (options.notification.posH == pos_middle)
{ {
despH = ((options.video.gameWidth / 2) - (width / 2)); despH = ((param.game.width / 2) - (width / 2));
} }
else else
{ {
despH = options.video.gameWidth - width - paddingOut; despH = param.game.width - width - paddingOut;
} }
// Posición vertical // Posición vertical
@@ -225,7 +226,7 @@ void Notify::showText(std::string text1, std::string text2, int icon)
} }
else else
{ {
despV = options.video.gameHeight - height - paddingOut; despV = param.game.height - height - paddingOut;
} }
const int travelDist = height + paddingOut; const int travelDist = height + paddingOut;

View File

@@ -94,13 +94,13 @@ void OnScreenHelp::fillTexture()
SDL_SetRenderTarget(Screen::get()->getRenderer(), texture); SDL_SetRenderTarget(Screen::get()->getRenderer(), texture);
// Crea el objeto para el texto // Crea el objeto para el texto
std::unique_ptr<Text> text(new Text(Asset::get()->get("8bithud.png"), Asset::get()->get("8bithud.txt"), Screen::get()->getRenderer())); auto text = std::make_unique<Text>(Asset::get()->get("8bithud.png"), Asset::get()->get("8bithud.txt"), Screen::get()->getRenderer());
// Crea la textura con los gráficos // Crea la textura con los gráficos
std::unique_ptr<Texture> controllersTexture(new Texture(Screen::get()->getRenderer(), Asset::get()->get("controllers.png"))); auto controllersTexture = std::make_unique<Texture>(Screen::get()->getRenderer(), Asset::get()->get("controllers.png"));
// Crea el sprite para dibujar los gráficos // Crea el sprite para dibujar los gráficos
std::unique_ptr<Sprite> sprite(new Sprite({0, 0, 16, 16}, controllersTexture.get())); auto sprite = std::make_unique<Sprite>((SDL_Rect){0, 0, 16, 16}, controllersTexture.get());
// Borra la textura // Borra la textura
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 0); SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 0);
@@ -140,11 +140,11 @@ void OnScreenHelp::fillTexture()
// Define el ancho y alto de la textura // Define el ancho y alto de la textura
void OnScreenHelp::setSize() void OnScreenHelp::setSize()
{ {
const int textSize = getLargestStringSize(); const auto textSize = getLargestStringSize();
const int width = PADDING.x + DESP.x + textSize + PADDING.x; const auto width = PADDING.x + DESP.x + textSize + PADDING.x;
const int height = PADDING.y + (7 * 18) + PADDING.y; const auto height = PADDING.y + (7 * 18) + PADDING.y;
const int x = 0; const auto x = 0;
const int y = (param.game.height - height) / 2; const auto y = (param.game.height - height) / 2;
dest = (SDL_Rect){x, y, width, height}; dest = (SDL_Rect){x, y, width, height};
@@ -167,14 +167,14 @@ void OnScreenHelp::toggleState()
} }
// Calcula la longitud en pixels del texto más largo // Calcula la longitud en pixels del texto más largo
int OnScreenHelp::getLargestStringSize() const auto OnScreenHelp::getLargestStringSize() -> int const
{ {
std::unique_ptr<Text> text(new Text(Asset::get()->get("8bithud.png"), Asset::get()->get("8bithud.txt"), Screen::get()->getRenderer())); auto text = std::make_unique<Text>(Asset::get()->get("8bithud.png"), Asset::get()->get("8bithud.txt"), Screen::get()->getRenderer());
int size = 0; auto size = 0;
for (int i = 107; i <= 113; ++i) for (int i = 107; i <= 113; ++i)
{ {
const int textSize = text->lenght(lang::getText(i)); const auto textSize = text->lenght(lang::getText(i));
size = textSize > size ? textSize : size; size = textSize > size ? textSize : size;
} }
@@ -196,14 +196,19 @@ void OnScreenHelp::updatePosition()
switch (state) switch (state)
{ {
case OnScreenHelpStatus::hidden: case OnScreenHelpStatus::hidden:
{
index = 0; index = 0;
break; break;
}
case OnScreenHelpStatus::showing: case OnScreenHelpStatus::showing:
{
index = path.size() - 1; index = path.size() - 1;
break; break;
}
case OnScreenHelpStatus::exitting: case OnScreenHelpStatus::exitting:
{
if (index > 0) if (index > 0)
{ {
index--; index--;
@@ -213,8 +218,10 @@ void OnScreenHelp::updatePosition()
state = OnScreenHelpStatus::hidden; state = OnScreenHelpStatus::hidden;
} }
break; break;
}
case OnScreenHelpStatus::entering: case OnScreenHelpStatus::entering:
{
if (index < (int)path.size() - 1) if (index < (int)path.size() - 1)
{ {
index++; index++;
@@ -224,6 +231,7 @@ void OnScreenHelp::updatePosition()
state = OnScreenHelpStatus::showing; state = OnScreenHelpStatus::showing;
} }
break; break;
}
default: default:
break; break;

View File

@@ -47,7 +47,7 @@ private:
void setSize(); void setSize();
// Calcula la longitud en pixels del texto más largo // Calcula la longitud en pixels del texto más largo
int getLargestStringSize() const; auto getLargestStringSize() -> int const;
// Renderizara el boton y el texto // Renderizara el boton y el texto
void renderButton(Sprite *sprite, Text *text, const SDL_Rect &buttonClip, const SDL_Rect &buttonPos, int textId); void renderButton(Sprite *sprite, Text *text, const SDL_Rect &buttonClip, const SDL_Rect &buttonPos, int textId);

View File

@@ -1,14 +1,14 @@
#include "options.h" #include "options.h"
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton, SDL_C... #include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton, SDL_C...
#include <SDL2/SDL_video.h> // for SDL_WINDOW_FULLSCREEN, SDL_WIND... #include <SDL2/SDL_video.h> // for SDL_WINDOW_FULLSCREEN, SDL_WIND...
#include <algorithm> // for max, min #include <algorithm> // for max, min
#include <fstream> // for char_traits, basic_ostream, ope... #include <fstream> // for char_traits, basic_ostream, ope...
#include <iostream> // for cout #include <iostream> // for cout
#include <vector> // for vector #include <vector> // for vector
#include "input.h" // for inputs_e, INPUT_USE_ANY, INPUT_... #include "input.h" // for inputs_e, INPUT_USE_ANY, INPUT_...
#include "lang.h" // for lang_e #include "lang.h" // for lang_e
#include "screen.h" // for SCREEN_FILTER_NEAREST, SCREEN_V... #include "screen.h" // for screenFilter::NEAREST, SCREEN_V...
#include "utils.h" // for op_controller_t, options_t, op_... #include "utils.h" // for op_controller_t, options_t, op_...
// Variables // Variables
options_t options; options_t options;
@@ -21,23 +21,21 @@ void initOptions()
{ {
// Opciones de video // Opciones de video
#ifdef ANBERNIC #ifdef ANBERNIC
options.video.mode = 0; options.video.mode = screenVideoMode::WINDOW;
options.video.window.size = 3; options.video.window.size = 3;
#else #else
options.video.mode = 0; options.video.mode = screenVideoMode::WINDOW;
options.video.window.size = 2; options.video.window.size = 2;
#endif #endif
options.video.filter = SCREEN_FILTER_NEAREST; options.video.filter = screenFilter::NEAREST;
options.video.vSync = true; options.video.vSync = true;
options.video.integerScale = true;
options.video.keepAspect = true;
options.video.shaders = true; options.video.shaders = true;
// Opciones de las notificaciones // Opciones de las notificaciones
options.notification.posV = pos_top; options.notification.posV = pos_top;
options.notification.posH = pos_left; options.notification.posH = pos_left;
options.notification.sound = false; options.notification.sound = false;
options.notification.color = {48, 48, 48}; options.notification.color = (color_t){48, 48, 48};
// Opciones de audio // Opciones de audio
options.audio.music.enabled = true; options.audio.music.enabled = true;
@@ -46,7 +44,7 @@ void initOptions()
options.audio.sound.volume = 64; options.audio.sound.volume = 64;
// Opciones de juego // Opciones de juego
options.game.difficulty = DIFFICULTY_NORMAL; options.game.difficulty = gameDifficulty::NORMAL;
options.game.language = lang::ba_BA; options.game.language = lang::ba_BA;
options.game.autofire = true; options.game.autofire = true;
@@ -135,12 +133,11 @@ bool loadOptionsFile(std::string filePath)
} }
// Normaliza los valores // Normaliza los valores
const bool a = options.video.mode == 0; const bool a = options.video.mode == screenVideoMode::WINDOW;
const bool b = options.video.mode == SDL_WINDOW_FULLSCREEN; const bool b = options.video.mode == screenVideoMode::FULLSCREEN;
const bool c = options.video.mode == SDL_WINDOW_FULLSCREEN_DESKTOP; if (!(a || b))
if (!(a || b || c))
{ {
options.video.mode = SCREEN_VIDEO_MODE_WINDOW; options.video.mode = screenVideoMode::WINDOW;
} }
if (options.video.window.size < 1 || options.video.window.size > 4) if (options.video.window.size < 1 || options.video.window.size > 4)
@@ -175,29 +172,26 @@ bool saveOptionsFile(std::string filePath)
#endif #endif
// Opciones de video // Opciones de video
const auto valueVideoModeWinow = std::to_string(static_cast<int>(screenVideoMode::WINDOW));
const auto valueVideoModeFullscreen = std::to_string(static_cast<int>(screenVideoMode::FULLSCREEN));
const auto valueFilterNearest = std::to_string(static_cast<int>(screenFilter::NEAREST));
const auto valueFilterLineal = std::to_string(static_cast<int>(screenFilter::LINEAL));
file << "## VIDEO\n"; file << "## VIDEO\n";
file << "## video.mode [0: window, 1: full screen]\n"; file << "## video.mode [" << valueVideoModeWinow << ": window, " << valueVideoModeFullscreen << ": fullscreen]\n";
file << "## video.filter [0: nearest, 1: lineal]\n"; file << "## video.filter [" << valueFilterNearest << ": nearest, " << valueFilterLineal << ": lineal]\n";
file << "\n"; file << "\n";
if (options.video.mode == SCREEN_VIDEO_MODE_WINDOW) const auto valueVideoMode = std::to_string(static_cast<int>(options.video.mode));
{ file << "video.mode=" << valueVideoMode << "\n";
file << "video.mode=0\n";
}
else if (options.video.mode == SCREEN_VIDEO_MODE_FULLSCREEN)
{
file << "video.mode=1\n";
}
file << "video.window.size=" + std::to_string(options.video.window.size) + "\n"; file << "video.window.size=" + std::to_string(options.video.window.size) + "\n";
options.video.filter == SCREEN_FILTER_NEAREST ? file << "video.filter=0\n" : file << "video.filter=1\n"; const auto valueFilter = std::to_string(static_cast<int>(options.video.filter));
file << "video.filter=" << valueFilter << "\n";
file << "video.shaders=" + boolToString(options.video.shaders) + "\n"; file << "video.shaders=" + boolToString(options.video.shaders) + "\n";
file << "video.vSync=" + boolToString(options.video.vSync) + "\n"; file << "video.vSync=" + boolToString(options.video.vSync) + "\n";
file << "video.integerScale=" + boolToString(options.video.integerScale) + "\n";
file << "video.keepAspect=" + boolToString(options.video.keepAspect) + "\n";
// Opciones de notificaciones // Opciones de notificaciones
file << "\n\n## NOTIFICATION\n"; file << "\n\n## NOTIFICATION\n";
@@ -243,13 +237,16 @@ bool saveOptionsFile(std::string filePath)
file << "audio.sound.volume=" + std::to_string(options.audio.sound.volume) + "\n"; file << "audio.sound.volume=" + std::to_string(options.audio.sound.volume) + "\n";
// Opciones del juego // Opciones del juego
const auto valueDifficultyEasy = std::to_string(static_cast<int>(gameDifficulty::EASY));
const auto valueDifficultyNormal = std::to_string(static_cast<int>(gameDifficulty::NORMAL));
const auto valueDifficultyHard = std::to_string(static_cast<int>(gameDifficulty::HARD));
file << "\n\n## GAME\n"; file << "\n\n## GAME\n";
file << "## game.language [0: spanish, 1: valencian, 2: english]\n"; file << "## game.language [0: spanish, 1: valencian, 2: english]\n";
file << "## game.difficulty [0: easy, 1: normal, 2: hard]\n"; file << "## game.difficulty [" << valueDifficultyEasy << ": easy, " << valueDifficultyNormal << ": normal, " << valueDifficultyHard << ": hard]\n";
file << "\n"; file << "\n";
file << "game.language=" + std::to_string(options.game.language) + "\n"; file << "game.language=" + std::to_string(options.game.language) + "\n";
file << "game.difficulty=" + std::to_string(options.game.difficulty) + "\n"; file << "game.difficulty=" + std::to_string(static_cast<int>(options.game.difficulty)) + "\n";
file << "game.autofire=" + boolToString(options.game.autofire) + "\n"; file << "game.autofire=" + boolToString(options.game.autofire) + "\n";
// Opciones de mandos // Opciones de mandos
@@ -289,7 +286,8 @@ bool setOptions(std::string var, std::string value)
// Opciones de video // Opciones de video
if (var == "video.mode") if (var == "video.mode")
{ {
options.video.mode = value == std::to_string(SCREEN_VIDEO_MODE_WINDOW) ? SCREEN_VIDEO_MODE_WINDOW : SCREEN_VIDEO_MODE_FULLSCREEN; //options.video.mode = value == std::to_string(static_cast<int>(screenVideoMode::WINDOW)) ? screenVideoMode::WINDOW : screenVideoMode::FULLSCREEN;
options.video.mode = static_cast<screenVideoMode>(std::stoi(value));
} }
else if (var == "video.window.size") else if (var == "video.window.size")
@@ -303,7 +301,8 @@ bool setOptions(std::string var, std::string value)
else if (var == "video.filter") else if (var == "video.filter")
{ {
options.video.filter = value == std::to_string(SCREEN_FILTER_NEAREST) ? SCREEN_FILTER_NEAREST : SCREEN_FILTER_LINEAL; //options.video.filter = value == std::to_string(static_cast<int>(screenFilter::NEAREST)) ? screenFilter::NEAREST : screenFilter::LINEAL;
options.video.filter = static_cast<screenFilter>(std::stoi(value));
} }
else if (var == "video.shaders") else if (var == "video.shaders")
@@ -316,16 +315,6 @@ bool setOptions(std::string var, std::string value)
options.video.vSync = stringToBool(value); options.video.vSync = stringToBool(value);
} }
else if (var == "video.integerScale")
{
options.video.integerScale = stringToBool(value);
}
else if (var == "video.keepAspect")
{
options.video.keepAspect = stringToBool(value);
}
// Opciones de notificaciones // Opciones de notificaciones
else if (var == "notification.posH") else if (var == "notification.posH")
{ {
@@ -382,7 +371,7 @@ bool setOptions(std::string var, std::string value)
else if (var == "game.difficulty") else if (var == "game.difficulty")
{ {
options.game.difficulty = std::stoi(value); options.game.difficulty = static_cast<gameDifficulty>(std::stoi(value));
} }
else if (var == "game.autofire") else if (var == "game.autofire")

View File

@@ -9,13 +9,30 @@
#include "text.h" // for Text #include "text.h" // for Text
#include "texture.h" // for Texture #include "texture.h" // for Texture
// Constructor // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Scoreboard::Scoreboard(SDL_Renderer *renderer) Scoreboard *Scoreboard::scoreboard = nullptr;
{
// Copia los punteros
this->renderer = renderer;
asset = Asset::get();
// [SINGLETON] Crearemos el objeto scoreboard con esta función estática
void Scoreboard::init(SDL_Renderer *renderer)
{
Scoreboard::scoreboard = new Scoreboard(renderer);
}
// [SINGLETON] Destruiremos el objeto scoreboard con esta función estática
void Scoreboard::destroy()
{
delete Scoreboard::scoreboard;
}
// [SINGLETON] Con este método obtenemos el objeto scoreboard y podemos trabajar con él
Scoreboard *Scoreboard::get()
{
return Scoreboard::scoreboard;
}
// Constructor
Scoreboard::Scoreboard(SDL_Renderer *renderer) : renderer(renderer)
{
// Inicializa punteros // Inicializa punteros
gamePowerMeterTexture = nullptr; gamePowerMeterTexture = nullptr;
powerMeterSprite = nullptr; powerMeterSprite = nullptr;
@@ -47,9 +64,9 @@ Scoreboard::Scoreboard(SDL_Renderer *renderer)
recalculateAnchors(); recalculateAnchors();
// Crea objetos // Crea objetos
gamePowerMeterTexture = new Texture(renderer, asset->get("game_power_meter.png")); gamePowerMeterTexture = std::unique_ptr<Texture>(new Texture(renderer, Asset::get()->get("game_power_meter.png")));
powerMeterSprite = new Sprite(slot4_2.x - 20, slot4_2.y, 40, 7, gamePowerMeterTexture); powerMeterSprite = std::unique_ptr<Sprite>(new Sprite(slot4_2.x - 20, slot4_2.y, 40, 7, gamePowerMeterTexture.get()));
textScoreBoard = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer); textScoreBoard = std::unique_ptr<Text>(new Text(Asset::get()->get("8bithud.png"), Asset::get()->get("8bithud.txt"), renderer));
// Crea la textura de fondo // Crea la textura de fondo
background = nullptr; background = nullptr;
@@ -64,14 +81,11 @@ Scoreboard::Scoreboard(SDL_Renderer *renderer)
Scoreboard::~Scoreboard() Scoreboard::~Scoreboard()
{ {
gamePowerMeterTexture->unload();
delete gamePowerMeterTexture;
delete powerMeterSprite;
delete textScoreBoard;
if (background) if (background)
{ {
SDL_DestroyTexture(background); SDL_DestroyTexture(background);
} }
for (auto texture : panelTexture) for (auto texture : panelTexture)
{ {
if (texture) if (texture)

View File

@@ -6,6 +6,7 @@
#include <string> // for string, basic_string #include <string> // for string, basic_string
#include <vector> // for vector #include <vector> // for vector
#include "utils.h" // for color_t #include "utils.h" // for color_t
#include <memory>
class Asset; class Asset;
class Sprite; class Sprite;
class Text; class Text;
@@ -35,19 +36,23 @@ enum class scoreboardMode
struct panel_t struct panel_t
{ {
scoreboardMode mode; // Modo en el que se encuentra el panel scoreboardMode mode; // Modo en el que se encuentra el panel
SDL_Rect pos; // Posición donde dibujar el panel dentro del marcador SDL_Rect pos; // Posición donde dibujar el panel dentro del marcador
}; };
// Clase Scoreboard // Clase Scoreboard
class Scoreboard class Scoreboard
{ {
private: private:
// [SINGLETON] Objeto scoreboard privado para Don Melitón
static Scoreboard *scoreboard;
// Objetos y punteros // Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana SDL_Renderer *renderer; // El renderizador de la ventana
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
Texture *gamePowerMeterTexture; // Textura con el marcador de poder de la fase std::unique_ptr<Texture> gamePowerMeterTexture; // Textura con el marcador de poder de la fase
Sprite *powerMeterSprite; // Sprite para el medidor de poder de la fase std::unique_ptr<Sprite> powerMeterSprite; // Sprite para el medidor de poder de la fase
Text *textScoreBoard; // Fuente para el marcador del juego std::unique_ptr<Text> textScoreBoard; // Fuente para el marcador del juego
SDL_Texture *background; // Textura para dibujar el marcador SDL_Texture *background; // Textura para dibujar el marcador
std::vector<SDL_Texture *> panelTexture; // Texturas para dibujar cada panel; std::vector<SDL_Texture *> panelTexture; // Texturas para dibujar cada panel;
@@ -96,13 +101,24 @@ private:
// Dibuja la linea que separa la zona de juego del marcador // Dibuja la linea que separa la zona de juego del marcador
void renderSeparator(); void renderSeparator();
public: // [SINGLETON] Ahora el constructor y el destructor son privados
// Constructor // Constructor
Scoreboard(SDL_Renderer *renderer); Scoreboard(SDL_Renderer *renderer);
// Destructor // Destructor
~Scoreboard(); ~Scoreboard();
public:
// [SINGLETON] Crearemos el objeto scoreboard con esta función estática
static void init(SDL_Renderer *renderer);
// [SINGLETON] Destruiremos el objeto scoreboard con esta función estática
static void destroy();
// [SINGLETON] Con este método obtenemos el objeto scoreboard y podemos trabajar con él
static Scoreboard *get();
// Actualiza la lógica del marcador // Actualiza la lógica del marcador
void update(); void update();

View File

@@ -12,6 +12,7 @@
#include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT #include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT
#include "notify.h" // for Notify #include "notify.h" // for Notify
#include "options.h" // for options #include "options.h" // for options
#include "param.h"
#include "on_screen_help.h" #include "on_screen_help.h"
#include "global_inputs.h" #include "global_inputs.h"
@@ -48,10 +49,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer) : window(window), ren
asset = Asset::get(); asset = Asset::get();
// Inicializa variables // Inicializa variables
SDL_GetRendererOutputSize(renderer, &windowWidth, &windowHeight); srcrect = {0, 0, param.game.width, param.game.height};
gameCanvasWidth = options.video.gameWidth; dstrect = {0, 0, param.game.width, param.game.height};
gameCanvasHeight = options.video.gameHeight;
dest = {0, 0, 0, 0};
borderColor = {0, 0, 0}; borderColor = {0, 0, 0};
flashEffect.enabled = false; flashEffect.enabled = false;
flashEffect.counter = 0; flashEffect.counter = 0;
@@ -77,13 +76,13 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer) : window(window), ren
infoResolution = std::to_string(DM.w) + " X " + std::to_string(DM.h) + " AT " + std::to_string(DM.refresh_rate) + " HZ"; infoResolution = std::to_string(DM.w) + " X " + std::to_string(DM.h) + " AT " + std::to_string(DM.refresh_rate) + " HZ";
// Crea los objetos // Crea los objetos
notify = new Notify(renderer, "", asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav")); notify = std::make_unique<Notify>(renderer, "", asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav"));
// Define el color del borde para el modo de pantalla completa // Define el color del borde para el modo de pantalla completa
borderColor = {0x00, 0x00, 0x00}; borderColor = {0x00, 0x00, 0x00};
// Crea la textura donde se dibujan los graficos del juego // Crea la textura donde se dibujan los graficos del juego
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight); gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height);
// Establece el modo de video // Establece el modo de video
setVideoMode(options.video.mode); setVideoMode(options.video.mode);
@@ -95,7 +94,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer) : window(window), ren
// Destructor // Destructor
Screen::~Screen() Screen::~Screen()
{ {
delete notify;
SDL_DestroyTexture(gameCanvas); SDL_DestroyTexture(gameCanvas);
} }
@@ -142,7 +140,7 @@ void Screen::blit()
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
// Copia la textura de juego en el renderizador en la posición adecuada // Copia la textura de juego en el renderizador en la posición adecuada
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest); SDL_RenderCopy(renderer, gameCanvas, nullptr, nullptr);
// Muestra por pantalla el renderizador // Muestra por pantalla el renderizador
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@@ -156,12 +154,8 @@ void Screen::blit()
// Vuelve a dejar el renderizador en modo normal // Vuelve a dejar el renderizador en modo normal
SDL_SetRenderTarget(renderer, nullptr); SDL_SetRenderTarget(renderer, nullptr);
// Borra el contenido previo
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
SDL_RenderClear(renderer);
// Copia la textura de juego en el renderizador en la posición adecuada // Copia la textura de juego en el renderizador en la posición adecuada
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest); SDL_RenderCopy(renderer, gameCanvas, &srcrect, nullptr);
// Muestra por pantalla el renderizador // Muestra por pantalla el renderizador
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
@@ -170,17 +164,18 @@ void Screen::blit()
} }
// Establece el modo de video // Establece el modo de video
void Screen::setVideoMode(int videoMode) void Screen::setVideoMode(screenVideoMode videoMode)
{ {
options.video.mode = videoMode;
#ifdef ARCADE #ifdef ARCADE
videoMode = SCREEN_VIDEO_MODE_WINDOW; options.video.mode = screenVideoMode::WINDOW;
// videoMode = SCREEN_VIDEO_MODE_FULLSCREEN;
#endif #endif
// Si está activo el modo ventana quita el borde switch (options.video.mode)
if (videoMode == SCREEN_VIDEO_MODE_WINDOW)
{ {
// Aplica el modo de video case screenVideoMode::WINDOW:
{
// Cambia a modo de ventana
SDL_SetWindowFullscreen(window, 0); SDL_SetWindowFullscreen(window, 0);
#ifdef ARCADE #ifdef ARCADE
@@ -190,86 +185,29 @@ void Screen::setVideoMode(int videoMode)
// Muestra el puntero // Muestra el puntero
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
#endif #endif
windowWidth = gameCanvasWidth;
windowHeight = gameCanvasHeight;
dest = {0, 0, windowWidth, windowHeight};
// Modifica el tamaño de la ventana // Modifica el tamaño de la ventana
SDL_SetWindowSize(window, windowWidth * options.video.window.size, windowHeight * options.video.window.size); SDL_SetWindowSize(window, param.game.width * options.video.window.size, param.game.height * options.video.window.size);
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
break;
} }
// Si está activo el modo de pantalla completa añade el borde // Si está activo el modo de pantalla completa añade el borde
else if (videoMode == SCREEN_VIDEO_MODE_FULLSCREEN) case screenVideoMode::FULLSCREEN:
{ {
// Aplica el modo de video // Aplica el modo de video
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
#ifdef ARCADE
/*SDL_DisplayMode DM;
DM.w = 1024;
DM.h = 600;
DM.refresh_rate = 60;
if (!SDL_SetWindowDisplayMode(window, &DM))
{
std::cout << SDL_GetError() << std::endl;
}
else
{
std::cout << "Changed windows display mode" << std::endl;
}*/
#endif
// Oculta el puntero // Oculta el puntero
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
// Obten el alto y el ancho de la ventana break;
// SDL_GetWindowSize(window, &windowWidth, &windowHeight); }
// Aplica el escalado al rectangulo donde se pinta la textura del juego default:
if (options.video.integerScale) break;
{
// Calcula el tamaño de la escala máxima
int scale = 0;
while (((gameCanvasWidth * (scale + 1)) <= windowWidth) && ((gameCanvasHeight * (scale + 1)) <= windowHeight))
{
scale++;
}
dest.w = gameCanvasWidth * scale;
dest.h = gameCanvasHeight * scale;
dest.x = (windowWidth - dest.w) / 2;
dest.y = (windowHeight - dest.h) / 2;
}
else if (options.video.keepAspect)
{
float ratio = (float)gameCanvasWidth / (float)gameCanvasHeight;
if ((windowWidth - gameCanvasWidth) >= (windowHeight - gameCanvasHeight))
{
dest.h = windowHeight;
dest.w = (int)((windowHeight * ratio) + 0.5f);
dest.x = (windowWidth - dest.w) / 2;
dest.y = (windowHeight - dest.h) / 2;
}
else
{
dest.w = windowWidth;
dest.h = (int)((windowWidth / ratio) + 0.5f);
dest.x = (windowWidth - dest.w) / 2;
dest.y = (windowHeight - dest.h) / 2;
}
}
else
{
// dest = {0, 0, windowWidth, windowHeight};
dest = {0, 0, gameCanvasWidth, gameCanvasHeight};
}
} }
#ifdef NO_SHADERS
// El renderizador pasa a tener el tamaño de la pantalla en fullscreen o del juego en modo ventana
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
#else
// Reinicia los shaders // Reinicia los shaders
if (options.video.shaders) if (options.video.shaders)
{ {
@@ -279,28 +217,14 @@ void Screen::setVideoMode(int videoMode)
shader::init(window, gameCanvas, source.c_str()); shader::init(window, gameCanvas, source.c_str());
} }
// Modifica el tamaño del renderizador
else
{
// El renderizador pasa a tener el tamaño de la pantalla en fullscreen o del juego en modo ventana
// SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
SDL_RenderSetLogicalSize(renderer, gameCanvasWidth, gameCanvasHeight);
}
#endif
// Actualiza las opciones
options.video.mode = videoMode;
options.video.window.width = windowWidth;
options.video.window.height = windowHeight;
// Actualiza variables // Actualiza variables
shakeEffect.origin = dest.x; shakeEffect.origin = srcrect.x;
} }
// Camibia entre pantalla completa y ventana // Camibia entre pantalla completa y ventana
void Screen::switchVideoMode() void Screen::switchVideoMode()
{ {
options.video.mode = options.video.mode == SCREEN_VIDEO_MODE_WINDOW ? SCREEN_VIDEO_MODE_FULLSCREEN : SCREEN_VIDEO_MODE_WINDOW; options.video.mode = options.video.mode == screenVideoMode::WINDOW ? screenVideoMode::FULLSCREEN : screenVideoMode::WINDOW;
setVideoMode(options.video.mode); setVideoMode(options.video.mode);
} }
@@ -308,7 +232,7 @@ void Screen::switchVideoMode()
void Screen::setWindowSize(int size) void Screen::setWindowSize(int size)
{ {
options.video.window.size = size; options.video.window.size = size;
setVideoMode(SCREEN_VIDEO_MODE_WINDOW); setVideoMode(screenVideoMode::WINDOW);
} }
// Reduce el tamaño de la ventana // Reduce el tamaño de la ventana
@@ -316,7 +240,7 @@ void Screen::decWindowSize()
{ {
--options.video.window.size; --options.video.window.size;
options.video.window.size = std::max(options.video.window.size, 1); options.video.window.size = std::max(options.video.window.size, 1);
setVideoMode(SCREEN_VIDEO_MODE_WINDOW); setVideoMode(screenVideoMode::WINDOW);
} }
// Aumenta el tamaño de la ventana // Aumenta el tamaño de la ventana
@@ -324,7 +248,7 @@ void Screen::incWindowSize()
{ {
++options.video.window.size; ++options.video.window.size;
options.video.window.size = std::min(options.video.window.size, 4); options.video.window.size = std::min(options.video.window.size, 4);
setVideoMode(SCREEN_VIDEO_MODE_WINDOW); setVideoMode(screenVideoMode::WINDOW);
} }
// Cambia el color del borde // Cambia el color del borde
@@ -356,7 +280,7 @@ void Screen::checkInput()
if (input->checkInput(input_window_fullscreen, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_window_fullscreen, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
switchVideoMode(); switchVideoMode();
const std::string mode = options.video.mode == SCREEN_VIDEO_MODE_WINDOW ? "Window" : "Fullscreen"; const std::string mode = options.video.mode == screenVideoMode::WINDOW ? "Window" : "Fullscreen";
showNotification(mode + " mode"); showNotification(mode + " mode");
return; return;
} }
@@ -420,7 +344,7 @@ void Screen::shake()
// Si ya hay un shake effect en marcha no se pilla el origen, solo se renuevan los contadores // Si ya hay un shake effect en marcha no se pilla el origen, solo se renuevan los contadores
if (shakeEffect.remaining == 0) if (shakeEffect.remaining == 0)
{ {
shakeEffect.origin = dest.x; shakeEffect.origin = srcrect.x;
} }
shakeEffect.remaining = shakeEffect.lenght; shakeEffect.remaining = shakeEffect.lenght;
@@ -439,14 +363,14 @@ void Screen::updateShake()
else else
{ {
shakeEffect.counter = shakeEffect.delay; shakeEffect.counter = shakeEffect.delay;
const int desp = shakeEffect.remaining % 2 == 0 ? shakeEffect.desp * (-1) : shakeEffect.desp; const auto desp = shakeEffect.remaining % 2 == 0 ? shakeEffect.desp * (-1) : shakeEffect.desp;
dest.x = shakeEffect.origin + desp; srcrect.x = shakeEffect.origin + desp;
shakeEffect.remaining--; shakeEffect.remaining--;
} }
} }
else else
{ {
dest.x = shakeEffect.origin; srcrect.x = shakeEffect.origin;
} }
} }
@@ -534,7 +458,7 @@ void Screen::displayInfo()
{ {
// FPS // FPS
const std::string fpstext = std::to_string(fps) + " FPS"; const std::string fpstext = std::to_string(fps) + " FPS";
dbg_print(gameCanvasWidth - fpstext.length() * 8, 0, fpstext.c_str(), 255, 255, 0); dbg_print(param.game.width - fpstext.length() * 8, 0, fpstext.c_str(), 255, 255, 0);
// Resolution // Resolution
dbg_print(0, 0, infoResolution.c_str(), 255, 255, 0); dbg_print(0, 0, infoResolution.c_str(), 255, 255, 0);

View File

@@ -1,21 +1,28 @@
#pragma once #pragma once
#include <SDL2/SDL_blendmode.h> // for SDL_BlendMode #include <SDL2/SDL_blendmode.h> // for SDL_BlendMode
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_video.h> // for SDL_Window #include <SDL2/SDL_video.h> // for SDL_Window
#include <string> // for basic_string, string #include <string> // for basic_string, string
#include "utils.h" // for color_t #include "utils.h" // for color_t
#include <memory>
class Asset; class Asset;
class Input; class Input;
class Notify; class Notify;
#define SCREEN_FILTER_NEAREST 0 enum class screenFilter
#define SCREEN_FILTER_LINEAL 1 {
NEAREST = 0,
LINEAL = 1,
};
#define SCREEN_VIDEO_MODE_WINDOW 0 enum class screenVideoMode
#define SCREEN_VIDEO_MODE_FULLSCREEN 1 {
WINDOW = 0,
FULLSCREEN = 1,
};
class Screen class Screen
{ {
@@ -24,19 +31,16 @@ private:
static Screen *screen; static Screen *screen;
// Objetos y punteros // Objetos y punteros
SDL_Window *window; // Ventana de la aplicación SDL_Window *window; // Ventana de la aplicación
SDL_Renderer *renderer; // El renderizador de la ventana SDL_Renderer *renderer; // El renderizador de la ventana
Asset *asset; // Objeto con el listado de recursos Asset *asset; // Objeto con el listado de recursos
Input *input; // Objeto para leer las entradas de teclado o mando Input *input; // Objeto para leer las entradas de teclado o mando
Notify *notify; // Pinta notificaciones en pantalla std::unique_ptr<Notify> notify; // Pinta notificaciones en pantalla
SDL_Texture *gameCanvas; // Textura para completar la ventana de juego hasta la pantalla completa SDL_Texture *gameCanvas; // Textura para completar la ventana de juego hasta la pantalla completa
// Variables // Variables
int windowWidth; // Ancho de la pantalla o ventana SDL_Rect srcrect; // Coordenadas de donde va a pillar la textura del juego para dibujarla
int windowHeight; // Alto de la pantalla o ventana SDL_Rect dstrect; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
bool attenuateEffect; // Indica si la pantalla ha de estar atenuada bool attenuateEffect; // Indica si la pantalla ha de estar atenuada
Uint32 fpsTicks; // Ticks para contar los frames por segundo Uint32 fpsTicks; // Ticks para contar los frames por segundo
@@ -81,7 +85,6 @@ private:
// Muestra información por pantalla // Muestra información por pantalla
void displayInfo(); void displayInfo();
// [SINGLETON] Ahora el constructor y el destructor son privados, para no poder crear objetos screen desde fuera // [SINGLETON] Ahora el constructor y el destructor son privados, para no poder crear objetos screen desde fuera
// Constructor // Constructor
@@ -116,7 +119,7 @@ public:
void blit(); void blit();
// Establece el modo de video // Establece el modo de video
void setVideoMode(int videoMode); void setVideoMode(screenVideoMode videoMode);
// Camibia entre pantalla completa y ventana // Camibia entre pantalla completa y ventana
void switchVideoMode(); void switchVideoMode();

View File

@@ -1,20 +1,9 @@
#include "sprite.h" #include "sprite.h"
#include "texture.h" // for Texture #include "texture.h" // for Texture
// Constructor // Constructor
Sprite::Sprite(int x, int y, int w, int h, Texture *texture) Sprite::Sprite(int x, int y, int w, int h, Texture *texture) : x(x), y(y), w(w), h(h), texture(texture)
{ {
// Establece la posición X,Y del sprite
this->x = x;
this->y = y;
// Establece el alto y el ancho del sprite
this->w = w;
this->h = h;
// Establece la textura donde están los gráficos para el sprite
this->texture = texture;
// Establece el rectangulo de donde coger la imagen // Establece el rectangulo de donde coger la imagen
spriteClip = {0, 0, w, h}; spriteClip = {0, 0, w, h};
@@ -22,19 +11,8 @@ Sprite::Sprite(int x, int y, int w, int h, Texture *texture)
enabled = true; enabled = true;
} }
Sprite::Sprite(SDL_Rect rect, Texture *texture) Sprite::Sprite(SDL_Rect rect, Texture *texture): x(rect.x), y(rect.y), w(rect.w), h(rect.h), texture(texture)
{ {
// Establece la posición X,Y del sprite
x = rect.x;
y = rect.y;
// Establece el alto y el ancho del sprite
w = rect.w;
h = rect.h;
// Establece la textura donde están los gráficos para el sprite
this->texture = texture;
// Establece el rectangulo de donde coger la imagen // Establece el rectangulo de donde coger la imagen
spriteClip = {0, 0, w, h}; spriteClip = {0, 0, w, h};
@@ -58,25 +36,25 @@ void Sprite::render()
} }
// Obten el valor de la variable // Obten el valor de la variable
int Sprite::getPosX() int Sprite::getPosX() const
{ {
return x; return x;
} }
// Obten el valor de la variable // Obten el valor de la variable
int Sprite::getPosY() int Sprite::getPosY() const
{ {
return y; return y;
} }
// Obten el valor de la variable // Obten el valor de la variable
int Sprite::getWidth() int Sprite::getWidth() const
{ {
return w; return w;
} }
// Obten el valor de la variable // Obten el valor de la variable
int Sprite::getHeight() int Sprite::getHeight() const
{ {
return h; return h;
} }
@@ -122,7 +100,7 @@ void Sprite::setHeight(int h)
} }
// Obten el valor de la variable // Obten el valor de la variable
SDL_Rect Sprite::getSpriteClip() SDL_Rect Sprite::getSpriteClip() const
{ {
return spriteClip; return spriteClip;
} }
@@ -158,16 +136,15 @@ void Sprite::setEnabled(bool value)
} }
// Comprueba si el objeto está habilitado // Comprueba si el objeto está habilitado
bool Sprite::isEnabled() bool Sprite::isEnabled() const
{ {
return enabled; return enabled;
} }
// Devuelve el rectangulo donde está el sprite // Devuelve el rectangulo donde está el sprite
SDL_Rect Sprite::getRect() SDL_Rect Sprite::getRect() const
{ {
SDL_Rect rect = {x, y, w, h}; return (SDL_Rect){x, y, w, h};
return rect;
} }
// Establece los valores de posición y tamaño del sprite // Establece los valores de posición y tamaño del sprite

View File

@@ -20,7 +20,7 @@ protected:
public: public:
// Constructor // Constructor
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, Texture *texture = nullptr); Sprite(int x = 0, int y = 0, int w = 0, int h = 0, Texture *texture = nullptr);
Sprite(SDL_Rect rect, Texture *texture); Sprite(SDL_Rect rect, Texture *texture = nullptr);
// Destructor // Destructor
~Sprite(); ~Sprite();
@@ -29,16 +29,16 @@ public:
void render(); void render();
// Obten el valor de la variable // Obten el valor de la variable
int getPosX(); int getPosX() const;
// Obten el valor de la variable // Obten el valor de la variable
int getPosY(); int getPosY() const;
// Obten el valor de la variable // Obten el valor de la variable
int getWidth(); int getWidth() const;
// Obten el valor de la variable // Obten el valor de la variable
int getHeight(); int getHeight() const;
// Establece la posición del objeto // Establece la posición del objeto
void setPos(SDL_Point p); void setPos(SDL_Point p);
@@ -63,7 +63,7 @@ public:
void setHeight(int h); void setHeight(int h);
// Obten el valor de la variable // Obten el valor de la variable
SDL_Rect getSpriteClip(); SDL_Rect getSpriteClip() const;
// Establece el valor de la variable // Establece el valor de la variable
void setSpriteClip(SDL_Rect rect); void setSpriteClip(SDL_Rect rect);
@@ -81,10 +81,10 @@ public:
void setEnabled(bool value); void setEnabled(bool value);
// Comprueba si el objeto está habilitado // Comprueba si el objeto está habilitado
bool isEnabled(); bool isEnabled() const;
// Devuelve el rectangulo donde está el sprite // Devuelve el rectangulo donde está el sprite
SDL_Rect getRect(); SDL_Rect getRect() const;
// Establece los valores de posición y tamaño del sprite // Establece los valores de posición y tamaño del sprite
void setRect(SDL_Rect rect); void setRect(SDL_Rect rect);

View File

@@ -10,11 +10,16 @@
#include "input.h" // for inputs_e #include "input.h" // for inputs_e
struct JA_Music_t; struct JA_Music_t;
struct JA_Sound_t; struct JA_Sound_t;
enum class screenFilter;
enum class screenVideoMode;
// Dificultad del juego // Dificultad del juego
#define DIFFICULTY_EASY 0 enum class gameDifficulty
#define DIFFICULTY_NORMAL 1 {
#define DIFFICULTY_HARD 2 EASY = 0,
NORMAL = 1,
HARD = 2,
};
// Tamaño de bloque // Tamaño de bloque
#define BLOCK 8 #define BLOCK 8
@@ -22,9 +27,7 @@ struct JA_Sound_t;
// Estructura para definir un circulo // Estructura para definir un circulo
struct circle_t struct circle_t
{ {
int x; int x, y, r;
int y;
int r;
}; };
// Estructura para definir una linea horizontal // Estructura para definir una linea horizontal
@@ -54,9 +57,7 @@ struct line_t
// Estructura para definir un color // Estructura para definir un color
struct color_t struct color_t
{ {
Uint8 r; Uint8 r, g, b;
Uint8 g;
Uint8 b;
}; };
// Posiciones de las notificaciones // Posiciones de las notificaciones
@@ -97,23 +98,17 @@ struct demoKeys_t
// Estructura para las opciones de la ventana // Estructura para las opciones de la ventana
struct op_window_t struct op_window_t
{ {
int width; // Ancho de la ventana
int height; // Alto de la ventana
int size; // Contiene el valor por el que se multiplica el tamaño de la ventana int size; // Contiene el valor por el que se multiplica el tamaño de la ventana
}; };
// Estructura con opciones para el video // Estructura con opciones para el video
struct op_video_t struct op_video_t
{ {
int gameWidth; // Ancho de la resolucion nativa del juego op_window_t window; // Opciones para la ventana del programa
int gameHeight; // Alto de la resolucion nativa del juego screenVideoMode mode; // Contiene el valor del modo de pantalla completa
op_window_t window; // Opciones para la ventana del programa screenFilter filter; // Filtro usado para el escalado de la imagen
Uint32 mode; // Contiene el valor del modo de pantalla completa bool vSync; // Indica si se quiere usar vsync o no
Uint32 filter; // Filtro usado para el escalado de la imagen bool shaders; // Indica si se van a usar shaders para los filtros de video
bool vSync; // Indica si se quiere usar vsync o no
bool integerScale; // Indica si el escalado de la imagen ha de ser entero en el modo a pantalla completa
bool keepAspect; // Indica si se ha de mantener la relación de aspecto al poner el modo a pantalla completa
bool shaders; // Indica si se van a usar shaders para los filtros de video
}; };
// Estructura para las opciones de musica // Estructura para las opciones de musica
@@ -140,7 +135,7 @@ struct op_audio_t
// Estructura para las opciones del juego // Estructura para las opciones del juego
struct op_game_t struct op_game_t
{ {
Uint8 difficulty; // Dificultad del juego gameDifficulty difficulty; // Dificultad del juego
Uint8 language; // Idioma usado en el juego Uint8 language; // Idioma usado en el juego
bool autofire; // Indica si el jugador ha de pulsar repetidamente para disparar o basta con mantener pulsado bool autofire; // Indica si el jugador ha de pulsar repetidamente para disparar o basta con mantener pulsado
std::vector<hiScoreEntry_t> hiScoreTable; // Tabla con las mejores puntuaciones std::vector<hiScoreEntry_t> hiScoreTable; // Tabla con las mejores puntuaciones