Eliminados metodos y variables sobrantes de la clase player

This commit is contained in:
2024-06-30 20:10:10 +02:00
parent eb3cba879a
commit 0d8207013c
4 changed files with 16 additions and 48 deletions

View File

@@ -1,5 +1,7 @@
#include "game.h" #include "game.h"
#define DEATH_COUNTER 350
// Constructor // Constructor
Game::Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section) Game::Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section)
{ {
@@ -46,7 +48,7 @@ Game::Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *scree
SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND); SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND);
// Inicializa las variables necesarias para la sección 'Game' // Inicializa las variables necesarias para la sección 'Game'
init(); init(playerID);
} }
Game::~Game() Game::~Game()
@@ -154,7 +156,7 @@ Game::~Game()
} }
// Inicializa las variables necesarias para la sección 'Game' // Inicializa las variables necesarias para la sección 'Game'
void Game::init() void Game::init(int playerID)
{ {
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -175,6 +177,7 @@ void Game::init()
// Variables relacionadas con la dificultad // Variables relacionadas con la dificultad
switch (difficulty) switch (difficulty)
{ {

View File

@@ -225,7 +225,7 @@ private:
void checkEvents(); void checkEvents();
// Inicializa las variables necesarias para la sección 'Game' // Inicializa las variables necesarias para la sección 'Game'
void init(); void init(int playerID);
// Carga los recursos necesarios para la sección 'Game' // Carga los recursos necesarios para la sección 'Game'
void loadMedia(); void loadMedia();

View File

@@ -39,7 +39,6 @@ void Player::init()
posX = defaultPosX; posX = defaultPosX;
posY = defaultPosY; posY = defaultPosY;
alive = true; alive = true;
deathCounter = DEATH_COUNTER;
statusWalking = PLAYER_STATUS_WALKING_STOP; statusWalking = PLAYER_STATUS_WALKING_STOP;
statusFiring = PLAYER_STATUS_FIRING_NO; statusFiring = PLAYER_STATUS_FIRING_NO;
invulnerable = true; invulnerable = true;
@@ -136,7 +135,8 @@ void Player::move()
// Si el jugador abandona el area de juego por los laterales // Si el jugador abandona el area de juego por los laterales
if ((posX < PLAY_AREA_LEFT - 5) || (posX + width > PLAY_AREA_RIGHT + 5)) if ((posX < PLAY_AREA_LEFT - 5) || (posX + width > PLAY_AREA_RIGHT + 5))
{ // Restaura su posición {
// Restaura su posición
posX -= velX; posX -= velX;
} }
@@ -159,7 +159,8 @@ void Player::move()
// Si el cadaver abandona el area de juego por los laterales // Si el cadaver abandona el area de juego por los laterales
if ((deathSprite->getPosX() < PLAY_AREA_LEFT) || (deathSprite->getPosX() + width > PLAY_AREA_RIGHT)) if ((deathSprite->getPosX() < PLAY_AREA_LEFT) || (deathSprite->getPosX() + width > PLAY_AREA_RIGHT))
{ // Restaura su posición {
// Restaura su posición
const float vx = deathSprite->getVelX(); const float vx = deathSprite->getVelX();
deathSprite->setPosX(deathSprite->getPosX() - vx); deathSprite->setPosX(deathSprite->getPosX() - vx);
@@ -211,7 +212,6 @@ void Player::setWalkingStatus(Uint8 status)
if (statusWalking != status) if (statusWalking != status)
{ {
statusWalking = status; statusWalking = status;
// legsSprite->setCurrentFrame(0);
} }
} }
@@ -248,14 +248,16 @@ void Player::setAnimation()
legsSprite->setCurrentAnimation(aWalking); legsSprite->setCurrentAnimation(aWalking);
legsSprite->setFlip(flipWalk); legsSprite->setFlip(flipWalk);
if (statusFiring == PLAYER_STATUS_FIRING_NO) if (statusFiring == PLAYER_STATUS_FIRING_NO)
{ // No esta disparando {
// No esta disparando
bodySprite->setCurrentAnimation(aWalking + aBodyCoffees + aPowerUp); bodySprite->setCurrentAnimation(aWalking + aBodyCoffees + aPowerUp);
bodySprite->setFlip(flipWalk); bodySprite->setFlip(flipWalk);
headSprite->setCurrentAnimation(aWalking + aHeadCoffees + aPowerUp); headSprite->setCurrentAnimation(aWalking + aHeadCoffees + aPowerUp);
headSprite->setFlip(flipWalk); headSprite->setFlip(flipWalk);
} }
else else
{ // Está disparando {
// Está disparando
bodySprite->setCurrentAnimation(aFiring + aBodyCoffees + aPowerUp); bodySprite->setCurrentAnimation(aFiring + aBodyCoffees + aPowerUp);
bodySprite->setFlip(flipFire); bodySprite->setFlip(flipFire);
headSprite->setCurrentAnimation(aFiring + aHeadCoffees + aPowerUp); headSprite->setCurrentAnimation(aFiring + aHeadCoffees + aPowerUp);
@@ -299,14 +301,7 @@ int Player::getHeight()
bool Player::canFire() bool Player::canFire()
{ {
// 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
if (cooldown > 0) return cooldown > 0 ? false : true;
{
return false;
}
else
{
return true;
}
} }
// Establece el valor de la variable // Establece el valor de la variable
@@ -341,7 +336,6 @@ void Player::update()
updateCooldown(); updateCooldown();
updatePowerUpCounter(); updatePowerUpCounter();
updateInvulnerableCounter(); updateInvulnerableCounter();
updateDeathCounter();
updatePowerUpHeadOffset(); updatePowerUpHeadOffset();
} }
@@ -467,18 +461,6 @@ void Player::updateInvulnerableCounter()
} }
} }
// Actualiza el valor de la variable
void Player::updateDeathCounter()
{
if (!alive)
{
if (deathCounter > 0)
{
deathCounter--;
}
}
}
// Obtiene el valor de la variable // Obtiene el valor de la variable
bool Player::isPowerUp() bool Player::isPowerUp()
{ {
@@ -584,13 +566,6 @@ void Player::shiftColliders()
Texture *Player::getDeadTexture() Texture *Player::getDeadTexture()
{ {
return deathSprite->getTexture(); return deathSprite->getTexture();
;
}
// Obtiene el valor de la variable
Uint16 Player::getDeathCounter()
{
return deathCounter;
} }
// Actualiza el valor de la variable // Actualiza el valor de la variable

View File

@@ -10,9 +10,6 @@
#ifndef PLAYER_H #ifndef PLAYER_H
#define PLAYER_H #define PLAYER_H
// Contadores
#define DEATH_COUNTER 350
// Estados del jugador // Estados del jugador
#define PLAYER_STATUS_WALKING_LEFT 0 #define PLAYER_STATUS_WALKING_LEFT 0
#define PLAYER_STATUS_WALKING_RIGHT 1 #define PLAYER_STATUS_WALKING_RIGHT 1
@@ -61,8 +58,6 @@ private:
Uint8 statusWalking; // Estado del jugador Uint8 statusWalking; // Estado del jugador
Uint8 statusFiring; // Estado del jugador Uint8 statusFiring; // Estado del jugador
bool alive; // Indica si el jugador está vivo
Uint16 deathCounter; // Contador para la animación de morirse
bool invulnerable; // Indica si el jugador es invulnerable bool invulnerable; // Indica si el jugador es invulnerable
Uint16 invulnerableCounter; // Contador para la invulnerabilidad Uint16 invulnerableCounter; // Contador para la invulnerabilidad
bool extraHit; // Indica si el jugador tiene un toque extra bool extraHit; // Indica si el jugador tiene un toque extra
@@ -71,6 +66,7 @@ private:
Uint16 powerUpCounter; // Temporizador para el modo PowerUp Uint16 powerUpCounter; // Temporizador para el modo PowerUp
bool input; // Indica si puede recibir ordenes de entrada bool input; // Indica si puede recibir ordenes de entrada
circle_t collider; // Circulo de colisión del jugador circle_t collider; // Circulo de colisión del jugador
bool alive; // Indica si el jugador está vivo
// 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();
@@ -78,9 +74,6 @@ private:
// Actualiza el valor de la variable // Actualiza el valor de la variable
void updateInvulnerableCounter(); void updateInvulnerableCounter();
// Actualiza el valor de la variable
void updateDeathCounter();
// Actualiza el valor de la variable // Actualiza el valor de la variable
void updatePowerUpHeadOffset(); void updatePowerUpHeadOffset();
@@ -216,9 +209,6 @@ public:
// Obtiene el puntero a la textura con los gráficos de la animación de morir // Obtiene el puntero a la textura con los gráficos de la animación de morir
Texture *getDeadTexture(); Texture *getDeadTexture();
// Obtiene el valor de la variable
Uint16 getDeathCounter();
}; };
#endif #endif