neteja tidy a source/game (fixes d'arrel: BulletKind enum class, signatures, branches)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "game/entities/player.h"
|
||||
|
||||
#include <stdlib.h> // for rand
|
||||
#include <algorithm>
|
||||
#include <cstdlib> // for rand
|
||||
|
||||
#include "core/input/input.h" // for inputs_e
|
||||
#include "core/rendering/animatedsprite.h" // for AnimatedSprite
|
||||
@@ -72,7 +73,7 @@ void Player::init() {
|
||||
score = 0;
|
||||
|
||||
// Establece el multiplicador de puntos inicial
|
||||
scoreMultiplier = 1.0f;
|
||||
scoreMultiplier = 1.0F;
|
||||
|
||||
// Inicia el contador para la cadencia de disparo
|
||||
cooldown = 10;
|
||||
@@ -200,8 +201,8 @@ void Player::setFiringStatus(Uint8 status) {
|
||||
// Establece la animación correspondiente al estado
|
||||
void Player::setAnimation() {
|
||||
// Crea cadenas de texto para componer el nombre de la animación
|
||||
std::string aBodyCoffees = "";
|
||||
std::string aHeadCoffees = "";
|
||||
std::string aBodyCoffees;
|
||||
std::string aHeadCoffees;
|
||||
if (coffees > 0) {
|
||||
aBodyCoffees = coffees == 1 ? "_1C" : "_2C";
|
||||
aHeadCoffees = "_1C";
|
||||
@@ -239,33 +240,29 @@ void Player::setAnimation() {
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Player::getPosX() {
|
||||
auto Player::getPosX() const -> int {
|
||||
return int(posX);
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Player::getPosY() {
|
||||
auto Player::getPosY() const -> int {
|
||||
return posY;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Player::getWidth() {
|
||||
auto Player::getWidth() const -> int {
|
||||
return width;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Player::getHeight() {
|
||||
auto Player::getHeight() const -> int {
|
||||
return height;
|
||||
}
|
||||
|
||||
// Indica si el jugador puede disparar
|
||||
bool Player::canFire() {
|
||||
auto Player::canFire() const -> bool {
|
||||
// Si el contador a llegado a cero, podemos disparar. En caso contrario decrementamos el contador
|
||||
if (cooldown > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return cooldown <= 0;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
@@ -298,7 +295,7 @@ void Player::update() {
|
||||
}
|
||||
|
||||
// Obtiene la puntuación del jugador
|
||||
Uint32 Player::getScore() {
|
||||
auto Player::getScore() const -> Uint32 {
|
||||
return score;
|
||||
}
|
||||
|
||||
@@ -313,7 +310,7 @@ void Player::addScore(Uint32 score) {
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Player::isAlive() {
|
||||
auto Player::isAlive() const -> bool {
|
||||
return alive;
|
||||
}
|
||||
|
||||
@@ -324,17 +321,17 @@ void Player::setAlive(bool value) {
|
||||
if (!value) {
|
||||
deathSprite->setPosX(headSprite->getRect().x);
|
||||
deathSprite->setPosY(headSprite->getRect().y);
|
||||
deathSprite->setAccelY(0.2f);
|
||||
deathSprite->setVelY(-6.6f);
|
||||
deathSprite->setVelX(3.3f);
|
||||
deathSprite->setAccelY(0.2F);
|
||||
deathSprite->setVelY(-6.6F);
|
||||
deathSprite->setVelX(3.3F);
|
||||
if (rand() % 2 == 0) {
|
||||
deathSprite->setVelX(-3.3f);
|
||||
deathSprite->setVelX(-3.3F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
float Player::getScoreMultiplier() {
|
||||
auto Player::getScoreMultiplier() const -> float {
|
||||
return scoreMultiplier;
|
||||
}
|
||||
|
||||
@@ -345,24 +342,24 @@ void Player::setScoreMultiplier(float value) {
|
||||
|
||||
// Aumenta el valor de la variable hasta un máximo
|
||||
void Player::incScoreMultiplier() {
|
||||
if (scoreMultiplier < 5.0f) {
|
||||
scoreMultiplier += 0.1f;
|
||||
if (scoreMultiplier < 5.0F) {
|
||||
scoreMultiplier += 0.1F;
|
||||
} else {
|
||||
scoreMultiplier = 5.0f;
|
||||
scoreMultiplier = 5.0F;
|
||||
}
|
||||
}
|
||||
|
||||
// Decrementa el valor de la variable hasta un mínimo
|
||||
void Player::decScoreMultiplier() {
|
||||
if (scoreMultiplier > 1.0f) {
|
||||
scoreMultiplier -= 0.1f;
|
||||
if (scoreMultiplier > 1.0F) {
|
||||
scoreMultiplier -= 0.1F;
|
||||
} else {
|
||||
scoreMultiplier = 1.0f;
|
||||
scoreMultiplier = 1.0F;
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Player::isInvulnerable() {
|
||||
auto Player::isInvulnerable() const -> bool {
|
||||
return invulnerable;
|
||||
}
|
||||
|
||||
@@ -372,7 +369,7 @@ void Player::setInvulnerable(bool value) {
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 Player::getInvulnerableCounter() {
|
||||
auto Player::getInvulnerableCounter() const -> Uint16 {
|
||||
return invulnerableCounter;
|
||||
}
|
||||
|
||||
@@ -403,7 +400,7 @@ void Player::updateDeathCounter() {
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Player::isPowerUp() {
|
||||
auto Player::isPowerUp() const -> bool {
|
||||
return powerUp;
|
||||
}
|
||||
|
||||
@@ -413,7 +410,7 @@ void Player::setPowerUp(bool value) {
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 Player::getPowerUpCounter() {
|
||||
auto Player::getPowerUpCounter() const -> Uint16 {
|
||||
return powerUpCounter;
|
||||
}
|
||||
|
||||
@@ -433,7 +430,7 @@ void Player::updatePowerUpCounter() {
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Player::hasExtraHit() {
|
||||
auto Player::hasExtraHit() const -> bool {
|
||||
return extraHit;
|
||||
}
|
||||
|
||||
@@ -441,9 +438,7 @@ bool Player::hasExtraHit() {
|
||||
void Player::giveExtraHit() {
|
||||
extraHit = true;
|
||||
coffees++;
|
||||
if (coffees > 2) {
|
||||
coffees = 2;
|
||||
}
|
||||
coffees = std::min<int>(coffees, 2);
|
||||
}
|
||||
|
||||
// Quita el toque extra al jugador
|
||||
@@ -469,29 +464,29 @@ void Player::disableInput() {
|
||||
}
|
||||
|
||||
// Devuelve el numero de cafes actuales
|
||||
Uint8 Player::getCoffees() {
|
||||
auto Player::getCoffees() const -> Uint8 {
|
||||
return coffees;
|
||||
}
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &Player::getCollider() {
|
||||
auto Player::getCollider() -> circle_t & {
|
||||
return collider;
|
||||
}
|
||||
|
||||
// Actualiza el circulo de colisión a la posición del jugador
|
||||
void Player::shiftColliders() {
|
||||
collider.x = int(posX + (width / 2));
|
||||
collider.y = int(posY + (height / 2));
|
||||
collider.y = (posY + (height / 2));
|
||||
}
|
||||
|
||||
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
||||
Texture *Player::getDeadTexture() {
|
||||
auto Player::getDeadTexture() -> Texture * {
|
||||
return deathSprite->getTexture();
|
||||
;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 Player::getDeathCounter() {
|
||||
auto Player::getDeathCounter() const -> Uint16 {
|
||||
return deathCounter;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user