La tabla de puntuacions ja mostra aquelles aconseguides amb 1CC
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1370,7 +1370,7 @@ 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)
|
void Game::addScoreToScoreBoard(const std::string &name, int score, bool one_credit_continue)
|
||||||
{
|
{
|
||||||
const auto entry = HiScoreEntry(trim(name), score);
|
const auto entry = HiScoreEntry(trim(name), score);
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
||||||
@@ -1649,7 +1649,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());
|
addScoreToScoreBoard(player->getRecordName(), player->getScore(), player->get1CC());
|
||||||
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 +1673,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());
|
addScoreToScoreBoard(player->getRecordName(), player->getScore(), player->get1CC());
|
||||||
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);
|
void addScoreToScoreBoard(const std::string &name, int score, bool one_credit_continue);
|
||||||
|
|
||||||
// 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);
|
||||||
|
|||||||
@@ -266,9 +266,9 @@ void HiScoreTable::createSprites()
|
|||||||
int backbuffer_height;
|
int backbuffer_height;
|
||||||
SDL_QueryTexture(backbuffer_, nullptr, nullptr, &backbuffer_width, &backbuffer_height);
|
SDL_QueryTexture(backbuffer_, nullptr, nullptr, &backbuffer_width, &backbuffer_height);
|
||||||
|
|
||||||
// Hay 27 letras - 7 de puntos quedan 20 caracteres 20 - name_lenght 0 num_dots <-- Esto no se qué coño es
|
constexpr int entry_lenght = 22;
|
||||||
constexpr int max_names = 10;
|
constexpr int max_names = 10;
|
||||||
constexpr int space_between_header = 32;
|
const int space_between_header = entry_text->getCharacterSize() * 4;
|
||||||
const int space_between_lines = entry_text->getCharacterSize() * 2;
|
const int space_between_lines = entry_text->getCharacterSize() * 2;
|
||||||
const int size = space_between_header + space_between_lines * (max_names - 1) + entry_text->getCharacterSize();
|
const int size = space_between_header + space_between_lines * (max_names - 1) + entry_text->getCharacterSize();
|
||||||
const int first_line = (param.game.height - size) / 2;
|
const int first_line = (param.game.height - size) / 2;
|
||||||
@@ -279,21 +279,25 @@ void HiScoreTable::createSprites()
|
|||||||
|
|
||||||
// Crea los sprites para las entradas en la tabla de puntuaciones
|
// Crea los sprites para las entradas en la tabla de puntuaciones
|
||||||
const int animation = rand() % 4;
|
const int animation = rand() % 4;
|
||||||
|
const std::string sample_line(entry_lenght + 3, ' ');
|
||||||
|
auto sample_entry = std::make_unique<Sprite>(entry_text->writeDXToTexture(TEXT_SHADOW, sample_line, 1, orange_color, 1, shdw_txt_color));
|
||||||
|
const auto entry_width = sample_entry->getWidth();
|
||||||
for (int i = 0; i < max_names; ++i)
|
for (int i = 0; i < max_names; ++i)
|
||||||
{
|
{
|
||||||
// const auto table_position = (i + 1 >= 10) ? format(i + 1) + ". " : " " + format(i + 1) + ". ";
|
|
||||||
const auto table_position = format(i + 1) + ". ";
|
const auto table_position = format(i + 1) + ". ";
|
||||||
const auto score = format(options.game.hi_score_table.at(i).score);
|
const auto score = format(options.game.hi_score_table.at(i).score);
|
||||||
const auto num_dots = 22 - options.game.hi_score_table.at(i).name.size() - score.size();
|
const auto num_dots = entry_lenght - options.game.hi_score_table.at(i).name.size() - score.size();
|
||||||
|
const auto one_cc = options.game.hi_score_table.at(i).one_credit_complete ? " }" : "";
|
||||||
std::string dots;
|
std::string dots;
|
||||||
for (int j = 0; j < (int)num_dots; ++j)
|
for (int j = 0; j < (int)num_dots; ++j)
|
||||||
{
|
{
|
||||||
dots = dots + ".";
|
dots = dots + ".";
|
||||||
}
|
}
|
||||||
const auto line = table_position + options.game.hi_score_table.at(i).name + dots + score;
|
const auto line = table_position + options.game.hi_score_table.at(i).name + dots + score + one_cc;
|
||||||
|
|
||||||
entry_names_.emplace_back(std::make_shared<PathSprite>(entry_text->writeDXToTexture(TEXT_SHADOW, line, 1, orange_color, 1, shdw_txt_color)));
|
entry_names_.emplace_back(std::make_shared<PathSprite>(entry_text->writeDXToTexture(TEXT_SHADOW, line, 1, orange_color, 1, shdw_txt_color)));
|
||||||
const int pos_x = (i < 9) ? (backbuffer_width - entry_names_.front()->getWidth()) / 2 : (backbuffer_width - entry_names_.front()->getWidth()) / 2 - entry_text->getCharacterSize();
|
const int default_pos_x = (backbuffer_width - entry_width) / 2;
|
||||||
|
const int pos_x = (i < 9) ? default_pos_x : default_pos_x - entry_text->getCharacterSize();
|
||||||
const int pos_y = (i * space_between_lines) + first_line + space_between_header;
|
const int pos_y = (i * space_between_lines) + first_line + space_between_header;
|
||||||
constexpr int steps = 80;
|
constexpr int steps = 80;
|
||||||
switch (animation)
|
switch (animation)
|
||||||
|
|||||||
@@ -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));
|
table_.push_back(HiScoreEntry("USUFON", 500000, true));
|
||||||
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));
|
||||||
|
|||||||
@@ -14,13 +14,13 @@
|
|||||||
// Estructura para las entradas de la tabla de recirds
|
// Estructura para las entradas de la tabla de recirds
|
||||||
struct HiScoreEntry
|
struct HiScoreEntry
|
||||||
{
|
{
|
||||||
std::string name; // Nombre
|
std::string name; // Nombre
|
||||||
int score = 0; // Puntuación
|
int score; // Puntuación
|
||||||
bool one_credit_complete = false; // Indica si se ha conseguido 1CC
|
bool one_credit_complete; // Indica si se ha conseguido 1CC
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
explicit HiScoreEntry(const std::string &n = "", int s = 0)
|
explicit HiScoreEntry(const std::string &n = "", int s = 0, bool occ = false)
|
||||||
: name(n), score(s) {}
|
: name(n.substr(0, 5)), score(s), one_credit_complete(occ) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clase ManageHiScoreTable
|
// Clase ManageHiScoreTable
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ 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();
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ public:
|
|||||||
int getWidth() const { return WIDTH_; }
|
int getWidth() const { return WIDTH_; }
|
||||||
PlayerState getPlayingState() const { return playing_state_; }
|
PlayerState getPlayingState() const { return playing_state_; }
|
||||||
std::string getName() const { return name_; }
|
std::string getName() const { return name_; }
|
||||||
bool get1CC() const { return game_completed_ && credits_used_ == 0; }
|
bool get1CC() const { return game_completed_ && credits_used_ == 1; }
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
void setController(int index) { controller_index_ = index; }
|
void setController(int index) { controller_index_ = index; }
|
||||||
|
|||||||
Reference in New Issue
Block a user