Arreglos varios relacionats amb el nom al obtenir la màxima puntuació:
No canviava al marcador, ni el nom del que tenia la maxima puntuació en calent ni al posar nom retallat el nom de 8 a 6 caracters, i tots en majuscula pa que capia en el marcador ja actualitza be la cadena amb el nom al posar nom per segona vegada en la mateixa partida
This commit is contained in:
@@ -158,19 +158,19 @@ Felicitats!!
|
|||||||
2 JUGADORS
|
2 JUGADORS
|
||||||
|
|
||||||
## 53 MARCADOR
|
## 53 MARCADOR
|
||||||
jugador 1
|
Jugador 1
|
||||||
|
|
||||||
## 54 MARCADOR
|
## 54 MARCADOR
|
||||||
jugador 2
|
Jugador 2
|
||||||
|
|
||||||
## 55 MARCADOR
|
## 55 MARCADOR
|
||||||
mult
|
Multiplicador
|
||||||
|
|
||||||
## 56 MARCADOR
|
## 56 MARCADOR
|
||||||
max. puntuacio
|
Max. puntuacio
|
||||||
|
|
||||||
## 57 MARCADOR
|
## 57 MARCADOR
|
||||||
fase
|
Fase
|
||||||
|
|
||||||
## 58 - MENU DE OPCIONES
|
## 58 - MENU DE OPCIONES
|
||||||
MODE DE VISUALITZACIO
|
MODE DE VISUALITZACIO
|
||||||
|
|||||||
@@ -158,19 +158,19 @@ Congratulations!!
|
|||||||
2 PLAYERS
|
2 PLAYERS
|
||||||
|
|
||||||
## 53 - MARCADOR
|
## 53 - MARCADOR
|
||||||
player 1
|
Player 1
|
||||||
|
|
||||||
## 54 - MARCADOR
|
## 54 - MARCADOR
|
||||||
player 2
|
Player 2
|
||||||
|
|
||||||
## 55 - MARCADOR
|
## 55 - MARCADOR
|
||||||
mult
|
Multiplier
|
||||||
|
|
||||||
## 56 - MARCADOR
|
## 56 - MARCADOR
|
||||||
high score
|
High Score
|
||||||
|
|
||||||
## 57 - MARCADOR
|
## 57 - MARCADOR
|
||||||
stage
|
Stage
|
||||||
|
|
||||||
## 58 - MENU DE OPCIONES
|
## 58 - MENU DE OPCIONES
|
||||||
DISPLAY MODE
|
DISPLAY MODE
|
||||||
|
|||||||
@@ -158,19 +158,19 @@ Felicidades!!
|
|||||||
2 JUGADORES
|
2 JUGADORES
|
||||||
|
|
||||||
## 53 - MARCADOR
|
## 53 - MARCADOR
|
||||||
jugador 1
|
Jugador 1
|
||||||
|
|
||||||
## 54 - MARCADOR
|
## 54 - MARCADOR
|
||||||
jugador 2
|
Jugador 2
|
||||||
|
|
||||||
## 55 - MARCADOR
|
## 55 - MARCADOR
|
||||||
mult
|
Multiplicador
|
||||||
|
|
||||||
## 56 - MARCADOR
|
## 56 - MARCADOR
|
||||||
max. puntuacion
|
Max. puntuacion
|
||||||
|
|
||||||
## 57 - MARCADOR
|
## 57 - MARCADOR
|
||||||
FASE
|
Fase
|
||||||
|
|
||||||
## 58 - MENU DE OPCIONES
|
## 58 - MENU DE OPCIONES
|
||||||
MODO DE VISUALIZACION
|
MODO DE VISUALIZACION
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
constexpr int NAME_LENGHT = 8;
|
constexpr int NAME_LENGHT = 6;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Un array, "characterList", contiene la lista de caracteres
|
Un array, "characterList", contiene la lista de caracteres
|
||||||
|
|||||||
@@ -184,6 +184,8 @@ void Game::updateHiScore()
|
|||||||
{
|
{
|
||||||
// Actualiza la máxima puntuación
|
// Actualiza la máxima puntuación
|
||||||
hi_score_.score = player->getScore();
|
hi_score_.score = player->getScore();
|
||||||
|
hi_score_.name.clear();
|
||||||
|
;
|
||||||
|
|
||||||
// Si se supera la máxima puntuación emite sonido
|
// Si se supera la máxima puntuación emite sonido
|
||||||
if (hi_score_achieved_ == false)
|
if (hi_score_achieved_ == false)
|
||||||
@@ -1224,6 +1226,7 @@ void Game::addScoreToScoreBoard(const std::string &name, int score)
|
|||||||
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);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@@ -1486,7 +1489,7 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
|||||||
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->getRecordNamePos() == 7)
|
if (player->getRecordNamePos() == NAME_LENGHT - 1)
|
||||||
{
|
{
|
||||||
player->setInput(InputType::START);
|
player->setInput(InputType::START);
|
||||||
addScoreToScoreBoard(player->getRecordName(), player->getScore());
|
addScoreToScoreBoard(player->getRecordName(), player->getScore());
|
||||||
@@ -1510,12 +1513,6 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player)
|
|||||||
{
|
{
|
||||||
player->setInput(InputType::LEFT);
|
player->setInput(InputType::LEFT);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
else if (input_->checkInput(InputType::RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].device_type, options.controller[controllerIndex].index))
|
|
||||||
{
|
|
||||||
player->setInput(InputType::RIGHT);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
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);
|
||||||
|
|||||||
@@ -12,16 +12,18 @@ void ManageHiScoreTable::clear()
|
|||||||
table_.clear();
|
table_.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("Usufondo", 500000));
|
table_.push_back(HiScoreEntry("USUFON", 500000));
|
||||||
table_.push_back(HiScoreEntry("G.Lucas", 100000));
|
table_.push_back(HiScoreEntry("GLUCAS", 100000));
|
||||||
table_.push_back(HiScoreEntry("P.Delgat", 50000));
|
table_.push_back(HiScoreEntry("PDLGAT", 50000));
|
||||||
table_.push_back(HiScoreEntry("P.Arrabalera", 10000));
|
table_.push_back(HiScoreEntry("PARRAB", 10000));
|
||||||
table_.push_back(HiScoreEntry("Pelechano", 5000));
|
table_.push_back(HiScoreEntry("PELECH", 5000));
|
||||||
table_.push_back(HiScoreEntry("Sahuquillo", 1000));
|
table_.push_back(HiScoreEntry("SAHUQU", 1000));
|
||||||
table_.push_back(HiScoreEntry("Bacteriol", 500));
|
table_.push_back(HiScoreEntry("BACTER", 500));
|
||||||
table_.push_back(HiScoreEntry("Pepe", 200));
|
table_.push_back(HiScoreEntry("PEPE", 200));
|
||||||
table_.push_back(HiScoreEntry("Rosita", 100));
|
table_.push_back(HiScoreEntry("ROSITA", 100));
|
||||||
|
|
||||||
|
sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Añade un elemento a la tabla
|
// Añade un elemento a la tabla
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ Player::Player(int id, float x, int y, bool demo, SDL_Rect &play_area, std::vect
|
|||||||
power_sprite_->setPosY(y - (power_sprite_->getHeight() - player_sprite_->getHeight()));
|
power_sprite_->setPosY(y - (power_sprite_->getHeight() - player_sprite_->getHeight()));
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
setRecordName(enter_name_->getName());
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,9 +54,10 @@ void Player::init()
|
|||||||
shiftColliders();
|
shiftColliders();
|
||||||
vel_x_ = 0;
|
vel_x_ = 0;
|
||||||
vel_y_ = 0;
|
vel_y_ = 0;
|
||||||
score_ = 0;
|
score_ = 999999;
|
||||||
score_multiplier_ = 1.0f;
|
score_multiplier_ = 1.0f;
|
||||||
cooldown_ = 10;
|
cooldown_ = 10;
|
||||||
|
enter_name_->init();
|
||||||
|
|
||||||
// Establece la posición del sprite
|
// Establece la posición del sprite
|
||||||
player_sprite_->clear();
|
player_sprite_->clear();
|
||||||
@@ -147,12 +147,10 @@ void Player::setInputEnteringName(InputType input)
|
|||||||
enter_name_->decIndex();
|
enter_name_->decIndex();
|
||||||
break;
|
break;
|
||||||
case InputType::START:
|
case InputType::START:
|
||||||
setRecordName(enter_name_->getName());
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setRecordName(enter_name_->getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mueve el jugador a la posición y animación que le corresponde
|
// Mueve el jugador a la posición y animación que le corresponde
|
||||||
@@ -344,7 +342,7 @@ void Player::updateScoreboard()
|
|||||||
case PlayerState::ENTERING_NAME:
|
case PlayerState::ENTERING_NAME:
|
||||||
case PlayerState::ENTERING_NAME_GAME_COMPLETED:
|
case PlayerState::ENTERING_NAME_GAME_COMPLETED:
|
||||||
{
|
{
|
||||||
Scoreboard::get()->setRecordName(getScoreBoardPanel(), getRecordName());
|
Scoreboard::get()->setRecordName(getScoreBoardPanel(), enter_name_->getName());
|
||||||
Scoreboard::get()->setSelectorPos(getScoreBoardPanel(), getRecordNamePos());
|
Scoreboard::get()->setSelectorPos(getScoreBoardPanel(), getRecordNamePos());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -381,7 +379,6 @@ void Player::setPlayingState(PlayerState state)
|
|||||||
// Inicializa el contador de continuar
|
// Inicializa el contador de continuar
|
||||||
continue_ticks_ = SDL_GetTicks();
|
continue_ticks_ = SDL_GetTicks();
|
||||||
continue_counter_ = 9;
|
continue_counter_ = 9;
|
||||||
enter_name_->init();
|
|
||||||
setScoreboardMode(ScoreboardMode::CONTINUE);
|
setScoreboardMode(ScoreboardMode::CONTINUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -598,49 +595,3 @@ void Player::shiftSprite()
|
|||||||
player_sprite_->setPosY(pos_y_);
|
player_sprite_->setPosY(pos_y_);
|
||||||
power_sprite_->setPosX(getPosX() - power_up_desp_x_);
|
power_sprite_->setPosX(getPosX() - power_up_desp_x_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::getScore() const { return score_; }
|
|
||||||
void Player::setScore(int score) { score_ = score; }
|
|
||||||
PlayerState Player::getPlayingState() const { return playing_state_; }
|
|
||||||
float Player::getScoreMultiplier() const { return score_multiplier_; }
|
|
||||||
void Player::setScoreMultiplier(float value) { score_multiplier_ = value; }
|
|
||||||
bool Player::isInvulnerable() const { return invulnerable_; }
|
|
||||||
int Player::getInvulnerableCounter() const { return invulnerable_counter_; }
|
|
||||||
void Player::setInvulnerableCounter(int value) { invulnerable_counter_ = value; }
|
|
||||||
bool Player::isPowerUp() const { return power_up_; }
|
|
||||||
int Player::getPowerUpCounter() const { return power_up_counter_; }
|
|
||||||
void Player::setPowerUpCounter(int value) { power_up_counter_ = value; }
|
|
||||||
bool Player::hasExtraHit() const { return extra_hit_; }
|
|
||||||
void Player::setScoreBoardPanel(int panel) { scoreboard_panel_ = panel; }
|
|
||||||
int Player::getScoreBoardPanel() const { return scoreboard_panel_; }
|
|
||||||
int Player::getCoffees() const { return coffees_; }
|
|
||||||
Circle &Player::getCollider() { return collider_; }
|
|
||||||
int Player::getContinueCounter() const { return continue_counter_; }
|
|
||||||
void Player::setName(const std::string &name) { name_ = name; }
|
|
||||||
void Player::setRecordName(const std::string &record_name) { record_name_ = record_name.substr(0, 8); }
|
|
||||||
std::string Player::getName() const { return name_; }
|
|
||||||
std::string Player::getRecordName() const { return record_name_; }
|
|
||||||
void Player::setController(int index) { controller_index_ = index; }
|
|
||||||
int Player::getController() const { return controller_index_; }
|
|
||||||
int Player::getId() const { return id_; }
|
|
||||||
bool Player::isRenderable() const { return isPlaying() || isDying() || isCelebrating() || isEnteringNameGameCompleted() || isGameCompleted(); }
|
|
||||||
bool Player::IsEligibleForHighScore() { return score_ > options.game.hi_score_table.back().score; }
|
|
||||||
bool Player::isCooling() { return firing_state_ == PlayerState::COOLING_LEFT || firing_state_ == PlayerState::COOLING_UP || firing_state_ == PlayerState::COOLING_RIGHT; }
|
|
||||||
int Player::getPosX() const { return static_cast<int>(pos_x_); }
|
|
||||||
int Player::getPosY() const { return pos_y_; }
|
|
||||||
int Player::getWidth() const { return WIDTH_; }
|
|
||||||
int Player::getHeight() const { return HEIGHT_; }
|
|
||||||
bool Player::canFire() const { return cooldown_ > 0 ? false : true; }
|
|
||||||
void Player::setFireCooldown(int time) { cooldown_ = time; }
|
|
||||||
void Player::setWalkingState(PlayerState state) { walking_state_ = state; }
|
|
||||||
void Player::setFiringState(PlayerState state) { firing_state_ = state; }
|
|
||||||
bool Player::isPlaying() const { return playing_state_ == PlayerState::PLAYING; }
|
|
||||||
bool Player::isContinue() const { return playing_state_ == PlayerState::CONTINUE; }
|
|
||||||
bool Player::isWaiting() const { return playing_state_ == PlayerState::WAITING; }
|
|
||||||
bool Player::isEnteringName() const { return playing_state_ == PlayerState::ENTERING_NAME; }
|
|
||||||
bool Player::isDying() const { return playing_state_ == PlayerState::DYING; }
|
|
||||||
bool Player::hasDied() const { return playing_state_ == PlayerState::DIED; }
|
|
||||||
bool Player::isGameOver() const { return playing_state_ == PlayerState::GAME_OVER; }
|
|
||||||
bool Player::isEnteringNameGameCompleted() const { return playing_state_ == PlayerState::ENTERING_NAME_GAME_COMPLETED; }
|
|
||||||
bool Player::isGameCompleted() const { return playing_state_ == PlayerState::GAME_COMPLETED; }
|
|
||||||
bool Player::isCelebrating() const { return playing_state_ == PlayerState::CELEBRATING; }
|
|
||||||
161
source/player.h
161
source/player.h
@@ -8,6 +8,7 @@
|
|||||||
#include <memory> // Para unique_ptr, shared_ptr
|
#include <memory> // Para unique_ptr, shared_ptr
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
class Texture; // lines 12-12
|
class Texture; // lines 12-12
|
||||||
enum class InputType : int; // lines 13-13
|
enum class InputType : int; // lines 13-13
|
||||||
@@ -85,7 +86,6 @@ private:
|
|||||||
Uint32 continue_ticks_ = 0; // Variable para poder cambiar el contador de continue en función del tiempo
|
Uint32 continue_ticks_ = 0; // Variable para poder cambiar el contador de continue en función del tiempo
|
||||||
int scoreboard_panel_ = 0; // Panel del marcador asociado al jugador
|
int scoreboard_panel_ = 0; // Panel del marcador asociado al jugador
|
||||||
std::string name_; // Nombre del jugador
|
std::string name_; // Nombre del jugador
|
||||||
std::string record_name_; // Nombre del jugador para la tabla de mejores puntuaciones
|
|
||||||
int controller_index_ = 0; // Indice del array de mandos que utilizará para moverse
|
int controller_index_ = 0; // Indice del array de mandos que utilizará para moverse
|
||||||
bool demo_; // Para que el jugador sepa si está en el modo demostración
|
bool demo_; // Para que el jugador sepa si está en el modo demostración
|
||||||
int enter_name_counter_; // Contador para poner nombre
|
int enter_name_counter_; // Contador para poner nombre
|
||||||
@@ -109,17 +109,13 @@ private:
|
|||||||
// Decrementa el contador de entrar nombre
|
// Decrementa el contador de entrar nombre
|
||||||
void decEnterNameCounter();
|
void decEnterNameCounter();
|
||||||
|
|
||||||
// Indica si el jugador se puede dibujar
|
|
||||||
bool isRenderable() const;
|
|
||||||
|
|
||||||
// Actualiza el panel del marcador
|
// Actualiza el panel del marcador
|
||||||
void updateScoreboard();
|
void updateScoreboard();
|
||||||
|
|
||||||
// Cambia el modo del marcador
|
// Cambia el modo del marcador
|
||||||
void setScoreboardMode(ScoreboardMode mode);
|
void setScoreboardMode(ScoreboardMode mode);
|
||||||
|
|
||||||
// Se encuentra en alguno de los estados "COOLING"
|
bool isRenderable() const { return isPlaying() || isDying() || isCelebrating() || isEnteringNameGameCompleted() || isGameCompleted(); }
|
||||||
bool isCooling();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -152,153 +148,86 @@ public:
|
|||||||
// Mueve el jugador a la posición y animación que le corresponde
|
// Mueve el jugador a la posición y animación que le corresponde
|
||||||
void move();
|
void move();
|
||||||
|
|
||||||
// Establece el estado del jugador
|
|
||||||
void setWalkingState(PlayerState state);
|
|
||||||
|
|
||||||
// Establece el estado del jugador
|
|
||||||
void setFiringState(PlayerState state);
|
|
||||||
|
|
||||||
// Establece la animación correspondiente al estado
|
// Establece la animación correspondiente al estado
|
||||||
void setAnimation();
|
void setAnimation();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int getPosX() const;
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int getPosY() const;
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int getWidth() const;
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int getHeight() const;
|
|
||||||
|
|
||||||
// Indica si el jugador puede disparar
|
|
||||||
bool canFire() const;
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setFireCooldown(int time);
|
|
||||||
|
|
||||||
// Actualiza el valor de la variable
|
// Actualiza el valor de la variable
|
||||||
void updateCooldown();
|
void updateCooldown();
|
||||||
|
|
||||||
// Obtiene la puntuación del jugador
|
|
||||||
int getScore() const;
|
|
||||||
|
|
||||||
// Asigna un valor a la puntuación del jugador
|
|
||||||
void setScore(int score);
|
|
||||||
|
|
||||||
// Incrementa la puntuación del jugador
|
// Incrementa la puntuación del jugador
|
||||||
void addScore(int score);
|
void addScore(int score);
|
||||||
|
|
||||||
// Indica si el jugador se encuentra en ese estado
|
|
||||||
bool isPlaying() const;
|
|
||||||
bool isContinue() const;
|
|
||||||
bool isWaiting() const;
|
|
||||||
bool isEnteringName() const;
|
|
||||||
bool isDying() const;
|
|
||||||
bool hasDied() const;
|
|
||||||
bool isGameOver() const;
|
|
||||||
bool isEnteringNameGameCompleted() const;
|
|
||||||
bool isGameCompleted() const;
|
|
||||||
bool isCelebrating() const;
|
|
||||||
|
|
||||||
// Establece el estado del jugador en el juego
|
// Establece el estado del jugador en el juego
|
||||||
void setPlayingState(PlayerState state);
|
void setPlayingState(PlayerState state);
|
||||||
|
|
||||||
// Obtiene el estado del jugador en el juego
|
|
||||||
PlayerState getPlayingState() const;
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
float getScoreMultiplier() const;
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setScoreMultiplier(float value);
|
|
||||||
|
|
||||||
// Aumenta el valor de la variable hasta un máximo
|
// Aumenta el valor de la variable hasta un máximo
|
||||||
void incScoreMultiplier();
|
void incScoreMultiplier();
|
||||||
|
|
||||||
// Decrementa el valor de la variable hasta un mínimo
|
// Decrementa el valor de la variable hasta un mínimo
|
||||||
void decScoreMultiplier();
|
void decScoreMultiplier();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
bool isInvulnerable() const;
|
|
||||||
|
|
||||||
// Establece el valor del estado
|
// Establece el valor del estado
|
||||||
void setInvulnerable(bool value);
|
void setInvulnerable(bool value);
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int getInvulnerableCounter() const;
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setInvulnerableCounter(int value);
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
bool isPowerUp() const;
|
|
||||||
|
|
||||||
// Establece el valor de la variable a verdadero
|
// Establece el valor de la variable a verdadero
|
||||||
void setPowerUp();
|
void setPowerUp();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int getPowerUpCounter() const;
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setPowerUpCounter(int value);
|
|
||||||
|
|
||||||
// Actualiza el valor de la variable
|
// Actualiza el valor de la variable
|
||||||
void updatePowerUp();
|
void updatePowerUp();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
bool hasExtraHit() const;
|
|
||||||
|
|
||||||
// Concede un toque extra al jugador
|
// Concede un toque extra al jugador
|
||||||
void giveExtraHit();
|
void giveExtraHit();
|
||||||
|
|
||||||
// Quita el toque extra al jugador
|
// Quita el toque extra al jugador
|
||||||
void removeExtraHit();
|
void removeExtraHit();
|
||||||
|
|
||||||
// Devuelve el número de cafes actuales
|
|
||||||
int getCoffees() const;
|
|
||||||
|
|
||||||
// Obtiene el circulo de colisión
|
|
||||||
Circle &getCollider();
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int getContinueCounter() const;
|
|
||||||
|
|
||||||
// Le asigna un panel en el marcador al jugador
|
|
||||||
void setScoreBoardPanel(int panel);
|
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
|
||||||
int getScoreBoardPanel() const;
|
|
||||||
|
|
||||||
// Decrementa el contador de continuar
|
// Decrementa el contador de continuar
|
||||||
void decContinueCounter();
|
void decContinueCounter();
|
||||||
|
|
||||||
// Establece el nombre del jugador
|
|
||||||
void setName(const std::string &name);
|
|
||||||
|
|
||||||
// Establece el nombre del jugador para la tabla de mejores puntuaciones
|
|
||||||
void setRecordName(const std::string &record_name);
|
|
||||||
|
|
||||||
// Obtiene el nombre del jugador
|
|
||||||
std::string getName() const;
|
|
||||||
|
|
||||||
// Obtiene el nombre del jugador para la tabla de mejores puntuaciones
|
|
||||||
std::string getRecordName() const;
|
|
||||||
|
|
||||||
// Obtiene la posición que se está editando del nombre del jugador para la tabla de mejores puntuaciones
|
// Obtiene la posición que se está editando del nombre del jugador para la tabla de mejores puntuaciones
|
||||||
int getRecordNamePos() const;
|
int getRecordNamePos() const;
|
||||||
|
|
||||||
// Establece el mando que usará para ser controlado
|
bool canFire() const { return cooldown_ > 0 ? false : true; }
|
||||||
void setController(int index);
|
bool hasDied() const { return playing_state_ == PlayerState::DIED; }
|
||||||
|
bool hasExtraHit() const { return extra_hit_; }
|
||||||
// Obtiene el mando que usa para ser controlado
|
bool isCelebrating() const { return playing_state_ == PlayerState::CELEBRATING; }
|
||||||
int getController() const;
|
bool isContinue() const { return playing_state_ == PlayerState::CONTINUE; }
|
||||||
|
bool isCooling() { return firing_state_ == PlayerState::COOLING_LEFT || firing_state_ == PlayerState::COOLING_UP || firing_state_ == PlayerState::COOLING_RIGHT; }
|
||||||
// Obtiene el "id" del jugador
|
bool isDying() const { return playing_state_ == PlayerState::DYING; }
|
||||||
int getId() const;
|
bool IsEligibleForHighScore() { return score_ > options.game.hi_score_table.back().score; }
|
||||||
|
bool isEnteringName() const { return playing_state_ == PlayerState::ENTERING_NAME; }
|
||||||
// Comprueba si la puntuación entra en la tabla de mejores puntuaciones
|
bool isEnteringNameGameCompleted() const { return playing_state_ == PlayerState::ENTERING_NAME_GAME_COMPLETED; }
|
||||||
bool IsEligibleForHighScore();
|
bool isGameCompleted() const { return playing_state_ == PlayerState::GAME_COMPLETED; }
|
||||||
|
bool isGameOver() const { return playing_state_ == PlayerState::GAME_OVER; }
|
||||||
|
bool isInvulnerable() const { return invulnerable_; }
|
||||||
|
bool isPlaying() const { return playing_state_ == PlayerState::PLAYING; }
|
||||||
|
bool isPowerUp() const { return power_up_; }
|
||||||
|
bool isWaiting() const { return playing_state_ == PlayerState::WAITING; }
|
||||||
|
Circle &getCollider() { return collider_; }
|
||||||
|
float getScoreMultiplier() const { return score_multiplier_; }
|
||||||
|
int getCoffees() const { return coffees_; }
|
||||||
|
int getContinueCounter() const { return continue_counter_; }
|
||||||
|
int getController() const { return controller_index_; }
|
||||||
|
int getHeight() const { return HEIGHT_; }
|
||||||
|
int getId() const { return id_; }
|
||||||
|
int getInvulnerableCounter() const { return invulnerable_counter_; }
|
||||||
|
int getPosX() const { return static_cast<int>(pos_x_); }
|
||||||
|
int getPosY() const { return pos_y_; }
|
||||||
|
int getPowerUpCounter() const { return power_up_counter_; }
|
||||||
|
std::string getRecordName() const { return enter_name_->getName(); }
|
||||||
|
int getScore() const { return score_; }
|
||||||
|
int getScoreBoardPanel() const { return scoreboard_panel_; }
|
||||||
|
int getWidth() const { return WIDTH_; }
|
||||||
|
PlayerState getPlayingState() const { return playing_state_; }
|
||||||
|
std::string getName() const { return name_; }
|
||||||
|
void setController(int index) { controller_index_ = index; }
|
||||||
|
void setFireCooldown(int time) { cooldown_ = time; }
|
||||||
|
void setFiringState(PlayerState state) { firing_state_ = state; }
|
||||||
|
void setInvulnerableCounter(int value) { invulnerable_counter_ = value; }
|
||||||
|
void setName(const std::string &name) { name_ = name; }
|
||||||
|
void setPowerUpCounter(int value) { power_up_counter_ = value; }
|
||||||
|
void setScore(int score) { score_ = score; }
|
||||||
|
void setScoreBoardPanel(int panel) { scoreboard_panel_ = panel; }
|
||||||
|
void setScoreMultiplier(float value) { score_multiplier_ = value; }
|
||||||
|
void setWalkingState(PlayerState state) { walking_state_ = state; }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "screen.h" // Para Screen
|
#include "screen.h" // Para Screen
|
||||||
#include "sprite.h" // Para Sprite
|
#include "sprite.h" // Para Sprite
|
||||||
#include "text.h" // Para Text
|
#include "text.h" // Para Text
|
||||||
|
#include "enter_name.h"
|
||||||
|
|
||||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||||
Scoreboard *Scoreboard::scoreboard_ = nullptr;
|
Scoreboard *Scoreboard::scoreboard_ = nullptr;
|
||||||
@@ -118,17 +119,6 @@ void Scoreboard::render()
|
|||||||
SDL_RenderCopy(renderer_, background_, nullptr, &rect_);
|
SDL_RenderCopy(renderer_, background_, nullptr, &rect_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scoreboard::setName(int panel, const std::string &name) { name_[panel] = name; }
|
|
||||||
void Scoreboard::setRecordName(int panel, const std::string &record_name) { record_name_[panel] = record_name; }
|
|
||||||
void Scoreboard::setSelectorPos(int panel, int pos) { selector_pos_[panel] = pos; }
|
|
||||||
void Scoreboard::setScore(int panel, int score) { score_[panel] = score; }
|
|
||||||
void Scoreboard::setMult(int panel, float mult) { mult_[panel] = mult; }
|
|
||||||
void Scoreboard::setContinue(int panel, int continue_counter) { continue_counter_[panel] = continue_counter; }
|
|
||||||
void Scoreboard::setStage(int stage) { stage_ = stage; }
|
|
||||||
void Scoreboard::setHiScore(int hi_score) { hi_score_ = hi_score; }
|
|
||||||
void Scoreboard::setPower(float power) { power_ = power; }
|
|
||||||
void Scoreboard::setHiScoreName(const std::string &name) { hi_score_name_ = name; }
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Scoreboard::setColor(Color color)
|
void Scoreboard::setColor(Color color)
|
||||||
{
|
{
|
||||||
@@ -180,7 +170,7 @@ void Scoreboard::fillPanelTextures()
|
|||||||
|
|
||||||
// MULT
|
// MULT
|
||||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(55));
|
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(55));
|
||||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, std::to_string(mult_[i]).substr(0, 3));
|
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, "x" + std::to_string(mult_[i]).substr(0, 3));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +229,8 @@ void Scoreboard::fillPanelTextures()
|
|||||||
|
|
||||||
// HI-SCORE
|
// HI-SCORE
|
||||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(56));
|
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(56));
|
||||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, hi_score_name_ + " - " + updateScoreText(hi_score_));
|
const std::string name = hi_score_name_ == "" ? "" : hi_score_name_ + " - ";
|
||||||
|
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, name + updateScoreText(hi_score_));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,21 +258,6 @@ void Scoreboard::fillPanelTextures()
|
|||||||
SDL_SetRenderDrawColor(renderer_, 0xFF, 0xFF, 0xEB, 255);
|
SDL_SetRenderDrawColor(renderer_, 0xFF, 0xFF, 0xEB, 255);
|
||||||
for (size_t j = 0; j < record_name_[i].size(); ++j)
|
for (size_t j = 0; j < record_name_[i].size(); ++j)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (j == selector_pos_[i])
|
|
||||||
{ // La letra seleccionada se pinta de forma intermitente
|
|
||||||
if (counter_ % 3 > 0)
|
|
||||||
{
|
|
||||||
SDL_RenderDrawLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
|
|
||||||
text_scoreboard_->write(rect.x, rect.y, record_name_[i].substr(j, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SDL_RenderDrawLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
|
|
||||||
text_scoreboard_->write(rect.x, rect.y, record_name_[i].substr(j, 1));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (j != selector_pos_[i] || counter_ % 3 == 0)
|
if (j != selector_pos_[i] || counter_ % 3 == 0)
|
||||||
{
|
{
|
||||||
SDL_RenderDrawLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
|
SDL_RenderDrawLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
|
||||||
@@ -372,7 +348,7 @@ void Scoreboard::recalculateAnchors()
|
|||||||
slot4_4_ = {col, row4};
|
slot4_4_ = {col, row4};
|
||||||
|
|
||||||
// Primer cuadrado para poner el nombre de record
|
// Primer cuadrado para poner el nombre de record
|
||||||
const int enterNameLenght = 8 * 7;
|
const int enterNameLenght = NAME_LENGHT * 7;
|
||||||
enter_name_pos_.x = (panelWidth - enterNameLenght) / 2;
|
enter_name_pos_.x = (panelWidth - enterNameLenght) / 2;
|
||||||
enter_name_pos_.y = row4;
|
enter_name_pos_.y = row4;
|
||||||
|
|
||||||
@@ -384,9 +360,6 @@ void Scoreboard::recalculateAnchors()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el modo del marcador
|
|
||||||
void Scoreboard::setMode(int index, ScoreboardMode mode) { panel_[index].mode = mode; }
|
|
||||||
|
|
||||||
// Crea la textura de fondo
|
// Crea la textura de fondo
|
||||||
void Scoreboard::createBackgroundTexture()
|
void Scoreboard::createBackgroundTexture()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -126,42 +126,21 @@ public:
|
|||||||
// Pinta el marcador
|
// Pinta el marcador
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setName(int panel, const std::string &name);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setRecordName(int panel, const std::string &record_name);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setSelectorPos(int panel, int pos);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setScore(int panel, int score);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setMult(int panel, float mult);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setContinue(int panel, int score);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setStage(int stage);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setHiScore(int hi_score);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setPower(float power);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setHiScoreName(const std::string &name);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setColor(Color color);
|
void setColor(Color color);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setPos(SDL_Rect rect);
|
void setPos(SDL_Rect rect);
|
||||||
|
|
||||||
// Establece el modo del marcador
|
void setContinue(int panel, int continue_counter) { continue_counter_[panel] = continue_counter; }
|
||||||
void setMode(int index, ScoreboardMode mode);
|
void setHiScore(int hi_score) { hi_score_ = hi_score; }
|
||||||
|
void setHiScoreName(const std::string &name) { hi_score_name_ = name; }
|
||||||
|
void setMode(int index, ScoreboardMode mode) { panel_[index].mode = mode; }
|
||||||
|
void setMult(int panel, float mult) { mult_[panel] = mult; }
|
||||||
|
void setName(int panel, const std::string &name) { name_[panel] = name; }
|
||||||
|
void setPower(float power) { power_ = power; }
|
||||||
|
void setRecordName(int panel, const std::string &record_name) { record_name_[panel] = record_name; }
|
||||||
|
void setScore(int panel, int score) { score_[panel] = score; }
|
||||||
|
void setSelectorPos(int panel, int pos) { selector_pos_[panel] = pos; }
|
||||||
|
void setStage(int stage) { stage_ = stage; }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user