Arreglos varios al codi
This commit is contained in:
125
source/balloon.h
125
source/balloon.h
@@ -3,75 +3,76 @@
|
||||
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint16, Uint32
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
#include <memory>
|
||||
#include "utils.h" // for circle_t
|
||||
class AnimatedSprite;
|
||||
#include "animated_sprite.h"
|
||||
class Texture;
|
||||
|
||||
// Cantidad de elementos del vector con los valores de la deformación del globo al rebotar
|
||||
#define MAX_BOUNCE 10
|
||||
constexpr int MAX_BOUNCE = 10;
|
||||
|
||||
// Tipos de globo
|
||||
#define BALLOON_1 1
|
||||
#define BALLOON_2 2
|
||||
#define BALLOON_3 3
|
||||
#define BALLOON_4 4
|
||||
#define HEXAGON_1 5
|
||||
#define HEXAGON_2 6
|
||||
#define HEXAGON_3 7
|
||||
#define HEXAGON_4 8
|
||||
#define POWER_BALL 9
|
||||
constexpr int BALLOON_1 = 1;
|
||||
constexpr int BALLOON_2 = 2;
|
||||
constexpr int BALLOON_3 = 3;
|
||||
constexpr int BALLOON_4 = 4;
|
||||
constexpr int HEXAGON_1 = 5;
|
||||
constexpr int HEXAGON_2 = 6;
|
||||
constexpr int HEXAGON_3 = 7;
|
||||
constexpr int HEXAGON_4 = 8;
|
||||
constexpr int POWER_BALL = 9;
|
||||
|
||||
// Puntos de globo
|
||||
#define BALLOON_SCORE_1 50
|
||||
#define BALLOON_SCORE_2 100
|
||||
#define BALLOON_SCORE_3 200
|
||||
#define BALLOON_SCORE_4 400
|
||||
constexpr int BALLOON_SCORE_1 = 50;
|
||||
constexpr int BALLOON_SCORE_2 = 100;
|
||||
constexpr int BALLOON_SCORE_3 = 200;
|
||||
constexpr int BALLOON_SCORE_4 = 400;
|
||||
|
||||
// Tamaños de globo
|
||||
#define BALLOON_SIZE_1 1
|
||||
#define BALLOON_SIZE_2 2
|
||||
#define BALLOON_SIZE_3 3
|
||||
#define BALLOON_SIZE_4 4
|
||||
constexpr int BALLOON_SIZE_1 = 1;
|
||||
constexpr int BALLOON_SIZE_2 = 2;
|
||||
constexpr int BALLOON_SIZE_3 = 3;
|
||||
constexpr int BALLOON_SIZE_4 = 4;
|
||||
|
||||
// Clases de globo
|
||||
#define BALLOON_CLASS 0
|
||||
#define HEXAGON_CLASS 1
|
||||
constexpr int BALLOON_CLASS = 0;
|
||||
constexpr int HEXAGON_CLASS = 1;
|
||||
|
||||
// Velocidad del globo
|
||||
#define BALLOON_VELX_POSITIVE 0.7f
|
||||
#define BALLOON_VELX_NEGATIVE -0.7f
|
||||
constexpr float BALLOON_VELX_POSITIVE = 0.7f;
|
||||
constexpr float BALLOON_VELX_NEGATIVE = -0.7f;
|
||||
|
||||
// Indice para las animaciones de los globos
|
||||
#define BALLOON_MOVING_ANIMATION 0
|
||||
#define BALLOON_POP_ANIMATION 1
|
||||
#define BALLOON_BORN_ANIMATION 2
|
||||
constexpr int BALLOON_MOVING_ANIMATION = 0;
|
||||
constexpr int BALLOON_POP_ANIMATION = 1;
|
||||
constexpr int BALLOON_BORN_ANIMATION = 2;
|
||||
|
||||
// Cantidad posible de globos
|
||||
#define MAX_BALLOONS 100
|
||||
constexpr int MAX_BALLOONS = 100;
|
||||
|
||||
// Velocidades a las que se mueven los globos
|
||||
#define BALLOON_SPEED_1 0.60f
|
||||
#define BALLOON_SPEED_2 0.70f
|
||||
#define BALLOON_SPEED_3 0.80f
|
||||
#define BALLOON_SPEED_4 0.90f
|
||||
#define 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
|
||||
#define BALLOON_WIDTH_1 10
|
||||
#define BALLOON_WIDTH_2 16
|
||||
#define BALLOON_WIDTH_3 26
|
||||
#define BALLOON_WIDTH_4 46
|
||||
constexpr int BALLOON_WIDTH_1 = 10;
|
||||
constexpr int BALLOON_WIDTH_2 = 16;
|
||||
constexpr int BALLOON_WIDTH_3 = 26;
|
||||
constexpr int BALLOON_WIDTH_4 = 46;
|
||||
|
||||
// PowerBall
|
||||
#define POWERBALL_SCREENPOWER_MINIMUM 10
|
||||
#define POWERBALL_COUNTER 8
|
||||
constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10;
|
||||
constexpr int POWERBALL_COUNTER = 8;
|
||||
|
||||
// Clase Balloon
|
||||
class Balloon
|
||||
{
|
||||
private:
|
||||
// Estructura para las variables para el efecto de los rebotes
|
||||
struct bouncing
|
||||
struct Bouncing
|
||||
{
|
||||
bool enabled; // Si el efecto está activo
|
||||
Uint8 counter; // Countador para el efecto
|
||||
@@ -85,7 +86,7 @@ private:
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
AnimatedSprite *sprite; // Sprite del objeto globo
|
||||
std::unique_ptr<AnimatedSprite> sprite; // Sprite del objeto globo
|
||||
|
||||
// Variables
|
||||
float posX; // Posición en el eje X
|
||||
@@ -115,7 +116,7 @@ private:
|
||||
float speed; // Velocidad a la que se mueven los globos
|
||||
Uint8 size; // Tamaño del globo
|
||||
Uint8 power; // Cantidad de poder que alberga el globo
|
||||
bouncing bouncing; // Contiene las variables para el efecto de rebote
|
||||
Bouncing bouncing; // Contiene las variables para el efecto de rebote
|
||||
|
||||
// Alinea el circulo de colisión con la posición del objeto globo
|
||||
void updateColliders();
|
||||
@@ -143,7 +144,7 @@ public:
|
||||
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation);
|
||||
|
||||
// Destructor
|
||||
~Balloon();
|
||||
~Balloon() = default;
|
||||
|
||||
// Centra el globo en la posición X
|
||||
void allignTo(int x);
|
||||
@@ -164,22 +165,22 @@ public:
|
||||
void update();
|
||||
|
||||
// Comprueba si el globo está habilitado
|
||||
bool isEnabled();
|
||||
bool isEnabled() const;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float getPosX();
|
||||
float getPosX() const;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float getPosY();
|
||||
float getPosY() const;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
float getVelY();
|
||||
float getVelY() const;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getWidth();
|
||||
int getWidth() const;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getHeight();
|
||||
int getHeight() const;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelY(float velY);
|
||||
@@ -188,62 +189,62 @@ public:
|
||||
void setSpeed(float speed);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
int getKind();
|
||||
int getKind() const;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint8 getSize();
|
||||
Uint8 getSize() const;
|
||||
|
||||
// Obtiene la clase a la que pertenece el globo
|
||||
Uint8 getClass();
|
||||
Uint8 getClass() const;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setStop(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isStopped();
|
||||
bool isStopped() const;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setBlink(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isBlinking();
|
||||
bool isBlinking() const;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVisible(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isVisible();
|
||||
bool isVisible() const;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setInvulnerable(bool value);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isInvulnerable();
|
||||
bool isInvulnerable() const;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
bool isBeingCreated();
|
||||
bool isBeingCreated() const;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setStoppedTimer(Uint16 time);
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint16 getStoppedTimer();
|
||||
Uint16 getStoppedTimer() const;
|
||||
|
||||
// Obtiene del valor de la variable
|
||||
Uint16 getScore();
|
||||
Uint16 getScore() const;
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &getCollider();
|
||||
|
||||
// Obtiene le valor de la variable
|
||||
Uint8 getMenace();
|
||||
Uint8 getMenace() const;
|
||||
|
||||
// Obtiene le valor de la variable
|
||||
Uint8 getPower();
|
||||
Uint8 getPower() const;
|
||||
|
||||
// Indica si el globo se puede explotar
|
||||
bool canBePopped();
|
||||
bool canBePopped() const;
|
||||
|
||||
// Indica si el globo se puede destruir
|
||||
bool canBeDestroyed();
|
||||
bool canBeDestroyed() const;
|
||||
};
|
||||
Reference in New Issue
Block a user