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() {
|
||||
|
||||
Reference in New Issue
Block a user