neteja tidy a source/game (fixes d'arrel: BulletKind enum class, signatures, branches)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "game/entities/balloon.h"
|
||||
|
||||
#include <math.h> // for abs
|
||||
#include <cmath> // for abs
|
||||
|
||||
#include "core/rendering/animatedsprite.h" // for AnimatedSprite
|
||||
#include "core/rendering/movingsprite.h" // for MovingSprite
|
||||
@@ -26,9 +26,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
// Inicializa los valores de velocidad y gravedad
|
||||
this->velX = velx;
|
||||
velY = 0;
|
||||
maxVelY = 3.0f;
|
||||
gravity = 0.09f;
|
||||
defaultVelY = 2.6f;
|
||||
maxVelY = 3.0F;
|
||||
gravity = 0.09F;
|
||||
defaultVelY = 2.6F;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
score = BALLOON_SCORE_1;
|
||||
@@ -48,9 +48,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
// Inicializa los valores de velocidad y gravedad
|
||||
this->velX = velx;
|
||||
velY = 0;
|
||||
maxVelY = 3.0f;
|
||||
gravity = 0.10f;
|
||||
defaultVelY = 3.5f;
|
||||
maxVelY = 3.0F;
|
||||
gravity = 0.10F;
|
||||
defaultVelY = 3.5F;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
score = BALLOON_SCORE_2;
|
||||
@@ -70,9 +70,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
// Inicializa los valores de velocidad y gravedad
|
||||
this->velX = velx;
|
||||
velY = 0;
|
||||
maxVelY = 3.0f;
|
||||
gravity = 0.10f;
|
||||
defaultVelY = 4.50f;
|
||||
maxVelY = 3.0F;
|
||||
gravity = 0.10F;
|
||||
defaultVelY = 4.50F;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
score = BALLOON_SCORE_3;
|
||||
@@ -92,9 +92,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
// Inicializa los valores de velocidad y gravedad
|
||||
this->velX = velx;
|
||||
velY = 0;
|
||||
maxVelY = 3.0f;
|
||||
gravity = 0.10f;
|
||||
defaultVelY = 4.95f;
|
||||
maxVelY = 3.0F;
|
||||
gravity = 0.10F;
|
||||
defaultVelY = 4.95F;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
score = BALLOON_SCORE_4;
|
||||
@@ -115,7 +115,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
this->velX = velx;
|
||||
velY = abs(velx) * 2;
|
||||
maxVelY = abs(velx) * 2;
|
||||
gravity = 0.00f;
|
||||
gravity = 0.00F;
|
||||
defaultVelY = abs(velx) * 2;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
@@ -137,7 +137,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
this->velX = velx;
|
||||
velY = abs(velx) * 2;
|
||||
maxVelY = abs(velx) * 2;
|
||||
gravity = 0.00f;
|
||||
gravity = 0.00F;
|
||||
defaultVelY = abs(velx) * 2;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
@@ -159,7 +159,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
this->velX = velx;
|
||||
velY = abs(velx) * 2;
|
||||
maxVelY = abs(velx) * 2;
|
||||
gravity = 0.00f;
|
||||
gravity = 0.00F;
|
||||
defaultVelY = abs(velx) * 2;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
@@ -181,7 +181,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
this->velX = velx;
|
||||
velY = abs(velx) * 2;
|
||||
maxVelY = abs(velx) * 2;
|
||||
gravity = 0.00f;
|
||||
gravity = 0.00F;
|
||||
defaultVelY = abs(velx) * 2;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
@@ -202,9 +202,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
// Inicializa los valores de velocidad y gravedad
|
||||
this->velX = velx;
|
||||
velY = 0;
|
||||
maxVelY = 3.0f;
|
||||
gravity = 0.10f;
|
||||
defaultVelY = 4.95f;
|
||||
maxVelY = 3.0F;
|
||||
gravity = 0.10F;
|
||||
defaultVelY = 4.95F;
|
||||
|
||||
// Puntos que da el globo al ser destruido
|
||||
score = 0;
|
||||
@@ -215,7 +215,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
// Añade rotación al sprite
|
||||
sprite->setRotate(false);
|
||||
sprite->setRotateSpeed(0);
|
||||
if (velX > 0.0f) {
|
||||
if (velX > 0.0F) {
|
||||
sprite->setRotateAmount(2.0);
|
||||
} else {
|
||||
sprite->setRotateAmount(-2.0);
|
||||
@@ -235,12 +235,12 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
bouncing.enabled = false;
|
||||
bouncing.counter = 0;
|
||||
bouncing.speed = 2;
|
||||
bouncing.zoomW = 1.0f;
|
||||
bouncing.zoomH = 1.0f;
|
||||
bouncing.despX = 0.0f;
|
||||
bouncing.despY = 0.0f;
|
||||
bouncing.w = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f};
|
||||
bouncing.h = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f};
|
||||
bouncing.zoomW = 1.0F;
|
||||
bouncing.zoomH = 1.0F;
|
||||
bouncing.despX = 0.0F;
|
||||
bouncing.despY = 0.0F;
|
||||
bouncing.w = {1.10F, 1.05F, 1.00F, 0.95F, 0.90F, 0.95F, 1.00F, 1.02F, 1.05F, 1.02F};
|
||||
bouncing.h = {0.90F, 0.95F, 1.00F, 1.05F, 1.10F, 1.05F, 1.00F, 0.98F, 0.95F, 0.98F};
|
||||
|
||||
// Alto y ancho del sprite
|
||||
sprite->setWidth(width);
|
||||
@@ -270,7 +270,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
||||
invulnerable = beingCreated;
|
||||
|
||||
counter = 0;
|
||||
travelY = 1.0f;
|
||||
travelY = 1.0F;
|
||||
this->speed = speed;
|
||||
|
||||
// Tipo
|
||||
@@ -286,10 +286,11 @@ Balloon::~Balloon() {
|
||||
void Balloon::allignTo(int x) {
|
||||
posX = float(x - (width / 2));
|
||||
|
||||
if (posX < PLAY_AREA_LEFT)
|
||||
if (posX < PLAY_AREA_LEFT) {
|
||||
posX = PLAY_AREA_LEFT + 1;
|
||||
else if ((posX + width) > PLAY_AREA_RIGHT)
|
||||
} else if ((posX + width) > PLAY_AREA_RIGHT) {
|
||||
posX = float(PLAY_AREA_RIGHT - width - 1);
|
||||
}
|
||||
|
||||
// Posición X,Y del sprite
|
||||
sprite->setPosX(getPosX());
|
||||
@@ -313,10 +314,10 @@ void Balloon::render() {
|
||||
}
|
||||
} else if (isBeingCreated()) {
|
||||
// Aplica alpha blending
|
||||
sprite->getTexture()->setAlpha(255 - (int)((float)creationCounter * (255.0f / (float)creationCounterIni)));
|
||||
sprite->getTexture()->setAlpha(255 - (int)((float)creationCounter * (255.0F / (float)creationCounterIni)));
|
||||
sprite->render();
|
||||
if (kind == POWER_BALL) {
|
||||
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer());
|
||||
auto *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer());
|
||||
sp->setSpriteClip(407, 0, 37, 37);
|
||||
sp->render();
|
||||
delete sp;
|
||||
@@ -326,7 +327,7 @@ void Balloon::render() {
|
||||
sprite->render();
|
||||
|
||||
if (kind == POWER_BALL and !popping) {
|
||||
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer());
|
||||
auto *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer());
|
||||
sp->setSpriteClip(407, 0, 37, 37);
|
||||
sp->render();
|
||||
delete sp;
|
||||
@@ -403,9 +404,9 @@ void Balloon::move() {
|
||||
travelY += speed;
|
||||
|
||||
// Si la distancia acumulada en Y es igual a la velocidad, se aplica la gravedad
|
||||
if (travelY >= 1.0f) {
|
||||
if (travelY >= 1.0F) {
|
||||
// Quita el excedente
|
||||
travelY -= 1.0f;
|
||||
travelY -= 1.0F;
|
||||
|
||||
// Aplica la gravedad al objeto sin pasarse de una velocidad máxima
|
||||
velY += gravity;
|
||||
@@ -431,17 +432,17 @@ void Balloon::disable() {
|
||||
counter = 0;
|
||||
creationCounter = 0;
|
||||
creationCounterIni = 0;
|
||||
defaultVelY = 0.0f;
|
||||
defaultVelY = 0.0F;
|
||||
enabled = false;
|
||||
gravity = 0.0f;
|
||||
gravity = 0.0F;
|
||||
height = 0;
|
||||
invulnerable = false;
|
||||
kind = 0;
|
||||
maxVelY = 0.0f;
|
||||
maxVelY = 0.0F;
|
||||
menace = 0;
|
||||
popping = false;
|
||||
posX = 0.0f;
|
||||
posY = 0.0f;
|
||||
posX = 0.0F;
|
||||
posY = 0.0F;
|
||||
power = 0;
|
||||
score = 0;
|
||||
size = 0;
|
||||
@@ -449,8 +450,8 @@ void Balloon::disable() {
|
||||
stopped = false;
|
||||
stoppedCounter = 0;
|
||||
travelY = 0;
|
||||
velX = 0.0f;
|
||||
velY = 0.0f;
|
||||
velX = 0.0F;
|
||||
velY = 0.0F;
|
||||
visible = false;
|
||||
width = 0;
|
||||
sprite->clear();
|
||||
@@ -580,32 +581,32 @@ void Balloon::updateAnimation() {
|
||||
}
|
||||
|
||||
// Comprueba si el globo está habilitado
|
||||
bool Balloon::isEnabled() {
|
||||
auto Balloon::isEnabled() const -> bool {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float Balloon::getPosX() {
|
||||
auto Balloon::getPosX() const -> float {
|
||||
return posX;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float Balloon::getPosY() {
|
||||
auto Balloon::getPosY() const -> float {
|
||||
return posY;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float Balloon::getVelY() {
|
||||
auto Balloon::getVelY() const -> float {
|
||||
return velY;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int Balloon::getWidth() {
|
||||
auto Balloon::getWidth() const -> int {
|
||||
return width;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int Balloon::getHeight() {
|
||||
auto Balloon::getHeight() const -> int {
|
||||
return height;
|
||||
}
|
||||
|
||||
@@ -620,22 +621,22 @@ void Balloon::setSpeed(float speed) {
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int Balloon::getKind() {
|
||||
auto Balloon::getKind() const -> int {
|
||||
return kind;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint8 Balloon::getSize() {
|
||||
auto Balloon::getSize() const -> Uint8 {
|
||||
return size;
|
||||
}
|
||||
|
||||
// Obtiene la clase a la que pertenece el globo
|
||||
Uint8 Balloon::getClass() {
|
||||
auto Balloon::getClass() const -> Uint8 {
|
||||
if ((kind >= BALLOON_1) && (kind <= BALLOON_4)) {
|
||||
return BALLOON_CLASS;
|
||||
}
|
||||
|
||||
else if ((kind >= HEXAGON_1) && (kind <= HEXAGON_4)) {
|
||||
if ((kind >= HEXAGON_1) && (kind <= HEXAGON_4)) {
|
||||
return HEXAGON_CLASS;
|
||||
}
|
||||
|
||||
@@ -648,7 +649,7 @@ void Balloon::setStop(bool state) {
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool Balloon::isStopped() {
|
||||
auto Balloon::isStopped() const -> bool {
|
||||
return stopped;
|
||||
}
|
||||
|
||||
@@ -658,7 +659,7 @@ void Balloon::setBlink(bool value) {
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool Balloon::isBlinking() {
|
||||
auto Balloon::isBlinking() const -> bool {
|
||||
return blinking;
|
||||
}
|
||||
|
||||
@@ -668,7 +669,7 @@ void Balloon::setVisible(bool value) {
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool Balloon::isVisible() {
|
||||
auto Balloon::isVisible() const -> bool {
|
||||
return visible;
|
||||
}
|
||||
|
||||
@@ -678,7 +679,7 @@ void Balloon::setInvulnerable(bool value) {
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool Balloon::isInvulnerable() {
|
||||
auto Balloon::isInvulnerable() const -> bool {
|
||||
return invulnerable;
|
||||
}
|
||||
|
||||
@@ -688,7 +689,7 @@ void Balloon::setBeingCreated(bool value) {
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool Balloon::isBeingCreated() {
|
||||
auto Balloon::isBeingCreated() const -> bool {
|
||||
return beingCreated;
|
||||
}
|
||||
|
||||
@@ -698,7 +699,7 @@ void Balloon::setPopping(bool value) {
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool Balloon::isPopping() {
|
||||
auto Balloon::isPopping() const -> bool {
|
||||
return popping;
|
||||
}
|
||||
|
||||
@@ -708,17 +709,17 @@ void Balloon::setStoppedTimer(Uint16 time) {
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint16 Balloon::getStoppedTimer() {
|
||||
auto Balloon::getStoppedTimer() const -> Uint16 {
|
||||
return stoppedCounter;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint16 Balloon::getScore() {
|
||||
auto Balloon::getScore() const -> Uint16 {
|
||||
return score;
|
||||
}
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &Balloon::getCollider() {
|
||||
auto Balloon::getCollider() -> circle_t & {
|
||||
return collider;
|
||||
}
|
||||
|
||||
@@ -729,16 +730,15 @@ void Balloon::updateColliders() {
|
||||
}
|
||||
|
||||
// Obtiene le valor de la variable
|
||||
Uint8 Balloon::getMenace() {
|
||||
auto Balloon::getMenace() const -> Uint8 {
|
||||
if (isEnabled()) {
|
||||
return menace;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Obtiene le valor de la variable
|
||||
Uint8 Balloon::getPower() {
|
||||
auto Balloon::getPower() const -> Uint8 {
|
||||
return power;
|
||||
}
|
||||
|
||||
@@ -755,12 +755,12 @@ void Balloon::bounceStart() {
|
||||
void Balloon::bounceStop() {
|
||||
bouncing.enabled = false;
|
||||
bouncing.counter = 0;
|
||||
bouncing.zoomW = 1.0f;
|
||||
bouncing.zoomH = 1.0f;
|
||||
bouncing.zoomW = 1.0F;
|
||||
bouncing.zoomH = 1.0F;
|
||||
sprite->setZoomW(bouncing.zoomW);
|
||||
sprite->setZoomH(bouncing.zoomH);
|
||||
bouncing.despX = 0.0f;
|
||||
bouncing.despY = 0.0f;
|
||||
bouncing.despX = 0.0F;
|
||||
bouncing.despY = 0.0F;
|
||||
}
|
||||
|
||||
void Balloon::updateBounce() {
|
||||
|
||||
@@ -40,8 +40,8 @@ constexpr int BALLOON_CLASS = 0;
|
||||
constexpr int HEXAGON_CLASS = 1;
|
||||
|
||||
// Velocidad del globo
|
||||
constexpr float BALLOON_VELX_POSITIVE = 0.7f;
|
||||
constexpr float BALLOON_VELX_NEGATIVE = -0.7f;
|
||||
constexpr float BALLOON_VELX_POSITIVE = 0.7F;
|
||||
constexpr float BALLOON_VELX_NEGATIVE = -0.7F;
|
||||
|
||||
// Índice para las animaciones de los globos
|
||||
constexpr int BALLOON_MOVING_ANIMATION = 0;
|
||||
@@ -52,11 +52,11 @@ constexpr int BALLOON_BORN_ANIMATION = 2;
|
||||
constexpr int MAX_BALLOONS = 100;
|
||||
|
||||
// Velocidades a las que se mueven los globos
|
||||
constexpr float BALLOON_SPEED_1 = 0.60f;
|
||||
constexpr float BALLOON_SPEED_2 = 0.70f;
|
||||
constexpr float BALLOON_SPEED_3 = 0.80f;
|
||||
constexpr float BALLOON_SPEED_4 = 0.90f;
|
||||
constexpr float BALLOON_SPEED_5 = 1.00f;
|
||||
constexpr float BALLOON_SPEED_1 = 0.60F;
|
||||
constexpr float BALLOON_SPEED_2 = 0.70F;
|
||||
constexpr float BALLOON_SPEED_3 = 0.80F;
|
||||
constexpr float BALLOON_SPEED_4 = 0.90F;
|
||||
constexpr float BALLOON_SPEED_5 = 1.00F;
|
||||
|
||||
// Tamaño de los globos
|
||||
constexpr int BALLOON_WIDTH_1 = 8;
|
||||
@@ -147,7 +147,7 @@ class Balloon {
|
||||
~Balloon();
|
||||
|
||||
Balloon(const Balloon &) = delete;
|
||||
Balloon &operator=(const Balloon &) = delete;
|
||||
auto operator=(const Balloon &) -> Balloon & = delete;
|
||||
|
||||
// Centra el globo en la posición X
|
||||
void allignTo(int x);
|
||||
@@ -168,22 +168,22 @@ class Balloon {
|
||||
void update();
|
||||
|
||||
// Comprueba si el globo está habilitado
|
||||
bool isEnabled();
|
||||
[[nodiscard]] auto isEnabled() const -> bool;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float getPosX();
|
||||
[[nodiscard]] auto getPosX() const -> float;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float getPosY();
|
||||
[[nodiscard]] auto getPosY() const -> float;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float getVelY();
|
||||
[[nodiscard]] auto getVelY() const -> float;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getWidth();
|
||||
[[nodiscard]] auto getWidth() const -> int;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getHeight();
|
||||
[[nodiscard]] auto getHeight() const -> int;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelY(float velY);
|
||||
@@ -192,62 +192,62 @@ class Balloon {
|
||||
void setSpeed(float speed);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getKind();
|
||||
[[nodiscard]] auto getKind() const -> int;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint8 getSize();
|
||||
[[nodiscard]] auto getSize() const -> Uint8;
|
||||
|
||||
// Obtiene la clase a la que pertenece el globo
|
||||
Uint8 getClass();
|
||||
[[nodiscard]] auto getClass() const -> Uint8;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setStop(bool value);
|
||||
void setStop(bool state);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isStopped();
|
||||
[[nodiscard]] auto isStopped() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setBlink(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isBlinking();
|
||||
[[nodiscard]] auto isBlinking() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVisible(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isVisible();
|
||||
[[nodiscard]] auto isVisible() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setInvulnerable(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isInvulnerable();
|
||||
[[nodiscard]] auto isInvulnerable() const -> bool;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isBeingCreated();
|
||||
[[nodiscard]] auto isBeingCreated() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPopping(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isPopping();
|
||||
[[nodiscard]] auto isPopping() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setStoppedTimer(Uint16 time);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint16 getStoppedTimer();
|
||||
[[nodiscard]] auto getStoppedTimer() const -> Uint16;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint16 getScore();
|
||||
[[nodiscard]] auto getScore() const -> Uint16;
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &getCollider();
|
||||
auto getCollider() -> circle_t &;
|
||||
|
||||
// Obtiene le valor de la variable
|
||||
Uint8 getMenace();
|
||||
[[nodiscard]] auto getMenace() const -> Uint8;
|
||||
|
||||
// Obtiene le valor de la variable
|
||||
Uint8 getPower();
|
||||
[[nodiscard]] auto getPower() const -> Uint8;
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "game/entities/bullet.h"
|
||||
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "game/defaults.hpp" // for NO_KIND, PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_A...
|
||||
#include "game/defaults.hpp" // for BulletKind::NONE, PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_A...
|
||||
class Texture;
|
||||
|
||||
// Constructor
|
||||
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer) {
|
||||
Bullet::Bullet(int x, int y, BulletKind kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer) {
|
||||
sprite = new Sprite({x, y, 10, 10}, texture, renderer);
|
||||
|
||||
// Posición inicial del objeto
|
||||
@@ -27,7 +27,7 @@ Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *textu
|
||||
|
||||
// Valores especificos según el tipo
|
||||
switch (kind) {
|
||||
case BULLET_UP:
|
||||
case BulletKind::UP:
|
||||
// Establece la velocidad inicial
|
||||
velX = 0;
|
||||
|
||||
@@ -39,7 +39,7 @@ Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *textu
|
||||
}
|
||||
break;
|
||||
|
||||
case BULLET_LEFT:
|
||||
case BulletKind::LEFT:
|
||||
// Establece la velocidad inicial
|
||||
velX = -2;
|
||||
|
||||
@@ -51,7 +51,7 @@ Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *textu
|
||||
}
|
||||
break;
|
||||
|
||||
case BULLET_RIGHT:
|
||||
case BulletKind::RIGHT:
|
||||
// Establece la velocidad inicial
|
||||
velX = 2;
|
||||
|
||||
@@ -85,7 +85,7 @@ void Bullet::render() {
|
||||
}
|
||||
|
||||
// Actualiza la posición y estado del objeto en horizontal
|
||||
Uint8 Bullet::move() {
|
||||
auto Bullet::move() -> Uint8 {
|
||||
// Variable con el valor de retorno
|
||||
Uint8 msg = BULLET_MOVE_OK;
|
||||
|
||||
@@ -95,19 +95,19 @@ Uint8 Bullet::move() {
|
||||
// Si el objeto se sale del area de juego por los laterales
|
||||
if ((posX < PLAY_AREA_LEFT - width) || (posX > PLAY_AREA_RIGHT)) {
|
||||
// Se deshabilita
|
||||
kind = NO_KIND;
|
||||
kind = BulletKind::NONE;
|
||||
|
||||
// Mensaje de salida
|
||||
msg = BULLET_MOVE_OUT;
|
||||
}
|
||||
|
||||
// Mueve el objeto a su nueva posición en vertical
|
||||
posY += int(velY);
|
||||
posY += velY;
|
||||
|
||||
// Si el objeto se sale del area de juego por la parte superior
|
||||
if (posY < PLAY_AREA_TOP - height) {
|
||||
// Se deshabilita
|
||||
kind = NO_KIND;
|
||||
kind = BulletKind::NONE;
|
||||
|
||||
// Mensaje de salida
|
||||
msg = BULLET_MOVE_OUT;
|
||||
@@ -124,26 +124,22 @@ Uint8 Bullet::move() {
|
||||
}
|
||||
|
||||
// Comprueba si el objeto está habilitado
|
||||
bool Bullet::isEnabled() {
|
||||
if (kind == NO_KIND) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
auto Bullet::isEnabled() const -> bool {
|
||||
return kind != BulletKind::NONE;
|
||||
}
|
||||
|
||||
// Deshabilita el objeto
|
||||
void Bullet::disable() {
|
||||
kind = NO_KIND;
|
||||
kind = BulletKind::NONE;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getPosX() {
|
||||
auto Bullet::getPosX() const -> int {
|
||||
return posX;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getPosY() {
|
||||
auto Bullet::getPosY() const -> int {
|
||||
return posY;
|
||||
}
|
||||
|
||||
@@ -158,22 +154,22 @@ void Bullet::setPosY(int y) {
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getVelY() {
|
||||
auto Bullet::getVelY() const -> int {
|
||||
return velY;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getKind() {
|
||||
auto Bullet::getKind() const -> BulletKind {
|
||||
return kind;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int Bullet::getOwner() {
|
||||
auto Bullet::getOwner() const -> int {
|
||||
return owner;
|
||||
}
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &Bullet::getCollider() {
|
||||
auto Bullet::getCollider() -> circle_t & {
|
||||
return collider;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,19 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <cstdint> // for uint8_t
|
||||
#include "utils/utils.h" // for circle_t
|
||||
class Sprite;
|
||||
class Texture;
|
||||
|
||||
// Tipos de bala
|
||||
constexpr int BULLET_UP = 1;
|
||||
constexpr int BULLET_LEFT = 2;
|
||||
constexpr int BULLET_RIGHT = 3;
|
||||
// Tipus de bala. Enum class fortament tipat per evitar confusió accidental
|
||||
// amb altres `int`/`Uint8` (p.ex. el `owner` a `createBullet`).
|
||||
enum class BulletKind : std::uint8_t {
|
||||
NONE = 0, // bala desactivada / fora de pantalla
|
||||
UP = 1,
|
||||
LEFT = 2,
|
||||
RIGHT = 3,
|
||||
};
|
||||
|
||||
// Tipos de retorno de la función move de la bala
|
||||
constexpr int BULLET_MOVE_OK = 0;
|
||||
@@ -28,7 +33,7 @@ class Bullet {
|
||||
Uint8 height; // Alto del objeto
|
||||
int velX; // Velocidad en el eje X
|
||||
int velY; // Velocidad en el eje Y
|
||||
int kind; // Tipo de objeto
|
||||
BulletKind kind; // Tipo de objeto
|
||||
int owner; // Identificador del dueño del objeto
|
||||
circle_t collider; // Circulo de colisión del objeto
|
||||
|
||||
@@ -37,31 +42,31 @@ class Bullet {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer);
|
||||
Bullet(int x, int y, BulletKind kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Bullet();
|
||||
|
||||
Bullet(const Bullet &) = delete;
|
||||
Bullet &operator=(const Bullet &) = delete;
|
||||
auto operator=(const Bullet &) -> Bullet & = delete;
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
void render();
|
||||
|
||||
// Actualiza la posición y estado del objeto
|
||||
Uint8 move();
|
||||
auto move() -> Uint8;
|
||||
|
||||
// Comprueba si el objeto está habilitado
|
||||
bool isEnabled();
|
||||
[[nodiscard]] auto isEnabled() const -> bool;
|
||||
|
||||
// Deshabilita el objeto
|
||||
void disable();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getPosX();
|
||||
[[nodiscard]] auto getPosX() const -> int;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getPosY();
|
||||
[[nodiscard]] auto getPosY() const -> int;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(int x);
|
||||
@@ -70,14 +75,14 @@ class Bullet {
|
||||
void setPosY(int y);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getVelY();
|
||||
[[nodiscard]] auto getVelY() const -> int;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getKind();
|
||||
[[nodiscard]] auto getKind() const -> BulletKind;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getOwner();
|
||||
[[nodiscard]] auto getOwner() const -> int;
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &getCollider();
|
||||
auto getCollider() -> circle_t &;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "game/entities/item.h"
|
||||
|
||||
#include <stdlib.h> // for rand
|
||||
#include <cstdlib> // for rand
|
||||
|
||||
#include "core/rendering/animatedsprite.h" // for AnimatedSprite
|
||||
#include "game/defaults.hpp" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_AR...
|
||||
@@ -13,7 +13,7 @@ Item::Item(Uint8 kind, float x, float y, Texture *texture, std::vector<std::stri
|
||||
this->kind = kind;
|
||||
enabled = true;
|
||||
timeToLive = 600;
|
||||
accelX = 0.0f;
|
||||
accelX = 0.0F;
|
||||
floorCollision = false;
|
||||
|
||||
if (kind == ITEM_COFFEE_MACHINE) {
|
||||
@@ -21,18 +21,18 @@ Item::Item(Uint8 kind, float x, float y, Texture *texture, std::vector<std::stri
|
||||
height = 29;
|
||||
posX = (((int)x + (PLAY_AREA_WIDTH / 2)) % (PLAY_AREA_WIDTH - width - 5)) + 2;
|
||||
posY = PLAY_AREA_TOP - height;
|
||||
velX = 0.0f;
|
||||
velY = -0.1f;
|
||||
accelY = 0.1f;
|
||||
velX = 0.0F;
|
||||
velY = -0.1F;
|
||||
accelY = 0.1F;
|
||||
collider.r = 10;
|
||||
} else {
|
||||
width = 16;
|
||||
height = 16;
|
||||
posX = x;
|
||||
posY = y;
|
||||
velX = -1.0f + ((rand() % 5) * 0.5f);
|
||||
velY = -4.0f;
|
||||
accelY = 0.2f;
|
||||
velX = -1.0F + ((rand() % 5) * 0.5F);
|
||||
velY = -4.0F;
|
||||
accelY = 0.2F;
|
||||
collider.r = width / 2;
|
||||
}
|
||||
|
||||
@@ -66,12 +66,10 @@ void Item::allignTo(int x) {
|
||||
|
||||
// Pinta el objeto en la pantalla
|
||||
void Item::render() {
|
||||
if (enabled) {
|
||||
if (timeToLive > 200) {
|
||||
sprite->render();
|
||||
} else if (timeToLive % 20 > 10) {
|
||||
sprite->render();
|
||||
}
|
||||
// Mentre quede temps de sobra (>200) es renderitza sempre; quan està a
|
||||
// punt d'expirar, parpalleja alternant 10 frames visibles i 10 invisibles.
|
||||
if (enabled && (timeToLive > 200 || timeToLive % 20 > 10)) {
|
||||
sprite->render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,42 +144,43 @@ void Item::updateTimeToLive() {
|
||||
|
||||
// Comprueba si el objeto sigue vivo
|
||||
void Item::checkTimeToLive() {
|
||||
if (timeToLive == 0)
|
||||
if (timeToLive == 0) {
|
||||
disable();
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float Item::getPosX() {
|
||||
auto Item::getPosX() const -> float {
|
||||
return posX;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float Item::getPosY() {
|
||||
auto Item::getPosY() const -> float {
|
||||
return posY;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int Item::getWidth() {
|
||||
auto Item::getWidth() const -> int {
|
||||
return width;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int Item::getHeight() {
|
||||
auto Item::getHeight() const -> int {
|
||||
return height;
|
||||
}
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int Item::getClass() {
|
||||
auto Item::getClass() const -> int {
|
||||
return kind;
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool Item::isEnabled() {
|
||||
auto Item::isEnabled() const -> bool {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &Item::getCollider() {
|
||||
auto Item::getCollider() -> circle_t & {
|
||||
return collider;
|
||||
}
|
||||
|
||||
@@ -192,6 +191,6 @@ void Item::shiftColliders() {
|
||||
}
|
||||
|
||||
// Informa si el objeto ha colisionado con el suelo
|
||||
bool Item::isOnFloor() {
|
||||
auto Item::isOnFloor() const -> bool {
|
||||
return floorCollision;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class Item {
|
||||
~Item();
|
||||
|
||||
Item(const Item &) = delete;
|
||||
Item &operator=(const Item &) = delete;
|
||||
auto operator=(const Item &) -> Item & = delete;
|
||||
|
||||
// Centra el objeto en la posición X
|
||||
void allignTo(int x);
|
||||
@@ -74,26 +74,26 @@ class Item {
|
||||
void checkTimeToLive();
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float getPosX();
|
||||
[[nodiscard]] auto getPosX() const -> float;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float getPosY();
|
||||
[[nodiscard]] auto getPosY() const -> float;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getWidth();
|
||||
[[nodiscard]] auto getWidth() const -> int;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getHeight();
|
||||
[[nodiscard]] auto getHeight() const -> int;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getClass();
|
||||
[[nodiscard]] auto getClass() const -> int;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isEnabled();
|
||||
[[nodiscard]] auto isEnabled() const -> bool;
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &getCollider();
|
||||
auto getCollider() -> circle_t &;
|
||||
|
||||
// Informa si el objeto ha colisionado con el suelo
|
||||
bool isOnFloor();
|
||||
[[nodiscard]] auto isOnFloor() const -> bool;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class Player {
|
||||
~Player();
|
||||
|
||||
Player(const Player &) = delete;
|
||||
Player &operator=(const Player &) = delete;
|
||||
auto operator=(const Player &) -> Player & = delete;
|
||||
|
||||
// Iniciador
|
||||
void init();
|
||||
@@ -117,19 +117,19 @@ class Player {
|
||||
void setAnimation();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getPosX();
|
||||
[[nodiscard]] auto getPosX() const -> int;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getPosY();
|
||||
[[nodiscard]] auto getPosY() const -> int;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getWidth();
|
||||
[[nodiscard]] auto getWidth() const -> int;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getHeight();
|
||||
[[nodiscard]] auto getHeight() const -> int;
|
||||
|
||||
// Indica si el jugador puede disparar
|
||||
bool canFire();
|
||||
[[nodiscard]] auto canFire() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setFireCooldown(int time);
|
||||
@@ -138,7 +138,7 @@ class Player {
|
||||
void updateCooldown();
|
||||
|
||||
// Obtiene la puntuación del jugador
|
||||
Uint32 getScore();
|
||||
[[nodiscard]] auto getScore() const -> Uint32;
|
||||
|
||||
// Asigna un valor a la puntuación del jugador
|
||||
void setScore(Uint32 score);
|
||||
@@ -147,13 +147,13 @@ class Player {
|
||||
void addScore(Uint32 score);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isAlive();
|
||||
[[nodiscard]] auto isAlive() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAlive(bool value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
float getScoreMultiplier();
|
||||
[[nodiscard]] auto getScoreMultiplier() const -> float;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setScoreMultiplier(float value);
|
||||
@@ -165,25 +165,25 @@ class Player {
|
||||
void decScoreMultiplier();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isInvulnerable();
|
||||
[[nodiscard]] auto isInvulnerable() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setInvulnerable(bool value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getInvulnerableCounter();
|
||||
[[nodiscard]] auto getInvulnerableCounter() const -> Uint16;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setInvulnerableCounter(Uint16 value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isPowerUp();
|
||||
[[nodiscard]] auto isPowerUp() const -> bool;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPowerUp(bool value);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getPowerUpCounter();
|
||||
[[nodiscard]] auto getPowerUpCounter() const -> Uint16;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPowerUpCounter(Uint16 value);
|
||||
@@ -192,7 +192,7 @@ class Player {
|
||||
void updatePowerUpCounter();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool hasExtraHit();
|
||||
[[nodiscard]] auto hasExtraHit() const -> bool;
|
||||
|
||||
// Concede un toque extra al jugador
|
||||
void giveExtraHit();
|
||||
@@ -207,14 +207,14 @@ class Player {
|
||||
void disableInput();
|
||||
|
||||
// Devuelve el numero de cafes actuales
|
||||
Uint8 getCoffees();
|
||||
[[nodiscard]] auto getCoffees() const -> Uint8;
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &getCollider();
|
||||
auto getCollider() -> circle_t &;
|
||||
|
||||
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
||||
Texture *getDeadTexture();
|
||||
auto getDeadTexture() -> Texture *;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getDeathCounter();
|
||||
[[nodiscard]] auto getDeathCounter() const -> Uint16;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user