Abans de renombrar game.cpp
This commit is contained in:
@@ -11,32 +11,32 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(int id, float x, int y, bool demo, SDL_Rect *playArea, std::vector<std::shared_ptr<Texture>> texture, std::vector<std::vector<std::string> *> animations)
|
Player::Player(int id, float x, int y, bool demo, SDL_Rect *play_area, std::vector<std::shared_ptr<Texture>> texture, std::vector<std::vector<std::string> *> animations)
|
||||||
{
|
{
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
playerSprite = std::make_unique<AnimatedSprite>(texture[0], "", animations[0]);
|
player_sprite_ = std::make_unique<AnimatedSprite>(texture[0], "", animations[0]);
|
||||||
powerSprite = std::make_unique<AnimatedSprite>(texture[1], "", animations[1]);
|
power_sprite_ = std::make_unique<AnimatedSprite>(texture[1], "", animations[1]);
|
||||||
powerSprite->getTexture()->setAlpha(224);
|
power_sprite_->getTexture()->setAlpha(224);
|
||||||
enterName = std::make_unique<EnterName>();
|
enter_name_ = std::make_unique<EnterName>();
|
||||||
|
|
||||||
// Rectangulo con la zona de juego
|
// Rectangulo con la zona de juego
|
||||||
this->playArea = playArea;
|
play_area_ = play_area;
|
||||||
|
|
||||||
// Establece la posición inicial del jugador
|
// Establece la posición inicial del jugador
|
||||||
defaultPosX = posX = x;
|
default_pos_x_ = pos_x_ = x;
|
||||||
defaultPosY = posY = y;
|
default_pos_y_ = pos_y_ = y;
|
||||||
|
|
||||||
// Establece los offsets para el sprite de PowerUp
|
// Establece los offsets para el sprite de PowerUp
|
||||||
powerUpDespX = (powerSprite->getWidth() - playerSprite->getWidth()) / 2;
|
power_up_desp_x_ = (power_sprite_->getWidth() - player_sprite_->getWidth()) / 2;
|
||||||
powerSprite->setPosY(y - (powerSprite->getHeight() - playerSprite->getHeight()));
|
power_sprite_->setPosY(y - (power_sprite_->getHeight() - player_sprite_->getHeight()));
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
this->id = id;
|
id_ = id;
|
||||||
this->demo = demo;
|
demo_ = demo;
|
||||||
statusPlaying = PlayerStatus::WAITING;
|
status_playing_ = PlayerStatus::WAITING;
|
||||||
scoreBoardPanel = 0;
|
scoreboard_panel_ = 0;
|
||||||
name = "";
|
name_ = "";
|
||||||
setRecordName(enterName->getName());
|
setRecordName(enter_name_->getName());
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,50 +44,54 @@ Player::Player(int id, float x, int y, bool demo, SDL_Rect *playArea, std::vecto
|
|||||||
void Player::init()
|
void Player::init()
|
||||||
{
|
{
|
||||||
// Inicializa variables de estado
|
// Inicializa variables de estado
|
||||||
posX = defaultPosX;
|
pos_x_ = default_pos_x_;
|
||||||
posY = defaultPosY;
|
pos_y_ = default_pos_y_;
|
||||||
statusWalking = PlayerStatus::WALKING_STOP;
|
status_walking_ = PlayerStatus::WALKING_STOP;
|
||||||
statusFiring = PlayerStatus::FIRING_NO;
|
status_firing_ = PlayerStatus::FIRING_NO;
|
||||||
invulnerable = true;
|
invulnerable_ = true;
|
||||||
invulnerableCounter = PLAYER_INVULNERABLE_COUNTER;
|
invulnerable_counter_ = PLAYER_INVULNERABLE_COUNTER;
|
||||||
powerUp = false;
|
power_up_ = false;
|
||||||
powerUpCounter = PLAYER_POWERUP_COUNTER;
|
power_up_counter_ = PLAYER_POWERUP_COUNTER;
|
||||||
extraHit = false;
|
extra_hit_ = false;
|
||||||
coffees = 0;
|
coffees_ = 0;
|
||||||
input = true;
|
input_ = true;
|
||||||
continueTicks = 0;
|
continue_ticks_ = 0;
|
||||||
continueCounter = 20;
|
continue_counter_ = 20;
|
||||||
width = 30;
|
width_ = 30;
|
||||||
height = 30;
|
height_ = 30;
|
||||||
collider.r = 9;
|
collider_.r = 9;
|
||||||
shiftColliders();
|
shiftColliders();
|
||||||
velX = 0;
|
vel_x_ = 0;
|
||||||
velY = 0;
|
vel_y_ = 0;
|
||||||
baseSpeed = 1.5;
|
base_speed_ = 1.5;
|
||||||
score = 0;
|
score_ = 0;
|
||||||
scoreMultiplier = 1.0f;
|
score_multiplier_ = 1.0f;
|
||||||
cooldown = 10;
|
cooldown_ = 10;
|
||||||
|
|
||||||
// Establece la posición del sprite
|
// Establece la posición del sprite
|
||||||
playerSprite->setPosX(posX);
|
player_sprite_->setPosX(pos_x_);
|
||||||
playerSprite->setPosY(posY);
|
player_sprite_->setPosY(pos_y_);
|
||||||
|
|
||||||
// Selecciona un frame para pintar
|
// Selecciona un frame para pintar
|
||||||
playerSprite->setCurrentAnimation("stand");
|
player_sprite_->setCurrentAnimation("stand");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actua en consecuencia de la entrada recibida
|
// Actua en consecuencia de la entrada recibida
|
||||||
void Player::setInput(int input)
|
void Player::setInput(int input)
|
||||||
{
|
{
|
||||||
switch (statusPlaying)
|
switch (status_playing_)
|
||||||
{
|
{
|
||||||
case PlayerStatus::PLAYING:
|
case PlayerStatus::PLAYING:
|
||||||
|
{
|
||||||
setInputPlaying(input);
|
setInputPlaying(input);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case PlayerStatus::ENTERING_NAME:
|
case PlayerStatus::ENTERING_NAME:
|
||||||
|
{
|
||||||
setInputEnteringName(input);
|
setInputEnteringName(input);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -100,32 +104,44 @@ void Player::setInputPlaying(int input)
|
|||||||
switch (input)
|
switch (input)
|
||||||
{
|
{
|
||||||
case input_left:
|
case input_left:
|
||||||
velX = -baseSpeed;
|
{
|
||||||
|
vel_x_ = -base_speed_;
|
||||||
setWalkingStatus(PlayerStatus::WALKING_LEFT);
|
setWalkingStatus(PlayerStatus::WALKING_LEFT);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case input_right:
|
case input_right:
|
||||||
velX = baseSpeed;
|
{
|
||||||
|
vel_x_ = base_speed_;
|
||||||
setWalkingStatus(PlayerStatus::WALKING_RIGHT);
|
setWalkingStatus(PlayerStatus::WALKING_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case input_fire_center:
|
case input_fire_center:
|
||||||
|
{
|
||||||
setFiringStatus(PlayerStatus::FIRING_UP);
|
setFiringStatus(PlayerStatus::FIRING_UP);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case input_fire_left:
|
case input_fire_left:
|
||||||
|
{
|
||||||
setFiringStatus(PlayerStatus::FIRING_LEFT);
|
setFiringStatus(PlayerStatus::FIRING_LEFT);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case input_fire_right:
|
case input_fire_right:
|
||||||
|
{
|
||||||
setFiringStatus(PlayerStatus::FIRING_RIGHT);
|
setFiringStatus(PlayerStatus::FIRING_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
velX = 0;
|
{
|
||||||
|
vel_x_ = 0;
|
||||||
setWalkingStatus(PlayerStatus::WALKING_STOP);
|
setWalkingStatus(PlayerStatus::WALKING_STOP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Procesa inputs para cuando está introduciendo el nombre
|
// Procesa inputs para cuando está introduciendo el nombre
|
||||||
@@ -134,29 +150,29 @@ void Player::setInputEnteringName(int input)
|
|||||||
switch (input)
|
switch (input)
|
||||||
{
|
{
|
||||||
case input_left:
|
case input_left:
|
||||||
enterName->decPos();
|
enter_name_->decPos();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case input_right:
|
case input_right:
|
||||||
enterName->incPos();
|
enter_name_->incPos();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case input_up:
|
case input_up:
|
||||||
enterName->incIndex();
|
enter_name_->incIndex();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case input_down:
|
case input_down:
|
||||||
enterName->decIndex();
|
enter_name_->decIndex();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case input_start:
|
case input_start:
|
||||||
setRecordName(enterName->getName());
|
setRecordName(enter_name_->getName());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setRecordName(enterName->getName());
|
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
|
||||||
@@ -165,38 +181,38 @@ void Player::move()
|
|||||||
if (isPlaying())
|
if (isPlaying())
|
||||||
{
|
{
|
||||||
// Mueve el jugador a derecha o izquierda
|
// Mueve el jugador a derecha o izquierda
|
||||||
posX += velX;
|
pos_x_ += vel_x_;
|
||||||
|
|
||||||
// Si el jugador abandona el area de juego por los laterales
|
// Si el jugador abandona el area de juego por los laterales
|
||||||
if ((posX < param.game.play_area.rect.x - 5) || (posX + width > playArea->w + 5))
|
if ((pos_x_ < param.game.play_area.rect.x - 5) || (pos_x_ + width_ > play_area_->w + 5))
|
||||||
{
|
{
|
||||||
// Restaura su posición
|
// Restaura su posición
|
||||||
posX -= velX;
|
pos_x_ -= vel_x_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza la posición del sprite
|
// Actualiza la posición del sprite
|
||||||
playerSprite->setPosX(getPosX());
|
player_sprite_->setPosX(getPosX());
|
||||||
playerSprite->setPosY(posY);
|
player_sprite_->setPosY(pos_y_);
|
||||||
|
|
||||||
powerSprite->setPosX(getPosX() - powerUpDespX);
|
power_sprite_->setPosX(getPosX() - power_up_desp_x_);
|
||||||
}
|
}
|
||||||
else if (isDying())
|
else if (isDying())
|
||||||
{
|
{
|
||||||
playerSprite->update();
|
player_sprite_->update();
|
||||||
|
|
||||||
// Si el cadaver abandona el area de juego por los laterales
|
// Si el cadaver abandona el area de juego por los laterales
|
||||||
if ((playerSprite->getPosX() < param.game.play_area.rect.x) || (playerSprite->getPosX() + width > playArea->w))
|
if ((player_sprite_->getPosX() < param.game.play_area.rect.x) || (player_sprite_->getPosX() + width_ > play_area_->w))
|
||||||
{
|
{
|
||||||
// Restaura su posición
|
// Restaura su posición
|
||||||
const float vx = playerSprite->getVelX();
|
const float vx = player_sprite_->getVelX();
|
||||||
playerSprite->setPosX(playerSprite->getPosX() - vx);
|
player_sprite_->setPosX(player_sprite_->getPosX() - vx);
|
||||||
|
|
||||||
// Rebota
|
// Rebota
|
||||||
playerSprite->setVelX(-vx);
|
player_sprite_->setVelX(-vx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si el cadaver abandona el area de juego por abajo
|
// Si el cadaver abandona el area de juego por abajo
|
||||||
if (playerSprite->getPosY() > param.game.play_area.rect.h)
|
if (player_sprite_->getPosY() > param.game.play_area.rect.h)
|
||||||
{
|
{
|
||||||
setStatusPlaying(PlayerStatus::DIED);
|
setStatusPlaying(PlayerStatus::DIED);
|
||||||
}
|
}
|
||||||
@@ -206,25 +222,25 @@ void Player::move()
|
|||||||
// Pinta el jugador en pantalla
|
// Pinta el jugador en pantalla
|
||||||
void Player::render()
|
void Player::render()
|
||||||
{
|
{
|
||||||
if (powerUp && isPlaying())
|
if (power_up_ && isPlaying())
|
||||||
{
|
{
|
||||||
if (powerUpCounter > (PLAYER_POWERUP_COUNTER / 4) || powerUpCounter % 20 > 4)
|
if (power_up_counter_ > (PLAYER_POWERUP_COUNTER / 4) || power_up_counter_ % 20 > 4)
|
||||||
{
|
{
|
||||||
powerSprite->render();
|
power_sprite_->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRenderable())
|
if (isRenderable())
|
||||||
playerSprite->render();
|
player_sprite_->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado del jugador cuando camina
|
// Establece el estado del jugador cuando camina
|
||||||
void Player::setWalkingStatus(PlayerStatus status)
|
void Player::setWalkingStatus(PlayerStatus status)
|
||||||
{
|
{
|
||||||
// Si cambiamos de estado, reiniciamos la animación
|
// Si cambiamos de estado, reiniciamos la animación
|
||||||
if (statusWalking != status)
|
if (status_walking_ != status)
|
||||||
{
|
{
|
||||||
statusWalking = status;
|
status_walking_ = status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,9 +248,9 @@ void Player::setWalkingStatus(PlayerStatus status)
|
|||||||
void Player::setFiringStatus(PlayerStatus status)
|
void Player::setFiringStatus(PlayerStatus status)
|
||||||
{
|
{
|
||||||
// Si cambiamos de estado, reiniciamos la animación
|
// Si cambiamos de estado, reiniciamos la animación
|
||||||
if (statusFiring != status)
|
if (status_firing_ != status)
|
||||||
{
|
{
|
||||||
statusFiring = status;
|
status_firing_ = status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,86 +258,86 @@ void Player::setFiringStatus(PlayerStatus status)
|
|||||||
void Player::setAnimation()
|
void Player::setAnimation()
|
||||||
{
|
{
|
||||||
// Crea cadenas de texto para componer el nombre de la animación
|
// Crea cadenas de texto para componer el nombre de la animación
|
||||||
const std::string aWalking = statusWalking == PlayerStatus::WALKING_STOP ? "stand" : "walk";
|
const std::string a_walking = status_walking_ == PlayerStatus::WALKING_STOP ? "stand" : "walk";
|
||||||
const std::string aFiring = statusFiring == PlayerStatus::FIRING_UP ? "centershoot" : "sideshoot";
|
const std::string a_firing = status_firing_ == PlayerStatus::FIRING_UP ? "centershoot" : "sideshoot";
|
||||||
|
|
||||||
const SDL_RendererFlip flipWalk = statusWalking == PlayerStatus::WALKING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
const SDL_RendererFlip flip_walk = status_walking_ == PlayerStatus::WALKING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||||
const SDL_RendererFlip flipFire = statusFiring == PlayerStatus::FIRING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
const SDL_RendererFlip flip_fire = status_firing_ == PlayerStatus::FIRING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE;
|
||||||
|
|
||||||
// Establece la animación a partir de las cadenas
|
// Establece la animación a partir de las cadenas
|
||||||
if (isPlaying())
|
if (isPlaying())
|
||||||
{
|
{
|
||||||
if (statusFiring == PlayerStatus::FIRING_NO)
|
if (status_firing_ == PlayerStatus::FIRING_NO)
|
||||||
{ // No esta disparando
|
{ // No esta disparando
|
||||||
playerSprite->setCurrentAnimation(aWalking);
|
player_sprite_->setCurrentAnimation(a_walking);
|
||||||
playerSprite->setFlip(flipWalk);
|
player_sprite_->setFlip(flip_walk);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Está disparando
|
{ // Está disparando
|
||||||
playerSprite->setCurrentAnimation(aWalking + "-" + aFiring);
|
player_sprite_->setCurrentAnimation(a_walking + "-" + a_firing);
|
||||||
// Si dispara de lado, invierte el sprite segun hacia donde dispara
|
// Si dispara de lado, invierte el sprite segun hacia donde dispara
|
||||||
// Si dispara recto, invierte el sprite segun hacia donde camina
|
// Si dispara recto, invierte el sprite segun hacia donde camina
|
||||||
aFiring == "centershoot" ? playerSprite->setFlip(flipWalk) : playerSprite->setFlip(flipFire);
|
a_firing == "centershoot" ? player_sprite_->setFlip(flip_walk) : player_sprite_->setFlip(flip_fire);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playerSprite->setCurrentAnimation("death");
|
player_sprite_->setCurrentAnimation("death");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las animaciones de los sprites
|
// Actualiza las animaciones de los sprites
|
||||||
playerSprite->animate();
|
player_sprite_->animate();
|
||||||
|
|
||||||
// powerSprite->setFlip(flipWalk);
|
// powerSprite->setFlip(flip_walk);
|
||||||
powerSprite->animate();
|
power_sprite_->animate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getPosX() const
|
int Player::getPosX() const
|
||||||
{
|
{
|
||||||
return int(posX);
|
return int(pos_x_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getPosY() const
|
int Player::getPosY() const
|
||||||
{
|
{
|
||||||
return posY;
|
return pos_y_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getWidth() const
|
int Player::getWidth() const
|
||||||
{
|
{
|
||||||
return width;
|
return width_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getHeight() const
|
int Player::getHeight() const
|
||||||
{
|
{
|
||||||
return height;
|
return height_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador puede disparar
|
// Indica si el jugador puede disparar
|
||||||
bool Player::canFire() const
|
bool Player::canFire() const
|
||||||
{
|
{
|
||||||
// Si el contador a llegado a cero, podemos disparar. En caso contrario decrementamos el contador
|
// Si el contador a llegado a cero, podemos disparar. En caso contrario decrementamos el contador
|
||||||
return cooldown > 0 ? false : true;
|
return cooldown_ > 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Player::setFireCooldown(int time)
|
void Player::setFireCooldown(int time)
|
||||||
{
|
{
|
||||||
cooldown = time;
|
cooldown_ = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el valor de la variable
|
// Actualiza el valor de la variable
|
||||||
void Player::updateCooldown()
|
void Player::updateCooldown()
|
||||||
{
|
{
|
||||||
if (cooldown > 0)
|
if (cooldown_ > 0)
|
||||||
{
|
{
|
||||||
cooldown--;
|
cooldown_--;
|
||||||
if (powerUp)
|
if (power_up_)
|
||||||
{
|
{
|
||||||
cooldown--;
|
cooldown_--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -346,13 +362,13 @@ void Player::update()
|
|||||||
// Obtiene la puntuación del jugador
|
// Obtiene la puntuación del jugador
|
||||||
int Player::getScore() const
|
int Player::getScore() const
|
||||||
{
|
{
|
||||||
return score;
|
return score_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna un valor a la puntuación del jugador
|
// Asigna un valor a la puntuación del jugador
|
||||||
void Player::setScore(int score)
|
void Player::setScore(int score)
|
||||||
{
|
{
|
||||||
this->score = score;
|
score_ = score;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Incrementa la puntuación del jugador
|
// Incrementa la puntuación del jugador
|
||||||
@@ -360,56 +376,56 @@ void Player::addScore(int score)
|
|||||||
{
|
{
|
||||||
if (isPlaying())
|
if (isPlaying())
|
||||||
{
|
{
|
||||||
this->score += score;
|
score_ += score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador está jugando
|
// Indica si el jugador está jugando
|
||||||
bool Player::isPlaying() const
|
bool Player::isPlaying() const
|
||||||
{
|
{
|
||||||
return statusPlaying == PlayerStatus::PLAYING;
|
return status_playing_ == PlayerStatus::PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador está continuando
|
// Indica si el jugador está continuando
|
||||||
bool Player::isContinue() const
|
bool Player::isContinue() const
|
||||||
{
|
{
|
||||||
return statusPlaying == PlayerStatus::CONTINUE;
|
return status_playing_ == PlayerStatus::CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador está esperando
|
// Indica si el jugador está esperando
|
||||||
bool Player::isWaiting() const
|
bool Player::isWaiting() const
|
||||||
{
|
{
|
||||||
return statusPlaying == PlayerStatus::WAITING;
|
return status_playing_ == PlayerStatus::WAITING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador está introduciendo su nombre
|
// Indica si el jugador está introduciendo su nombre
|
||||||
bool Player::isEnteringName() const
|
bool Player::isEnteringName() const
|
||||||
{
|
{
|
||||||
return statusPlaying == PlayerStatus::ENTERING_NAME;
|
return status_playing_ == PlayerStatus::ENTERING_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador está muriendose
|
// Indica si el jugador está muriendose
|
||||||
bool Player::isDying() const
|
bool Player::isDying() const
|
||||||
{
|
{
|
||||||
return statusPlaying == PlayerStatus::DYING;
|
return status_playing_ == PlayerStatus::DYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador ha terminado de morir
|
// Indica si el jugador ha terminado de morir
|
||||||
bool Player::hasDied() const
|
bool Player::hasDied() const
|
||||||
{
|
{
|
||||||
return statusPlaying == PlayerStatus::DIED;
|
return status_playing_ == PlayerStatus::DIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador ya ha terminado de jugar
|
// Indica si el jugador ya ha terminado de jugar
|
||||||
bool Player::isGameOver() const
|
bool Player::isGameOver() const
|
||||||
{
|
{
|
||||||
return statusPlaying == PlayerStatus::GAME_OVER;
|
return status_playing_ == PlayerStatus::GAME_OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el panel del marcador
|
// Actualiza el panel del marcador
|
||||||
void Player::updateScoreboard()
|
void Player::updateScoreboard()
|
||||||
{
|
{
|
||||||
switch (statusPlaying)
|
switch (status_playing_)
|
||||||
{
|
{
|
||||||
|
|
||||||
case PlayerStatus::CONTINUE:
|
case PlayerStatus::CONTINUE:
|
||||||
@@ -433,7 +449,7 @@ void Player::updateScoreboard()
|
|||||||
// Cambia el modo del marcador
|
// Cambia el modo del marcador
|
||||||
void Player::setScoreboardMode(ScoreboardMode mode)
|
void Player::setScoreboardMode(ScoreboardMode mode)
|
||||||
{
|
{
|
||||||
if (!demo)
|
if (!demo_)
|
||||||
{
|
{
|
||||||
Scoreboard::get()->setMode(getScoreBoardPanel(), mode);
|
Scoreboard::get()->setMode(getScoreBoardPanel(), mode);
|
||||||
}
|
}
|
||||||
@@ -442,13 +458,13 @@ void Player::setScoreboardMode(ScoreboardMode mode)
|
|||||||
// Establece el estado del jugador en el juego
|
// Establece el estado del jugador en el juego
|
||||||
void Player::setStatusPlaying(PlayerStatus value)
|
void Player::setStatusPlaying(PlayerStatus value)
|
||||||
{
|
{
|
||||||
statusPlaying = value;
|
status_playing_ = value;
|
||||||
|
|
||||||
switch (statusPlaying)
|
switch (status_playing_)
|
||||||
{
|
{
|
||||||
case PlayerStatus::PLAYING:
|
case PlayerStatus::PLAYING:
|
||||||
{
|
{
|
||||||
statusPlaying = PlayerStatus::PLAYING;
|
status_playing_ = PlayerStatus::PLAYING;
|
||||||
init();
|
init();
|
||||||
setScoreboardMode(ScoreboardMode::SCORE);
|
setScoreboardMode(ScoreboardMode::SCORE);
|
||||||
break;
|
break;
|
||||||
@@ -457,9 +473,9 @@ void Player::setStatusPlaying(PlayerStatus value)
|
|||||||
case PlayerStatus::CONTINUE:
|
case PlayerStatus::CONTINUE:
|
||||||
{
|
{
|
||||||
// Inicializa el contador de continuar
|
// Inicializa el contador de continuar
|
||||||
continueTicks = SDL_GetTicks();
|
continue_ticks_ = SDL_GetTicks();
|
||||||
continueCounter = 9;
|
continue_counter_ = 9;
|
||||||
enterName->init();
|
enter_name_->init();
|
||||||
setScoreboardMode(ScoreboardMode::CONTINUE);
|
setScoreboardMode(ScoreboardMode::CONTINUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -479,16 +495,16 @@ void Player::setStatusPlaying(PlayerStatus value)
|
|||||||
case PlayerStatus::DYING:
|
case PlayerStatus::DYING:
|
||||||
{
|
{
|
||||||
// Activa la animación de morir
|
// Activa la animación de morir
|
||||||
playerSprite->setAccelY(0.2f);
|
player_sprite_->setAccelY(0.2f);
|
||||||
playerSprite->setVelY(-6.6f);
|
player_sprite_->setVelY(-6.6f);
|
||||||
rand() % 2 == 0 ? playerSprite->setVelX(3.3f) : playerSprite->setVelX(-3.3f);
|
rand() % 2 == 0 ? player_sprite_->setVelX(3.3f) : player_sprite_->setVelX(-3.3f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PlayerStatus::DIED:
|
case PlayerStatus::DIED:
|
||||||
{
|
{
|
||||||
const auto nextPlayerStatus = IsEligibleForHighScore() ? PlayerStatus::ENTERING_NAME : PlayerStatus::CONTINUE;
|
const auto nextPlayerStatus = IsEligibleForHighScore() ? PlayerStatus::ENTERING_NAME : PlayerStatus::CONTINUE;
|
||||||
demo ? setStatusPlaying(PlayerStatus::WAITING) : setStatusPlaying(nextPlayerStatus);
|
demo_ ? setStatusPlaying(PlayerStatus::WAITING) : setStatusPlaying(nextPlayerStatus);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,74 +522,74 @@ void Player::setStatusPlaying(PlayerStatus value)
|
|||||||
// Obtiene el estado del jugador en el juego
|
// Obtiene el estado del jugador en el juego
|
||||||
PlayerStatus Player::getStatusPlaying() const
|
PlayerStatus Player::getStatusPlaying() const
|
||||||
{
|
{
|
||||||
return statusPlaying;
|
return status_playing_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
float Player::getScoreMultiplier() const
|
float Player::getScoreMultiplier() const
|
||||||
{
|
{
|
||||||
return scoreMultiplier;
|
return score_multiplier_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Player::setScoreMultiplier(float value)
|
void Player::setScoreMultiplier(float value)
|
||||||
{
|
{
|
||||||
scoreMultiplier = value;
|
score_multiplier_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aumenta el valor de la variable hasta un máximo
|
// Aumenta el valor de la variable hasta un máximo
|
||||||
void Player::incScoreMultiplier()
|
void Player::incScoreMultiplier()
|
||||||
{
|
{
|
||||||
scoreMultiplier += 0.1f;
|
score_multiplier_ += 0.1f;
|
||||||
scoreMultiplier = std::min(scoreMultiplier, 5.0f);
|
score_multiplier_ = std::min(score_multiplier_, 5.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrementa el valor de la variable hasta un mínimo
|
// Decrementa el valor de la variable hasta un mínimo
|
||||||
void Player::decScoreMultiplier()
|
void Player::decScoreMultiplier()
|
||||||
{
|
{
|
||||||
scoreMultiplier -= 0.1f;
|
score_multiplier_ -= 0.1f;
|
||||||
scoreMultiplier = std::max(scoreMultiplier, 1.0f);
|
score_multiplier_ = std::max(score_multiplier_, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
bool Player::isInvulnerable() const
|
bool Player::isInvulnerable() const
|
||||||
{
|
{
|
||||||
return invulnerable;
|
return invulnerable_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor del estado
|
// Establece el valor del estado
|
||||||
void Player::setInvulnerable(bool value)
|
void Player::setInvulnerable(bool value)
|
||||||
{
|
{
|
||||||
invulnerable = value;
|
invulnerable_ = value;
|
||||||
invulnerableCounter = invulnerable ? PLAYER_INVULNERABLE_COUNTER : 0;
|
invulnerable_counter_ = invulnerable_ ? PLAYER_INVULNERABLE_COUNTER : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getInvulnerableCounter() const
|
int Player::getInvulnerableCounter() const
|
||||||
{
|
{
|
||||||
return invulnerableCounter;
|
return invulnerable_counter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Player::setInvulnerableCounter(int value)
|
void Player::setInvulnerableCounter(int value)
|
||||||
{
|
{
|
||||||
invulnerableCounter = value;
|
invulnerable_counter_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monitoriza el estado
|
// Monitoriza el estado
|
||||||
void Player::updateInvulnerable()
|
void Player::updateInvulnerable()
|
||||||
{
|
{
|
||||||
if (invulnerable)
|
if (invulnerable_)
|
||||||
{
|
{
|
||||||
if (invulnerableCounter > 0)
|
if (invulnerable_counter_ > 0)
|
||||||
{
|
{
|
||||||
invulnerableCounter--;
|
invulnerable_counter_--;
|
||||||
invulnerableCounter % 8 > 3 ? playerSprite->getTexture()->setPalette(coffees) : playerSprite->getTexture()->setPalette(3);
|
invulnerable_counter_ % 8 > 3 ? player_sprite_->getTexture()->setPalette(coffees_) : player_sprite_->getTexture()->setPalette(3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setInvulnerable(false);
|
setInvulnerable(false);
|
||||||
playerSprite->getTexture()->setPalette(coffees);
|
player_sprite_->getTexture()->setPalette(coffees_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -581,124 +597,123 @@ void Player::updateInvulnerable()
|
|||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
bool Player::isPowerUp() const
|
bool Player::isPowerUp() const
|
||||||
{
|
{
|
||||||
return powerUp;
|
return power_up_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Player::setPowerUp()
|
void Player::setPowerUp()
|
||||||
{
|
{
|
||||||
powerUp = true;
|
power_up_ = true;
|
||||||
powerUpCounter = PLAYER_POWERUP_COUNTER;
|
power_up_counter_ = PLAYER_POWERUP_COUNTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getPowerUpCounter() const
|
int Player::getPowerUpCounter() const
|
||||||
{
|
{
|
||||||
return powerUpCounter;
|
return power_up_counter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Player::setPowerUpCounter(int value)
|
void Player::setPowerUpCounter(int value)
|
||||||
{
|
{
|
||||||
powerUpCounter = value;
|
power_up_counter_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el valor de la variable
|
// Actualiza el valor de la variable
|
||||||
void Player::updatePowerUpCounter()
|
void Player::updatePowerUpCounter()
|
||||||
{
|
{
|
||||||
if ((powerUpCounter > 0) && (powerUp))
|
if ((power_up_counter_ > 0) && (power_up_))
|
||||||
{
|
{
|
||||||
powerUpCounter--;
|
power_up_counter_--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
powerUp = false;
|
power_up_ = false;
|
||||||
// powerUpCounter = PLAYER_POWERUP_COUNTER;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
bool Player::hasExtraHit() const
|
bool Player::hasExtraHit() const
|
||||||
{
|
{
|
||||||
return extraHit;
|
return extra_hit_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Concede un toque extra al jugador
|
// Concede un toque extra al jugador
|
||||||
void Player::giveExtraHit()
|
void Player::giveExtraHit()
|
||||||
{
|
{
|
||||||
extraHit = true;
|
extra_hit_ = true;
|
||||||
if (coffees < 2)
|
if (coffees_ < 2)
|
||||||
{
|
{
|
||||||
coffees++;
|
coffees_++;
|
||||||
playerSprite->getTexture()->setPalette(coffees);
|
player_sprite_->getTexture()->setPalette(coffees_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quita el toque extra al jugador
|
// Quita el toque extra al jugador
|
||||||
void Player::removeExtraHit()
|
void Player::removeExtraHit()
|
||||||
{
|
{
|
||||||
if (coffees > 0)
|
if (coffees_ > 0)
|
||||||
{
|
{
|
||||||
coffees--;
|
coffees_--;
|
||||||
setInvulnerable(true);
|
setInvulnerable(true);
|
||||||
playerSprite->getTexture()->setPalette(coffees);
|
player_sprite_->getTexture()->setPalette(coffees_);
|
||||||
}
|
}
|
||||||
|
|
||||||
extraHit = coffees == 0 ? false : true;
|
extra_hit_ = coffees_ == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Habilita la entrada de ordenes
|
// Habilita la entrada de ordenes
|
||||||
void Player::enableInput()
|
void Player::enableInput()
|
||||||
{
|
{
|
||||||
input = true;
|
input_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deshabilita la entrada de ordenes
|
// Deshabilita la entrada de ordenes
|
||||||
void Player::disableInput()
|
void Player::disableInput()
|
||||||
{
|
{
|
||||||
input = false;
|
input_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el número de cafes actuales
|
// Devuelve el número de cafes actuales
|
||||||
int Player::getCoffees() const
|
int Player::getCoffees() const
|
||||||
{
|
{
|
||||||
return coffees;
|
return coffees_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el circulo de colisión
|
// Obtiene el circulo de colisión
|
||||||
Circle &Player::getCollider()
|
Circle &Player::getCollider()
|
||||||
{
|
{
|
||||||
return collider;
|
return collider_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 Player::shiftColliders()
|
void Player::shiftColliders()
|
||||||
{
|
{
|
||||||
collider.x = int(posX + (width / 2));
|
collider_.x = int(pos_x_ + (width_ / 2));
|
||||||
collider.y = int(posY + (height / 2));
|
collider_.y = int(pos_y_ + (height_ / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone las texturas del jugador
|
// Pone las texturas del jugador
|
||||||
void Player::setPlayerTextures(std::vector<std::shared_ptr<Texture>> texture)
|
void Player::setPlayerTextures(std::vector<std::shared_ptr<Texture>> texture)
|
||||||
{
|
{
|
||||||
playerSprite->setTexture(texture[0]);
|
player_sprite_->setTexture(texture[0]);
|
||||||
powerSprite->setTexture(texture[1]);
|
power_sprite_->setTexture(texture[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getContinueCounter() const
|
int Player::getContinueCounter() const
|
||||||
{
|
{
|
||||||
return continueCounter;
|
return continue_counter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el contador de continue
|
// Actualiza el contador de continue
|
||||||
void Player::updateContinueCounter()
|
void Player::updateContinueCounter()
|
||||||
{
|
{
|
||||||
if (statusPlaying == PlayerStatus::CONTINUE)
|
if (status_playing_ == PlayerStatus::CONTINUE)
|
||||||
{
|
{
|
||||||
const Uint32 ticksSpeed = 1000;
|
constexpr Uint32 ticks_speed = 1000;
|
||||||
|
|
||||||
if (SDL_GetTicks() - continueTicks > ticksSpeed)
|
if (SDL_GetTicks() - continue_ticks_ > ticks_speed)
|
||||||
{
|
{
|
||||||
decContinueCounter();
|
decContinueCounter();
|
||||||
}
|
}
|
||||||
@@ -708,21 +723,21 @@ void Player::updateContinueCounter()
|
|||||||
// Le asigna un panel en el marcador al jugador
|
// Le asigna un panel en el marcador al jugador
|
||||||
void Player::setScoreBoardPanel(int panel)
|
void Player::setScoreBoardPanel(int panel)
|
||||||
{
|
{
|
||||||
scoreBoardPanel = panel;
|
scoreboard_panel_ = panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getScoreBoardPanel() const
|
int Player::getScoreBoardPanel() const
|
||||||
{
|
{
|
||||||
return scoreBoardPanel;
|
return scoreboard_panel_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrementa el contador de continuar
|
// Decrementa el contador de continuar
|
||||||
void Player::decContinueCounter()
|
void Player::decContinueCounter()
|
||||||
{
|
{
|
||||||
continueTicks = SDL_GetTicks();
|
continue_ticks_ = SDL_GetTicks();
|
||||||
continueCounter--;
|
continue_counter_--;
|
||||||
if (continueCounter < 0)
|
if (continue_counter_ < 0)
|
||||||
{
|
{
|
||||||
setStatusPlaying(PlayerStatus::GAME_OVER);
|
setStatusPlaying(PlayerStatus::GAME_OVER);
|
||||||
}
|
}
|
||||||
@@ -731,33 +746,33 @@ void Player::decContinueCounter()
|
|||||||
// Establece el nombre del jugador
|
// Establece el nombre del jugador
|
||||||
void Player::setName(std::string name)
|
void Player::setName(std::string name)
|
||||||
{
|
{
|
||||||
this->name = name;
|
name_ = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el nombre del jugador para la tabla de mejores puntuaciones
|
// Establece el nombre del jugador para la tabla de mejores puntuaciones
|
||||||
void Player::setRecordName(std::string recordName)
|
void Player::setRecordName(std::string record_name)
|
||||||
{
|
{
|
||||||
this->recordName = recordName.substr(0, 8);
|
record_name_ = record_name.substr(0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el nombre del jugador
|
// Obtiene el nombre del jugador
|
||||||
std::string Player::getName() const
|
std::string Player::getName() const
|
||||||
{
|
{
|
||||||
return name;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el nombre del jugador para la tabla de mejores puntuaciones
|
// Obtiene el nombre del jugador para la tabla de mejores puntuaciones
|
||||||
std::string Player::getRecordName() const
|
std::string Player::getRecordName() const
|
||||||
{
|
{
|
||||||
return recordName;
|
return record_name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene la posici´´on que se está editando del nombre del jugador para la tabla de mejores puntuaciones
|
// Obtiene la posici´´on que se está editando del nombre del jugador para la tabla de mejores puntuaciones
|
||||||
int Player::getRecordNamePos() const
|
int Player::getRecordNamePos() const
|
||||||
{
|
{
|
||||||
if (enterName)
|
if (enter_name_)
|
||||||
{
|
{
|
||||||
return enterName->getPos();
|
return enter_name_->getPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -766,19 +781,19 @@ int Player::getRecordNamePos() const
|
|||||||
// Establece el mando que usará para ser controlado
|
// Establece el mando que usará para ser controlado
|
||||||
void Player::setController(int index)
|
void Player::setController(int index)
|
||||||
{
|
{
|
||||||
controllerIndex = index;
|
controller_index_ = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el mando que usa para ser controlado
|
// Obtiene el mando que usa para ser controlado
|
||||||
int Player::getController() const
|
int Player::getController() const
|
||||||
{
|
{
|
||||||
return controllerIndex;
|
return controller_index_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el "id" del jugador
|
// Obtiene el "id" del jugador
|
||||||
int Player::getId() const
|
int Player::getId() const
|
||||||
{
|
{
|
||||||
return id;
|
return id_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador se puede dibujar
|
// Indica si el jugador se puede dibujar
|
||||||
@@ -790,5 +805,5 @@ bool Player::isRenderable() const
|
|||||||
// Comprueba si la puntuación entra en la tabla de mejores puntuaciones
|
// Comprueba si la puntuación entra en la tabla de mejores puntuaciones
|
||||||
bool Player::IsEligibleForHighScore()
|
bool Player::IsEligibleForHighScore()
|
||||||
{
|
{
|
||||||
return score > options.game.hi_score_table.back().score;
|
return score_ > options.game.hi_score_table.back().score;
|
||||||
}
|
}
|
||||||
@@ -41,44 +41,44 @@ class Player
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
std::unique_ptr<AnimatedSprite> playerSprite; // Sprite para dibujar el jugador
|
std::unique_ptr<AnimatedSprite> player_sprite_; // Sprite para dibujar el jugador
|
||||||
std::unique_ptr<AnimatedSprite> powerSprite; // Sprite para dibujar el aura del jugador con el poder a tope
|
std::unique_ptr<AnimatedSprite> power_sprite_; // Sprite para dibujar el aura del jugador con el poder a tope
|
||||||
std::unique_ptr<EnterName> enterName; // Clase utilizada para introducir el nombre
|
std::unique_ptr<EnterName> enter_name_; // Clase utilizada para introducir el nombre
|
||||||
SDL_Rect *playArea; // Rectangulo con la zona de juego
|
SDL_Rect *play_area_; // Rectangulo con la zona de juego
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int id; // Numero de identificación para el jugador
|
int id_; // Numero de identificación para el jugador
|
||||||
float posX; // Posicion en el eje X
|
float pos_x_; // Posicion en el eje X
|
||||||
int posY; // Posicion en el eje Y
|
int pos_y_; // Posicion en el eje Y
|
||||||
float defaultPosX; // Posición inicial para el jugador
|
float default_pos_x_; // Posición inicial para el jugador
|
||||||
int defaultPosY; // Posición inicial para el jugador
|
int default_pos_y_; // Posición inicial para el jugador
|
||||||
int width; // Anchura
|
int width_; // Anchura
|
||||||
int height; // Altura
|
int height_; // Altura
|
||||||
float velX; // Cantidad de pixeles a desplazarse en el eje X
|
float vel_x_; // Cantidad de pixeles a desplazarse en el eje X
|
||||||
int velY; // Cantidad de pixeles a desplazarse en el eje Y
|
int vel_y_; // Cantidad de pixeles a desplazarse en el eje Y
|
||||||
float baseSpeed; // Velocidad base del jugador
|
float base_speed_; // Velocidad base del jugador
|
||||||
int cooldown; // Contador durante el cual no puede disparar
|
int cooldown_; // Contador durante el cual no puede disparar
|
||||||
int score; // Puntos del jugador
|
int score_; // Puntos del jugador
|
||||||
float scoreMultiplier; // Multiplicador de puntos
|
float score_multiplier_; // Multiplicador de puntos
|
||||||
PlayerStatus statusWalking; // Estado del jugador al moverse
|
PlayerStatus status_walking_; // Estado del jugador al moverse
|
||||||
PlayerStatus statusFiring; // Estado del jugador al disparar
|
PlayerStatus status_firing_; // Estado del jugador al disparar
|
||||||
PlayerStatus statusPlaying; // Estado del jugador en el juego
|
PlayerStatus status_playing_; // Estado del jugador en el juego
|
||||||
bool invulnerable; // Indica si el jugador es invulnerable
|
bool invulnerable_; // Indica si el jugador es invulnerable
|
||||||
int invulnerableCounter; // Contador para la invulnerabilidad
|
int invulnerable_counter_; // Contador para la invulnerabilidad
|
||||||
bool extraHit; // Indica si el jugador tiene un toque extra
|
bool extra_hit_; // Indica si el jugador tiene un toque extra
|
||||||
int coffees; // Indica cuantos cafes lleva acumulados
|
int coffees_; // Indica cuantos cafes lleva acumulados
|
||||||
bool powerUp; // Indica si el jugador tiene activo el modo PowerUp
|
bool power_up_; // Indica si el jugador tiene activo el modo PowerUp
|
||||||
int powerUpCounter; // Temporizador para el modo PowerUp
|
int power_up_counter_; // Temporizador para el modo PowerUp
|
||||||
int powerUpDespX; // Desplazamiento del sprite de PowerUp respecto al sprite del jugador
|
int power_up_desp_x_; // Desplazamiento del sprite de PowerUp respecto al sprite del jugador
|
||||||
bool input; // Indica si puede recibir ordenes de entrada
|
bool input_; // Indica si puede recibir ordenes de entrada
|
||||||
Circle collider; // Circulo de colisión del jugador
|
Circle collider_; // Circulo de colisión del jugador
|
||||||
int continueCounter; // Contador para poder continuar
|
int continue_counter_; // Contador para poder continuar
|
||||||
Uint32 continueTicks; // Variable para poder cambiar el contador de continue en función del tiempo
|
Uint32 continue_ticks_; // Variable para poder cambiar el contador de continue en función del tiempo
|
||||||
int scoreBoardPanel; // Panel del marcador asociado al jugador
|
int scoreboard_panel_; // Panel del marcador asociado al jugador
|
||||||
std::string name; // Nombre del jugador
|
std::string name_; // Nombre del jugador
|
||||||
std::string recordName; // Nombre del jugador para l atabla de mejores puntuaciones
|
std::string record_name_; // Nombre del jugador para l atabla de mejores puntuaciones
|
||||||
int controllerIndex; // Indice del array de mandos que utilizará para moverse
|
int controller_index_; // 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
|
||||||
|
|
||||||
// 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();
|
||||||
@@ -103,7 +103,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Player(int id, float x, int y, bool demo, SDL_Rect *playArea, std::vector<std::shared_ptr<Texture>> texture, std::vector<std::vector<std::string> *> animations);
|
Player(int id, float x, int y, bool demo, SDL_Rect *play_area, std::vector<std::shared_ptr<Texture>> texture, std::vector<std::vector<std::string> *> animations);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Player() = default;
|
~Player() = default;
|
||||||
@@ -274,7 +274,7 @@ public:
|
|||||||
void setName(std::string name);
|
void setName(std::string name);
|
||||||
|
|
||||||
// Establece el nombre del jugador para la tabla de mejores puntuaciones
|
// Establece el nombre del jugador para la tabla de mejores puntuaciones
|
||||||
void setRecordName(std::string recordName);
|
void setRecordName(std::string record_name);
|
||||||
|
|
||||||
// Obtiene el nombre del jugador
|
// Obtiene el nombre del jugador
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user