La tabla de puntuació ja mostra amb altre color la puntuació que s'acaba d'afegir
fix: la tabla de punts no guardava a disc el estat de 1CC de cada entrada
This commit is contained in:
@@ -1370,11 +1370,11 @@ 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(const std::string &name, int score, bool one_credit_continue)
|
void Game::addScoreToScoreBoard(const std::shared_ptr<Player> &player)
|
||||||
{
|
{
|
||||||
const auto entry = HiScoreEntry(trim(name), score);
|
const auto entry = HiScoreEntry(trim(player->getRecordName()), player->getScore(), player->get1CC());
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
||||||
manager->add(entry);
|
options.game.last_hi_score_entry.at(player->getId() - 1) = manager->add(entry);
|
||||||
manager->saveToFile(asset_->get("score.bin"));
|
manager->saveToFile(asset_->get("score.bin"));
|
||||||
hi_score_.name = options.game.hi_score_table.front().name;
|
hi_score_.name = options.game.hi_score_table.front().name;
|
||||||
}
|
}
|
||||||
@@ -1627,16 +1627,20 @@ void Game::handlePlayerContinue(const std::shared_ptr<Player> &player)
|
|||||||
if (input_->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
if (input_->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
player->setPlayingState(PlayerState::PLAYING);
|
player->setPlayingState(PlayerState::PLAYING);
|
||||||
|
player->addCredit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
// Disminuye el contador de continuación si se presiona cualquier botón de disparo.
|
||||||
if (input_->checkInput(InputType::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
|
if (input_->checkInput(InputType::FIRE_LEFT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
|
||||||
input_->checkInput(InputType::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
|
input_->checkInput(InputType::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
|
||||||
input_->checkInput(InputType::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
input_->checkInput(InputType::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
||||||
|
{
|
||||||
|
if (player->getContinueCounter() < 8)
|
||||||
{
|
{
|
||||||
player->decContinueCounter();
|
player->decContinueCounter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Procesa las entradas para la introducción del nombre del jugador.
|
// Procesa las entradas para la introducción del nombre del jugador.
|
||||||
void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
||||||
@@ -1649,7 +1653,7 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
|||||||
if (player->getRecordNamePos() == NAME_LENGHT - 1)
|
if (player->getRecordNamePos() == NAME_LENGHT - 1)
|
||||||
{
|
{
|
||||||
player->setInput(InputType::START);
|
player->setInput(InputType::START);
|
||||||
addScoreToScoreBoard(player->getRecordName(), player->getScore(), player->get1CC());
|
addScoreToScoreBoard(player);
|
||||||
const auto state = player->getPlayingState();
|
const auto state = player->getPlayingState();
|
||||||
player->setPlayingState(state == PlayerState::ENTERING_NAME ? PlayerState::CONTINUE : PlayerState::LEAVING_SCREEN);
|
player->setPlayingState(state == PlayerState::ENTERING_NAME ? PlayerState::CONTINUE : PlayerState::LEAVING_SCREEN);
|
||||||
}
|
}
|
||||||
@@ -1673,7 +1677,7 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
|||||||
else if (input_->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
else if (input_->checkInput(InputType::START, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
|
||||||
{
|
{
|
||||||
player->setInput(InputType::START);
|
player->setInput(InputType::START);
|
||||||
addScoreToScoreBoard(player->getRecordName(), player->getScore(), player->get1CC());
|
addScoreToScoreBoard(player);
|
||||||
const auto state = player->getPlayingState();
|
const auto state = player->getPlayingState();
|
||||||
player->setPlayingState(state == PlayerState::ENTERING_NAME ? PlayerState::CONTINUE : PlayerState::LEAVING_SCREEN);
|
player->setPlayingState(state == PlayerState::ENTERING_NAME ? PlayerState::CONTINUE : PlayerState::LEAVING_SCREEN);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ private:
|
|||||||
void pause(bool value);
|
void pause(bool value);
|
||||||
|
|
||||||
// Añade una puntuación a la tabla de records
|
// Añade una puntuación a la tabla de records
|
||||||
void addScoreToScoreBoard(const std::string &name, int score, bool one_credit_continue);
|
void addScoreToScoreBoard(const std::shared_ptr<Player> &player);
|
||||||
|
|
||||||
// Saca del estado de GAME OVER al jugador si el otro está activo
|
// Saca del estado de GAME OVER al jugador si el otro está activo
|
||||||
void checkAndUpdatePlayerStatus(int active_player_index, int inactive_player_index);
|
void checkAndUpdatePlayerStatus(int active_player_index, int inactive_player_index);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ HiScoreTable::HiScoreTable()
|
|||||||
SDL_SetTextureBlendMode(backbuffer_, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(backbuffer_, SDL_BLENDMODE_BLEND);
|
||||||
initFade();
|
initFade();
|
||||||
initBackground();
|
initBackground();
|
||||||
|
iniEntryColors();
|
||||||
createSprites();
|
createSprites();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ HiScoreTable::HiScoreTable()
|
|||||||
HiScoreTable::~HiScoreTable()
|
HiScoreTable::~HiScoreTable()
|
||||||
{
|
{
|
||||||
SDL_DestroyTexture(backbuffer_);
|
SDL_DestroyTexture(backbuffer_);
|
||||||
|
options.game.clear_last_hi_score_entries();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
@@ -364,6 +366,8 @@ void HiScoreTable::updateSprites()
|
|||||||
{
|
{
|
||||||
entry->update();
|
entry->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glowEntryNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el fade
|
// Inicializa el fade
|
||||||
@@ -419,3 +423,45 @@ void HiScoreTable::initBackground()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtiene un color del vector de colores de entradas
|
||||||
|
Color HiScoreTable::getEntryColor(int counter_)
|
||||||
|
{
|
||||||
|
int cycle_length = entry_colors_.size() * 2 - 2; // Esto es 6 en este caso
|
||||||
|
int n = counter_ % cycle_length;
|
||||||
|
|
||||||
|
int index;
|
||||||
|
if (n < entry_colors_.size())
|
||||||
|
{
|
||||||
|
index = n; // Avanza: 0,1,2,3
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index = 2 * (entry_colors_.size() - 1) - n; // Retrocede: 2,1
|
||||||
|
}
|
||||||
|
|
||||||
|
return entry_colors_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializa los colores de las entradas
|
||||||
|
void HiScoreTable::iniEntryColors()
|
||||||
|
{
|
||||||
|
entry_colors_.clear();
|
||||||
|
entry_colors_.emplace_back(background_fade_color_.getInverse().lighten(75));
|
||||||
|
entry_colors_.emplace_back(background_fade_color_.getInverse().lighten(50));
|
||||||
|
entry_colors_.emplace_back(background_fade_color_.getInverse().lighten(25));
|
||||||
|
entry_colors_.emplace_back(background_fade_color_.getInverse());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hace brillar los nombres de la tabla de records
|
||||||
|
void HiScoreTable::glowEntryNames()
|
||||||
|
{
|
||||||
|
const Color entry_color = getEntryColor(counter_ / 5);
|
||||||
|
for (const auto& entry_index : options.game.last_hi_score_entry)
|
||||||
|
{
|
||||||
|
if (entry_index != -1)
|
||||||
|
{
|
||||||
|
entry_names_.at(entry_index)->getTexture()->setColor(entry_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ private:
|
|||||||
SDL_Rect view_area_; // Parte de la textura que se muestra en pantalla
|
SDL_Rect view_area_; // Parte de la textura que se muestra en pantalla
|
||||||
FadeMode fade_mode_; // Modo de fade a utilizar
|
FadeMode fade_mode_; // Modo de fade a utilizar
|
||||||
Color background_fade_color_; // Color de atenuación del fondo
|
Color background_fade_color_; // Color de atenuación del fondo
|
||||||
|
std::vector<Color> entry_colors_; // Colores para destacar las entradas en la tabla
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
@@ -84,6 +85,15 @@ private:
|
|||||||
// Inicializa el fondo
|
// Inicializa el fondo
|
||||||
void initBackground();
|
void initBackground();
|
||||||
|
|
||||||
|
// Obtiene un color del vector de colores de entradas
|
||||||
|
Color getEntryColor(int counter_);
|
||||||
|
|
||||||
|
// Inicializa los colores de las entradas
|
||||||
|
void iniEntryColors();
|
||||||
|
|
||||||
|
// Hace brillar los nombres de la tabla de records
|
||||||
|
void glowEntryNames();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
HiScoreTable();
|
HiScoreTable();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ void ManageHiScoreTable::clear()
|
|||||||
|
|
||||||
// Añade 10 entradas predefinidas
|
// Añade 10 entradas predefinidas
|
||||||
table_.push_back(HiScoreEntry("BRY", 1000000));
|
table_.push_back(HiScoreEntry("BRY", 1000000));
|
||||||
table_.push_back(HiScoreEntry("USUFON", 500000, true));
|
table_.push_back(HiScoreEntry("USUFON", 500000));
|
||||||
table_.push_back(HiScoreEntry("GLUCAS", 100000));
|
table_.push_back(HiScoreEntry("GLUCAS", 100000));
|
||||||
table_.push_back(HiScoreEntry("PDLGAT", 50000));
|
table_.push_back(HiScoreEntry("PDLGAT", 50000));
|
||||||
table_.push_back(HiScoreEntry("PARRAB", 10000));
|
table_.push_back(HiScoreEntry("PARRAB", 10000));
|
||||||
@@ -27,7 +27,7 @@ void ManageHiScoreTable::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade un elemento a la tabla
|
// Añade un elemento a la tabla
|
||||||
void ManageHiScoreTable::add(HiScoreEntry entry)
|
int ManageHiScoreTable::add(const HiScoreEntry &entry)
|
||||||
{
|
{
|
||||||
// Añade la entrada a la tabla
|
// Añade la entrada a la tabla
|
||||||
table_.push_back(entry);
|
table_.push_back(entry);
|
||||||
@@ -35,8 +35,32 @@ void ManageHiScoreTable::add(HiScoreEntry entry)
|
|||||||
// Ordena la tabla
|
// Ordena la tabla
|
||||||
sort();
|
sort();
|
||||||
|
|
||||||
|
// Encontrar la posición del nuevo elemento
|
||||||
|
auto it = std::find_if(table_.begin(), table_.end(), [&](const HiScoreEntry &e)
|
||||||
|
{ return e.name == entry.name &&
|
||||||
|
e.score == entry.score &&
|
||||||
|
e.one_credit_complete == entry.one_credit_complete; });
|
||||||
|
|
||||||
|
int position = -1;
|
||||||
|
if (it != table_.end())
|
||||||
|
{
|
||||||
|
position = std::distance(table_.begin(), it);
|
||||||
|
}
|
||||||
|
|
||||||
// Deja solo las 10 primeras entradas
|
// Deja solo las 10 primeras entradas
|
||||||
|
if (table_.size() > 10)
|
||||||
|
{
|
||||||
table_.resize(10);
|
table_.resize(10);
|
||||||
|
|
||||||
|
// Si el nuevo elemento quedó fuera del top 10
|
||||||
|
if (position >= 10)
|
||||||
|
{
|
||||||
|
position = -1; // No entró en el top 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Devuelve la posición
|
||||||
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ordena la tabla
|
// Ordena la tabla
|
||||||
@@ -50,52 +74,55 @@ void ManageHiScoreTable::sort()
|
|||||||
std::sort(table_.begin(), table_.end(), scoreDescendingComparator);
|
std::sort(table_.begin(), table_.end(), scoreDescendingComparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga la tabla con los datos de un fichero
|
// Carga la tabla desde un fichero
|
||||||
bool ManageHiScoreTable::loadFromFile(const std::string &file_path)
|
bool ManageHiScoreTable::loadFromFile(const std::string &file_path)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
auto success = true;
|
auto success = true;
|
||||||
auto file = SDL_RWFromFile(file_path.c_str(), "r+b");
|
auto file = SDL_RWFromFile(file_path.c_str(), "rb");
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
std::cout << "Reading file: " << getFileName(file_path) << std::endl;
|
table_.clear(); // Limpia la tabla actual
|
||||||
|
|
||||||
for (auto &entry : table_)
|
// Lee el número de entradas en la tabla
|
||||||
|
int tableSize = 0;
|
||||||
|
SDL_RWread(file, &tableSize, sizeof(int), 1);
|
||||||
|
|
||||||
|
// Lee los datos de cada entrada
|
||||||
|
for (int i = 0; i < tableSize; ++i)
|
||||||
{
|
{
|
||||||
|
HiScoreEntry entry;
|
||||||
|
|
||||||
|
// Lee la puntuación
|
||||||
|
SDL_RWread(file, &entry.score, sizeof(int), 1);
|
||||||
|
|
||||||
|
// Lee el tamaño del nombre y luego el nombre
|
||||||
int nameSize = 0;
|
int nameSize = 0;
|
||||||
|
SDL_RWread(file, &nameSize, sizeof(int), 1);
|
||||||
if (SDL_RWread(file, &entry.score, sizeof(int), 1) == 0)
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_RWread(file, &nameSize, sizeof(int), 1) == 0)
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<char> nameBuffer(nameSize + 1);
|
std::vector<char> nameBuffer(nameSize + 1);
|
||||||
if (SDL_RWread(file, nameBuffer.data(), sizeof(char) * nameSize, 1) == 0)
|
SDL_RWread(file, nameBuffer.data(), nameSize, 1);
|
||||||
{
|
nameBuffer[nameSize] = '\0'; // Asegurar el fin de la cadena
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nameBuffer[nameSize] = '\0';
|
|
||||||
entry.name = std::string(nameBuffer.data());
|
entry.name = std::string(nameBuffer.data());
|
||||||
|
|
||||||
|
// Lee el valor de one_credit_complete
|
||||||
|
int occValue = 0;
|
||||||
|
SDL_RWread(file, &occValue, sizeof(int), 1);
|
||||||
|
entry.one_credit_complete = (occValue != 0);
|
||||||
|
|
||||||
|
// Añade la entrada a la tabla
|
||||||
|
table_.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "Reading file: " << getFileName(file_path) << std::endl;
|
||||||
SDL_RWclose(file);
|
SDL_RWclose(file);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!success)
|
|
||||||
{
|
{
|
||||||
clear();
|
std::cout << "Error: Unable to load " << getFileName(file_path) << " file! " << SDL_GetError() << std::endl;
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,21 +134,35 @@ bool ManageHiScoreTable::saveToFile(const std::string &file_path)
|
|||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
// Guarda los datos
|
// Guarda el número de entradas en la tabla
|
||||||
for (int i = 0; i < (int)table_.size(); ++i)
|
int tableSize = static_cast<int>(table_.size());
|
||||||
|
SDL_RWwrite(file, &tableSize, sizeof(int), 1);
|
||||||
|
|
||||||
|
// Guarda los datos de cada entrada
|
||||||
|
for (int i = 0; i < tableSize; ++i)
|
||||||
{
|
{
|
||||||
SDL_RWwrite(file, &table_.at(i).score, sizeof(int), 1);
|
const HiScoreEntry& entry = table_.at(i);
|
||||||
const int nameSize = (int)table_.at(i).name.size();
|
|
||||||
|
// Guarda la puntuación
|
||||||
|
SDL_RWwrite(file, &entry.score, sizeof(int), 1);
|
||||||
|
|
||||||
|
// Guarda el tamaño del nombre y luego el nombre
|
||||||
|
int nameSize = static_cast<int>(entry.name.size());
|
||||||
SDL_RWwrite(file, &nameSize, sizeof(int), 1);
|
SDL_RWwrite(file, &nameSize, sizeof(int), 1);
|
||||||
SDL_RWwrite(file, table_.at(i).name.c_str(), nameSize, 1);
|
SDL_RWwrite(file, entry.name.c_str(), nameSize, 1);
|
||||||
|
|
||||||
|
// Guarda el valor de one_credit_complete como un entero (0 o 1)
|
||||||
|
int occValue = entry.one_credit_complete ? 1 : 0;
|
||||||
|
SDL_RWwrite(file, &occValue, sizeof(int), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Writing file: " << getFileName(file_path).c_str() << std::endl;
|
std::cout << "Writing file: " << getFileName(file_path) << std::endl;
|
||||||
SDL_RWclose(file);
|
SDL_RWclose(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Error: Unable to save " << getFileName(file_path).c_str() << " file! " << SDL_GetError() << std::endl;
|
std::cout << "Error: Unable to save " << getFileName(file_path) << " file! " << SDL_GetError() << std::endl;
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// Añade un elemento a la tabla
|
// Añade un elemento a la tabla
|
||||||
void add(HiScoreEntry entry);
|
int add(const HiScoreEntry& entry);
|
||||||
|
|
||||||
// Carga la tabla con los datos de un fichero
|
// Carga la tabla con los datos de un fichero
|
||||||
bool loadFromFile(const std::string &file_path);
|
bool loadFromFile(const std::string &file_path);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ void initOptions()
|
|||||||
options.game.difficulty = GameDifficulty::NORMAL;
|
options.game.difficulty = GameDifficulty::NORMAL;
|
||||||
options.game.language = lang::Code::ba_BA;
|
options.game.language = lang::Code::ba_BA;
|
||||||
options.game.autofire = true;
|
options.game.autofire = true;
|
||||||
|
options.game.clear_last_hi_score_entries();
|
||||||
|
|
||||||
// Opciones de control
|
// Opciones de control
|
||||||
options.controllers.clear();
|
options.controllers.clear();
|
||||||
|
|||||||
@@ -66,8 +66,16 @@ struct OptionsGame
|
|||||||
{
|
{
|
||||||
GameDifficulty difficulty; // Dificultad del juego
|
GameDifficulty difficulty; // Dificultad del juego
|
||||||
lang::Code language; // Idioma usado en el juego
|
lang::Code 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; // Indicador de autofire
|
||||||
std::vector<HiScoreEntry> hi_score_table; // Tabla con las mejores puntuaciones
|
std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones
|
||||||
|
std::vector<int> last_hi_score_entry = { -1, -1 }; // Inicialización directa con dos elementos en -1
|
||||||
|
|
||||||
|
// Método para reiniciar las últimas entradas de puntuación
|
||||||
|
void clear_last_hi_score_entries()
|
||||||
|
{
|
||||||
|
last_hi_score_entry[0] = -1;
|
||||||
|
last_hi_score_entry[1] = -1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para los controles del juego
|
// Estructura para los controles del juego
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ void Player::init()
|
|||||||
score_multiplier_ = 1.0f;
|
score_multiplier_ = 1.0f;
|
||||||
cool_down_ = 10;
|
cool_down_ = 10;
|
||||||
enter_name_->init();
|
enter_name_->init();
|
||||||
++credits_used_;
|
|
||||||
|
|
||||||
// Establece la posición del sprite
|
// Establece la posición del sprite
|
||||||
player_sprite_->clear();
|
player_sprite_->clear();
|
||||||
@@ -531,7 +530,7 @@ void Player::setPlayingState(PlayerState state)
|
|||||||
// Activa la animación de morir
|
// Activa la animación de morir
|
||||||
player_sprite_->setAccelY(0.2f);
|
player_sprite_->setAccelY(0.2f);
|
||||||
player_sprite_->setVelY(-6.6f);
|
player_sprite_->setVelY(-6.6f);
|
||||||
rand() % 2 == 0 ? player_sprite_->setVelX(3.3f) : player_sprite_->setVelX(-3.3f);
|
(rand() % 2 == 0) ? player_sprite_->setVelX(3.3f) : player_sprite_->setVelX(-3.3f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PlayerState::DIED:
|
case PlayerState::DIED:
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ private:
|
|||||||
Uint32 enter_name_ticks_ = 0; // Variable para poder cambiar el contador de poner nombre en función del tiempo
|
Uint32 enter_name_ticks_ = 0; // Variable para poder cambiar el contador de poner nombre en función del tiempo
|
||||||
int step_counter_ = 0; // Cuenta los pasos para los estados en los que camina automáticamente
|
int step_counter_ = 0; // Cuenta los pasos para los estados en los que camina automáticamente
|
||||||
bool game_completed_ = false; // Indica si ha completado el juego
|
bool game_completed_ = false; // Indica si ha completado el juego
|
||||||
int credits_used_ = 0; // Indica el numero de veces que ha continuado
|
int credits_used_ = 1; // Indica el numero de veces que ha continuado
|
||||||
|
|
||||||
// Actualiza el circulo de colisión a la posición del jugador
|
// Actualiza el circulo de colisión a la posición del jugador
|
||||||
void shiftColliders();
|
void shiftColliders();
|
||||||
@@ -245,4 +245,5 @@ public:
|
|||||||
void setScoreBoardPanel(int panel) { scoreboard_panel_ = panel; }
|
void setScoreBoardPanel(int panel) { scoreboard_panel_ = panel; }
|
||||||
void setScoreMultiplier(float value) { score_multiplier_ = value; }
|
void setScoreMultiplier(float value) { score_multiplier_ = value; }
|
||||||
void setWalkingState(PlayerState state) { walking_state_ = state; }
|
void setWalkingState(PlayerState state) { walking_state_ = state; }
|
||||||
|
void addCredit() { ++credits_used_; }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -394,10 +394,9 @@ void Screen::renderInfo()
|
|||||||
|
|
||||||
// Contador de service_pressed_counter
|
// Contador de service_pressed_counter
|
||||||
if (const int counter = globalInputs::service_pressed_counter; counter > 0)
|
if (const int counter = globalInputs::service_pressed_counter; counter > 0)
|
||||||
|
{
|
||||||
dbg_print(0, 8, std::to_string(counter).c_str(), 255, 0, 255);
|
dbg_print(0, 8, std::to_string(counter).c_str(), 255, 0, 255);
|
||||||
|
}
|
||||||
const std::string atten = attenuate_effect_ ? "ATTEN YES" : "ATTEN NO";
|
|
||||||
dbg_print(0, 16, atten.c_str(), 255, 0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user