eliminat el punter al renderer de 50.000 llocs
@@ -1,37 +1,16 @@
|
|||||||
frameWidth=8
|
frameWidth=10
|
||||||
frameHeight=8
|
frameHeight=10
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=orange
|
name=normal
|
||||||
speed=10
|
speed=10
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=blue
|
name=stopped
|
||||||
speed=20
|
speed=20
|
||||||
loop=0
|
loop=0
|
||||||
frames=12,13,14,15,16,17,18,19,20,21
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=green
|
|
||||||
speed=10
|
|
||||||
loop=0
|
|
||||||
frames=24,25,26,27,28,29,30,31,32,33
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=red
|
|
||||||
speed=20
|
|
||||||
loop=0
|
|
||||||
frames=36,37,38,39,40,41,42,43,44,45
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=pop
|
|
||||||
speed=5
|
|
||||||
loop=-1
|
|
||||||
frames=48,49,50,51,52,53,54,55,56,57,58,59
|
|
||||||
[/animation]
|
[/animation]
|
||||||
BIN
data/gfx/balloon1.gif
Normal file
|
After Width: | Height: | Size: 265 B |
|
Before Width: | Height: | Size: 1.8 KiB |
9
data/gfx/balloon1_explosion.ani
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
frameWidth=10
|
||||||
|
frameHeight=10
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=default
|
||||||
|
speed=5
|
||||||
|
loop=-1
|
||||||
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
|
[/animation]
|
||||||
BIN
data/gfx/balloon1_explosion.png
Normal file
|
After Width: | Height: | Size: 760 B |
@@ -1,37 +1,16 @@
|
|||||||
frameWidth=13
|
frameWidth=16
|
||||||
frameHeight=13
|
frameHeight=16
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=orange
|
name=normal
|
||||||
speed=10
|
speed=10
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=blue
|
name=stopped
|
||||||
speed=20
|
speed=20
|
||||||
loop=0
|
loop=0
|
||||||
frames=12,13,14,15,16,17,18,19,20,21
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=green
|
|
||||||
speed=10
|
|
||||||
loop=0
|
|
||||||
frames=24,25,26,27,28,29,30,31,32,33
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=red
|
|
||||||
speed=20
|
|
||||||
loop=0
|
|
||||||
frames=36,37,38,39,40,41,42,43,44,45
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=pop
|
|
||||||
speed=5
|
|
||||||
loop=-1
|
|
||||||
frames=48,49,50,51,52,53,54,55,56,57,58,59
|
|
||||||
[/animation]
|
[/animation]
|
||||||
BIN
data/gfx/balloon2.gif
Normal file
|
After Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 4.5 KiB |
9
data/gfx/balloon2_explosion.ani
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
frameWidth=16
|
||||||
|
frameHeight=16
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=default
|
||||||
|
speed=5
|
||||||
|
loop=-1
|
||||||
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
|
[/animation]
|
||||||
BIN
data/gfx/balloon2_explosion.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
@@ -1,37 +1,16 @@
|
|||||||
frameWidth=21
|
frameWidth=26
|
||||||
frameHeight=21
|
frameHeight=26
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=orange
|
name=normal
|
||||||
speed=10
|
speed=10
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=blue
|
name=stopped
|
||||||
speed=20
|
speed=20
|
||||||
loop=0
|
loop=0
|
||||||
frames=12,13,14,15,16,17,18,19,20,21
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=green
|
|
||||||
speed=10
|
|
||||||
loop=0
|
|
||||||
frames=24,25,26,27,28,29,30,31,32,33
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=red
|
|
||||||
speed=20
|
|
||||||
loop=0
|
|
||||||
frames=36,37,38,39,40,41,42,43,44,45
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=pop
|
|
||||||
speed=5
|
|
||||||
loop=-1
|
|
||||||
frames=48,49,50,51,52,53,54,55,56,57,58,59
|
|
||||||
[/animation]
|
[/animation]
|
||||||
BIN
data/gfx/balloon3.gif
Normal file
|
After Width: | Height: | Size: 908 B |
|
Before Width: | Height: | Size: 6.1 KiB |
9
data/gfx/balloon3_explosion.ani
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
frameWidth=26
|
||||||
|
frameHeight=26
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=default
|
||||||
|
speed=5
|
||||||
|
loop=-1
|
||||||
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
|
[/animation]
|
||||||
BIN
data/gfx/balloon3_explosion.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
@@ -1,44 +1,16 @@
|
|||||||
frameWidth=37
|
frameWidth=46
|
||||||
frameHeight=37
|
frameHeight=46
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=orange
|
name=normal
|
||||||
speed=10
|
speed=10
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=blue
|
name=stopped
|
||||||
speed=20
|
speed=20
|
||||||
loop=0
|
loop=0
|
||||||
frames=12,13,14,15,16,17,18,19,20,21
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=green
|
|
||||||
speed=10
|
|
||||||
loop=0
|
|
||||||
frames=24,25,26,27,28,29,30,31,32,33
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=red
|
|
||||||
speed=20
|
|
||||||
loop=0
|
|
||||||
frames=36,37,38,39,40,41,42,43,44,45
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=powerball
|
|
||||||
speed=10
|
|
||||||
loop=0
|
|
||||||
frames=10
|
|
||||||
[/animation]
|
|
||||||
|
|
||||||
[animation]
|
|
||||||
name=pop
|
|
||||||
speed=5
|
|
||||||
loop=-1
|
|
||||||
frames=48,49,50,51,52,53,54,55,56,57,58,59
|
|
||||||
[/animation]
|
[/animation]
|
||||||
BIN
data/gfx/balloon4.gif
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 13 KiB |
9
data/gfx/balloon4_explosion.ani
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
frameWidth=46
|
||||||
|
frameHeight=46
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=default
|
||||||
|
speed=5
|
||||||
|
loop=-1
|
||||||
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
|
[/animation]
|
||||||
BIN
data/gfx/balloon4_explosion.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
data/gfx/balloon_blue_pal.gif
Normal file
|
After Width: | Height: | Size: 69 B |
BIN
data/gfx/balloon_green_pal.gif
Normal file
|
After Width: | Height: | Size: 69 B |
BIN
data/gfx/balloon_yellow_pal.gif
Normal file
|
After Width: | Height: | Size: 69 B |
BIN
data/gfx/powerball.png
Normal file
|
After Width: | Height: | Size: 536 B |
@@ -39,15 +39,15 @@ Background::Background(SDL_Renderer *renderer, Screen *screen, Asset *asset, par
|
|||||||
const int clouds2y = base - 101;
|
const int clouds2y = base - 101;
|
||||||
const float clouds1speed = 0.1f;
|
const float clouds1speed = 0.1f;
|
||||||
const float clouds2speed = 0.05f;
|
const float clouds2speed = 0.05f;
|
||||||
clouds1A = new MovingSprite(0, clouds1y, rect.w, clouds1Texture->getHeight(), -clouds1speed, 0.0f, 0.0f, 0.0f, clouds1Texture, renderer);
|
clouds1A = new MovingSprite(0, clouds1y, rect.w, clouds1Texture->getHeight(), -clouds1speed, 0.0f, 0.0f, 0.0f, clouds1Texture);
|
||||||
clouds1B = new MovingSprite(rect.w, clouds1y, rect.w, clouds1Texture->getHeight(), -clouds1speed, 0.0f, 0.0f, 0.0f, clouds1Texture, renderer);
|
clouds1B = new MovingSprite(rect.w, clouds1y, rect.w, clouds1Texture->getHeight(), -clouds1speed, 0.0f, 0.0f, 0.0f, clouds1Texture);
|
||||||
|
|
||||||
clouds2A = new MovingSprite(0, clouds2y, rect.w, clouds2Texture->getHeight(), -clouds2speed, 0.0f, 0.0f, 0.0f, clouds2Texture, renderer);
|
clouds2A = new MovingSprite(0, clouds2y, rect.w, clouds2Texture->getHeight(), -clouds2speed, 0.0f, 0.0f, 0.0f, clouds2Texture);
|
||||||
clouds2B = new MovingSprite(rect.w, clouds2y, rect.w, clouds2Texture->getHeight(), -clouds2speed, 0.0f, 0.0f, 0.0f, clouds2Texture, renderer);
|
clouds2B = new MovingSprite(rect.w, clouds2y, rect.w, clouds2Texture->getHeight(), -clouds2speed, 0.0f, 0.0f, 0.0f, clouds2Texture);
|
||||||
|
|
||||||
buildingsSprite = new Sprite(0, 0, buildingsTexture->getWidth(), buildingsTexture->getHeight(), buildingsTexture, renderer);
|
buildingsSprite = new Sprite(0, 0, buildingsTexture->getWidth(), buildingsTexture->getHeight(), buildingsTexture);
|
||||||
gradientSprite = new Sprite(0, 0, rect.w, rect.h, gradientsTexture, renderer);
|
gradientSprite = new Sprite(0, 0, rect.w, rect.h, gradientsTexture);
|
||||||
grassSprite = new Sprite(0, 0, grassTexture->getWidth(), grassTexture->getHeight() / 2, grassTexture, renderer);
|
grassSprite = new Sprite(0, 0, grassTexture->getWidth(), grassTexture->getHeight() / 2, grassTexture);
|
||||||
|
|
||||||
// Inicializa objetos
|
// Inicializa objetos
|
||||||
clouds1A->setSpriteClip(0, 0, clouds1Texture->getWidth(), clouds1Texture->getHeight());
|
clouds1A->setSpriteClip(0, 0, clouds1Texture->getWidth(), clouds1Texture->getHeight());
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// Constructor
|
// Constructor
|
||||||
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
sprite = new AnimatedSprite(texture, "", animation);
|
||||||
disable();
|
disable();
|
||||||
|
|
||||||
enabled = true;
|
enabled = true;
|
||||||
@@ -210,14 +210,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
// Añade rotación al sprite
|
// Añade rotación al sprite
|
||||||
sprite->setRotate(false);
|
sprite->setRotate(false);
|
||||||
sprite->setRotateSpeed(0);
|
sprite->setRotateSpeed(0);
|
||||||
if (velX > 0.0f)
|
velX > 0.0f ? sprite->setRotateAmount(2.0) : sprite->setRotateAmount(-2.0);
|
||||||
{
|
|
||||||
sprite->setRotateAmount(2.0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprite->setRotateAmount(-2.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -289,9 +282,13 @@ void Balloon::allignTo(int x)
|
|||||||
posX = float(x - (width / 2));
|
posX = float(x - (width / 2));
|
||||||
|
|
||||||
if (posX < PLAY_AREA_LEFT)
|
if (posX < PLAY_AREA_LEFT)
|
||||||
|
{
|
||||||
posX = PLAY_AREA_LEFT + 1;
|
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);
|
posX = float(PLAY_AREA_RIGHT - width - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Posición X,Y del sprite
|
// Posición X,Y del sprite
|
||||||
sprite->setPosX(getPosX());
|
sprite->setPosX(getPosX());
|
||||||
@@ -304,7 +301,7 @@ void Balloon::allignTo(int x)
|
|||||||
// Pinta el globo en la pantalla
|
// Pinta el globo en la pantalla
|
||||||
void Balloon::render()
|
void Balloon::render()
|
||||||
{
|
{
|
||||||
if ((visible) && (enabled))
|
if (visible && enabled)
|
||||||
{
|
{
|
||||||
if (bouncing.enabled)
|
if (bouncing.enabled)
|
||||||
{
|
{
|
||||||
@@ -325,7 +322,7 @@ void Balloon::render()
|
|||||||
sprite->render();
|
sprite->render();
|
||||||
if (kind == POWER_BALL)
|
if (kind == POWER_BALL)
|
||||||
{
|
{
|
||||||
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer());
|
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture());
|
||||||
sp->setSpriteClip(407, 0, 37, 37);
|
sp->setSpriteClip(407, 0, 37, 37);
|
||||||
sp->render();
|
sp->render();
|
||||||
delete sp;
|
delete sp;
|
||||||
@@ -338,7 +335,7 @@ void Balloon::render()
|
|||||||
|
|
||||||
if (kind == POWER_BALL and !popping)
|
if (kind == POWER_BALL and !popping)
|
||||||
{
|
{
|
||||||
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer());
|
Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture());
|
||||||
sp->setSpriteClip(407, 0, 37, 37);
|
sp->setSpriteClip(407, 0, 37, 37);
|
||||||
sp->render();
|
sp->render();
|
||||||
delete sp;
|
delete sp;
|
||||||
@@ -579,16 +576,16 @@ void Balloon::updateState()
|
|||||||
{
|
{
|
||||||
stoppedCounter--;
|
stoppedCounter--;
|
||||||
}
|
}
|
||||||
// Quitarles el estado "detenido" si no estan explosionando
|
// Si el contador ha llegado a cero
|
||||||
else if (!isPopping())
|
else if (!isPopping())
|
||||||
{
|
{ // Quitarles el estado "detenido" si no estan explosionando
|
||||||
|
setStop(false);
|
||||||
|
|
||||||
// Si es una powerball vuelve a rodar
|
// Si es una powerball vuelve a rodar
|
||||||
if (kind == POWER_BALL)
|
if (kind == POWER_BALL)
|
||||||
{
|
{
|
||||||
sprite->setRotate(true);
|
sprite->setRotate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setStop(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -865,3 +862,15 @@ void Balloon::updateBounce()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Indica si el globo se puede explotar
|
||||||
|
bool Balloon::canBePopped()
|
||||||
|
{
|
||||||
|
return isEnabled() && !isPopping() && !isBeingCreated();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Indica si el globo se puede destruir
|
||||||
|
bool Balloon::canBeDestroyed()
|
||||||
|
{
|
||||||
|
return isEnabled() && !isPopping();
|
||||||
|
}
|
||||||
@@ -56,10 +56,10 @@
|
|||||||
#define BALLOON_SPEED_5 1.00f
|
#define BALLOON_SPEED_5 1.00f
|
||||||
|
|
||||||
// Tamaño de los globos
|
// Tamaño de los globos
|
||||||
#define BALLOON_WIDTH_1 8
|
#define BALLOON_WIDTH_1 10
|
||||||
#define BALLOON_WIDTH_2 13
|
#define BALLOON_WIDTH_2 16
|
||||||
#define BALLOON_WIDTH_3 21
|
#define BALLOON_WIDTH_3 26
|
||||||
#define BALLOON_WIDTH_4 37
|
#define BALLOON_WIDTH_4 46
|
||||||
|
|
||||||
// PowerBall
|
// PowerBall
|
||||||
#define POWERBALL_SCREENPOWER_MINIMUM 10
|
#define POWERBALL_SCREENPOWER_MINIMUM 10
|
||||||
@@ -246,4 +246,10 @@ public:
|
|||||||
|
|
||||||
// Obtiene le valor de la variable
|
// Obtiene le valor de la variable
|
||||||
Uint8 getPower();
|
Uint8 getPower();
|
||||||
|
|
||||||
|
// Indica si el globo se puede explotar
|
||||||
|
bool canBePopped();
|
||||||
|
|
||||||
|
// Indica si el globo se puede destruir
|
||||||
|
bool canBeDestroyed();
|
||||||
};
|
};
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer)
|
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture)
|
||||||
{
|
{
|
||||||
sprite = new Sprite({x, y, 10, 10}, texture, renderer);
|
sprite = new Sprite({x, y, 10, 10}, texture);
|
||||||
|
|
||||||
// Posición inicial del objeto
|
// Posición inicial del objeto
|
||||||
posX = x;
|
posX = x;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer);
|
Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Bullet();
|
~Bullet();
|
||||||
|
|||||||
@@ -146,11 +146,10 @@ animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::string file, std::vector<std::string> *buffer)
|
AnimatedSprite::AnimatedSprite(Texture *texture, std::string file, std::vector<std::string> *buffer)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
setRenderer(renderer);
|
|
||||||
|
|
||||||
// Carga las animaciones
|
// Carga las animaciones
|
||||||
if (file != "")
|
if (file != "")
|
||||||
@@ -174,11 +173,10 @@ AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation)
|
AnimatedSprite::AnimatedSprite(animatedSprite_t *animation)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
setTexture(animation->texture);
|
setTexture(animation->texture);
|
||||||
setRenderer(renderer);
|
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
currentAnimation = 0;
|
currentAnimation = 0;
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
AnimatedSprite(Texture *texture = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
||||||
AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation);
|
AnimatedSprite(animatedSprite_t *animation);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~AnimatedSprite();
|
~AnimatedSprite();
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, Texture *texture, SDL_Renderer *renderer)
|
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, Texture *texture)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->texture = texture;
|
this->texture = texture;
|
||||||
this->renderer = renderer;
|
|
||||||
|
|
||||||
// Establece el alto y el ancho del sprite
|
// Establece el alto y el ancho del sprite
|
||||||
this->w = w;
|
this->w = w;
|
||||||
@@ -96,7 +95,7 @@ void MovingSprite::render()
|
|||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
texture->render(renderer, (int)x, (int)y, &spriteClip, zoomW, zoomH, angle, center, currentFlip);
|
texture->render((int)x, (int)y, &spriteClip, zoomW, zoomH, angle, center, currentFlip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, Texture *texture = nullptr);
|
||||||
|
|
||||||
// Mueve el sprite
|
// Mueve el sprite
|
||||||
void move();
|
void move();
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#include "smartsprite.h"
|
#include "smartsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
SmartSprite::SmartSprite(Texture *texture, SDL_Renderer *renderer)
|
SmartSprite::SmartSprite(Texture *texture)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
setRenderer(renderer);
|
|
||||||
|
|
||||||
// Inicializa el objeto
|
// Inicializa el objeto
|
||||||
init();
|
init();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
SmartSprite(Texture *texture, SDL_Renderer *renderer);
|
SmartSprite(Texture *texture);
|
||||||
|
|
||||||
// Inicializa el objeto
|
// Inicializa el objeto
|
||||||
void init();
|
void init();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(int x, int y, int w, int h, Texture *texture)
|
||||||
{
|
{
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
this->x = x;
|
this->x = x;
|
||||||
@@ -11,9 +11,6 @@ Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *rende
|
|||||||
this->w = w;
|
this->w = w;
|
||||||
this->h = h;
|
this->h = h;
|
||||||
|
|
||||||
// Establece el puntero al renderizador de la ventana
|
|
||||||
this->renderer = renderer;
|
|
||||||
|
|
||||||
// Establece la textura donde están los gráficos para el sprite
|
// Establece la textura donde están los gráficos para el sprite
|
||||||
this->texture = texture;
|
this->texture = texture;
|
||||||
|
|
||||||
@@ -24,7 +21,7 @@ Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *rende
|
|||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(SDL_Rect rect, Texture *texture)
|
||||||
{
|
{
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
x = rect.x;
|
x = rect.x;
|
||||||
@@ -34,9 +31,6 @@ Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
|||||||
w = rect.w;
|
w = rect.w;
|
||||||
h = rect.h;
|
h = rect.h;
|
||||||
|
|
||||||
// Establece el puntero al renderizador de la ventana
|
|
||||||
this->renderer = renderer;
|
|
||||||
|
|
||||||
// Establece la textura donde están los gráficos para el sprite
|
// Establece la textura donde están los gráficos para el sprite
|
||||||
this->texture = texture;
|
this->texture = texture;
|
||||||
|
|
||||||
@@ -51,7 +45,6 @@ Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
|||||||
Sprite::~Sprite()
|
Sprite::~Sprite()
|
||||||
{
|
{
|
||||||
texture = nullptr;
|
texture = nullptr;
|
||||||
renderer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muestra el sprite por pantalla
|
// Muestra el sprite por pantalla
|
||||||
@@ -59,7 +52,7 @@ void Sprite::render()
|
|||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
texture->render(renderer, x, y, &spriteClip);
|
texture->render(x, y, &spriteClip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +81,10 @@ int Sprite::getHeight()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición del objeto
|
||||||
void Sprite::setPos(SDL_Rect rect)
|
void Sprite::setPos(SDL_Point p)
|
||||||
{
|
{
|
||||||
this->x = rect.x;
|
this->x = p.x;
|
||||||
this->y = rect.y;
|
this->y = p.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
@@ -148,18 +141,6 @@ void Sprite::setTexture(Texture *texture)
|
|||||||
this->texture = texture;
|
this->texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
|
||||||
SDL_Renderer *Sprite::getRenderer()
|
|
||||||
{
|
|
||||||
return renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Sprite::setRenderer(SDL_Renderer *renderer)
|
|
||||||
{
|
|
||||||
this->renderer = renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setEnabled(bool value)
|
void Sprite::setEnabled(bool value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ protected:
|
|||||||
int w; // Ancho del sprite
|
int w; // Ancho del sprite
|
||||||
int h; // Alto del sprite
|
int h; // Alto del sprite
|
||||||
|
|
||||||
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
|
||||||
Texture *texture; // Textura donde estan todos los dibujos del sprite
|
Texture *texture; // Textura donde estan todos los dibujos del sprite
|
||||||
SDL_Rect spriteClip; // Rectangulo de origen de la textura que se dibujará en pantalla
|
SDL_Rect spriteClip; // Rectangulo de origen de la textura que se dibujará en pantalla
|
||||||
|
|
||||||
@@ -20,8 +19,8 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, Texture *texture = nullptr);
|
||||||
Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer);
|
Sprite(SDL_Rect rect, Texture *texture);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Sprite();
|
~Sprite();
|
||||||
@@ -42,7 +41,7 @@ public:
|
|||||||
int getHeight();
|
int getHeight();
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición del objeto
|
||||||
void setPos(SDL_Rect rect);
|
void setPos(SDL_Point p);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setPosX(int x);
|
void setPosX(int x);
|
||||||
@@ -77,12 +76,6 @@ public:
|
|||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setTexture(Texture *texture);
|
void setTexture(Texture *texture);
|
||||||
|
|
||||||
// Obten el valor de la variable
|
|
||||||
SDL_Renderer *getRenderer();
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setRenderer(SDL_Renderer *renderer);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setEnabled(bool value);
|
void setEnabled(bool value);
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ Text::Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer)
|
|||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
texture = new Texture(renderer, bitmapFile);
|
texture = new Texture(renderer, bitmapFile);
|
||||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
fixedWidth = false;
|
fixedWidth = false;
|
||||||
@@ -118,7 +118,7 @@ Text::Text(std::string textFile, Texture *texture, SDL_Renderer *renderer)
|
|||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
this->texture = nullptr;
|
this->texture = nullptr;
|
||||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
fixedWidth = false;
|
fixedWidth = false;
|
||||||
@@ -139,7 +139,7 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer)
|
|||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
this->texture = nullptr;
|
this->texture = nullptr;
|
||||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
fixedWidth = false;
|
fixedWidth = false;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
|||||||
// .png
|
// .png
|
||||||
if (extension == "png")
|
if (extension == "png")
|
||||||
{
|
{
|
||||||
loadFromFile(path, renderer, verbose);
|
loadFromFile(path, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
// .gif
|
// .gif
|
||||||
@@ -38,7 +38,7 @@ Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
|||||||
surface = loadSurface(path.c_str());
|
surface = loadSurface(path.c_str());
|
||||||
addPalette(path.c_str());
|
addPalette(path.c_str());
|
||||||
setPaletteColor(0, 0, 0x00000000);
|
setPaletteColor(0, 0, 0x00000000);
|
||||||
createBlank(renderer, width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING);
|
createBlank(width, height, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING);
|
||||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||||
flipSurface();
|
flipSurface();
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ Texture::~Texture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga una imagen desde un fichero
|
// Carga una imagen desde un fichero
|
||||||
bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer, bool verbose)
|
bool Texture::loadFromFile(std::string path, bool verbose)
|
||||||
{
|
{
|
||||||
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
||||||
int req_format = STBI_rgb_alpha;
|
int req_format = STBI_rgb_alpha;
|
||||||
@@ -131,7 +131,7 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer, bool verbos
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea una textura en blanco
|
// Crea una textura en blanco
|
||||||
bool Texture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_PixelFormatEnum format, SDL_TextureAccess access)
|
bool Texture::createBlank(int width, int height, SDL_PixelFormatEnum format, SDL_TextureAccess access)
|
||||||
{
|
{
|
||||||
// Crea una textura sin inicializar
|
// Crea una textura sin inicializar
|
||||||
texture = SDL_CreateTexture(renderer, format, access, width, height);
|
texture = SDL_CreateTexture(renderer, format, access, width, height);
|
||||||
@@ -187,7 +187,7 @@ void Texture::setAlpha(Uint8 alpha)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Renderiza la textura en un punto específico
|
// Renderiza la textura en un punto específico
|
||||||
void Texture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, float zoomW, float zoomH, double angle, SDL_Point *center, SDL_RendererFlip flip)
|
void Texture::render(int x, int y, SDL_Rect *clip, float zoomW, float zoomH, double angle, SDL_Point *center, SDL_RendererFlip flip)
|
||||||
{
|
{
|
||||||
// Establece el destino de renderizado en la pantalla
|
// Establece el destino de renderizado en la pantalla
|
||||||
SDL_Rect renderQuad = {x, y, width, height};
|
SDL_Rect renderQuad = {x, y, width, height};
|
||||||
@@ -374,3 +374,9 @@ void Texture::setPalette(int palette)
|
|||||||
flipSurface();
|
flipSurface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtiene el renderizador
|
||||||
|
SDL_Renderer *Texture::getRenderer()
|
||||||
|
{
|
||||||
|
return renderer;
|
||||||
|
}
|
||||||
@@ -52,10 +52,10 @@ public:
|
|||||||
~Texture();
|
~Texture();
|
||||||
|
|
||||||
// Carga una imagen desde un fichero
|
// Carga una imagen desde un fichero
|
||||||
bool loadFromFile(std::string path, SDL_Renderer *renderer, bool verbose = false);
|
bool loadFromFile(std::string path, bool verbose = false);
|
||||||
|
|
||||||
// Crea una textura en blanco
|
// Crea una textura en blanco
|
||||||
bool createBlank(SDL_Renderer *renderer, int width, int height, SDL_PixelFormatEnum format = SDL_PIXELFORMAT_RGBA8888, SDL_TextureAccess = SDL_TEXTUREACCESS_STREAMING);
|
bool createBlank(int width, int height, SDL_PixelFormatEnum format = SDL_PIXELFORMAT_RGBA8888, SDL_TextureAccess = SDL_TEXTUREACCESS_STREAMING);
|
||||||
|
|
||||||
// Libera la memoria de la textura
|
// Libera la memoria de la textura
|
||||||
void unload();
|
void unload();
|
||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
void setAlpha(Uint8 alpha);
|
void setAlpha(Uint8 alpha);
|
||||||
|
|
||||||
// Renderiza la textura en un punto específico
|
// Renderiza la textura en un punto específico
|
||||||
void render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip = nullptr, float zoomW = 1, float zoomH = 1, double angle = 0.0, SDL_Point *center = nullptr, SDL_RendererFlip flip = SDL_FLIP_NONE);
|
void render(int x, int y, SDL_Rect *clip = nullptr, float zoomW = 1, float zoomH = 1, double angle = 0.0, SDL_Point *center = nullptr, SDL_RendererFlip flip = SDL_FLIP_NONE);
|
||||||
|
|
||||||
// Establece la textura como objetivo de renderizado
|
// Establece la textura como objetivo de renderizado
|
||||||
void setAsRenderTarget(SDL_Renderer *renderer);
|
void setAsRenderTarget(SDL_Renderer *renderer);
|
||||||
@@ -95,4 +95,7 @@ public:
|
|||||||
|
|
||||||
// Cambia la paleta de la textura
|
// Cambia la paleta de la textura
|
||||||
void setPalette(int palette);
|
void setPalette(int palette);
|
||||||
|
|
||||||
|
// Obtiene el renderizador
|
||||||
|
SDL_Renderer *getRenderer();
|
||||||
};
|
};
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
#include "define_buttons.h"
|
#include "define_buttons.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
DefineButtons::DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options, section_t *section)
|
DefineButtons::DefineButtons(Input *input, Text *text, param_t *param, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia punteros a los objetos
|
// Copia punteros a los objetos
|
||||||
this->renderer = renderer;
|
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->text = text;
|
this->text = text;
|
||||||
this->param = param;
|
this->param = param;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class DefineButtons
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos
|
// Objetos
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
Text *text; // Objeto para escribir texto
|
Text *text; // Objeto para escribir texto
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
DefineButtons(SDL_Renderer *renderer, Input *input, Text *text, param_t *param, options_t *options, section_t *section);
|
DefineButtons(Input *input, Text *text, param_t *param, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~DefineButtons();
|
~DefineButtons();
|
||||||
|
|||||||
@@ -320,14 +320,27 @@ bool Director::setFileList()
|
|||||||
asset->add(prefix + "/data/shaders/crtpi.glsl", t_data);
|
asset->add(prefix + "/data/shaders/crtpi.glsl", t_data);
|
||||||
|
|
||||||
// Texturas
|
// Texturas
|
||||||
asset->add(prefix + "/data/gfx/balloon1.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/balloon1.gif", t_bitmap);
|
||||||
asset->add(prefix + "/data/gfx/balloon1.ani", t_data);
|
asset->add(prefix + "/data/gfx/balloon1.ani", t_data);
|
||||||
asset->add(prefix + "/data/gfx/balloon2.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/balloon2.gif", t_bitmap);
|
||||||
asset->add(prefix + "/data/gfx/balloon2.ani", t_data);
|
asset->add(prefix + "/data/gfx/balloon2.ani", t_data);
|
||||||
asset->add(prefix + "/data/gfx/balloon3.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/balloon3.gif", t_bitmap);
|
||||||
asset->add(prefix + "/data/gfx/balloon3.ani", t_data);
|
asset->add(prefix + "/data/gfx/balloon3.ani", t_data);
|
||||||
asset->add(prefix + "/data/gfx/balloon4.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/balloon4.gif", t_bitmap);
|
||||||
asset->add(prefix + "/data/gfx/balloon4.ani", t_data);
|
asset->add(prefix + "/data/gfx/balloon4.ani", t_data);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon1_explosion.png", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon1_explosion.ani", t_data);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon2_explosion.png", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon2_explosion.ani", t_data);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon3_explosion.png", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon3_explosion.ani", t_data);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon4_explosion.png", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon4_explosion.ani", t_data);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon_blue_pal.gif", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon_yellow_pal.gif", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/balloon_green_pal.gif", t_bitmap);
|
||||||
|
asset->add(prefix + "/data/gfx/powerball.png", t_bitmap);
|
||||||
|
|
||||||
asset->add(prefix + "/data/gfx/bullet.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/bullet.png", t_bitmap);
|
||||||
|
|
||||||
asset->add(prefix + "/data/gfx/game_buildings.png", t_bitmap);
|
asset->add(prefix + "/data/gfx/game_buildings.png", t_bitmap);
|
||||||
|
|||||||
39
source/explosions.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#include "explosions.h"
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Explosions::Explosions()
|
||||||
|
{
|
||||||
|
textures.clear();
|
||||||
|
explosions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
Explosions::~Explosions()
|
||||||
|
{
|
||||||
|
for (auto explosion : explosions)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza la lógica de la clase
|
||||||
|
void Explosions::update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja el objeto en pantalla
|
||||||
|
void Explosions::render()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade texturas al objetp
|
||||||
|
void Explosions::addTexture(Texture *texture)
|
||||||
|
{
|
||||||
|
textures.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añade una explosión
|
||||||
|
void Explosions::add(int x, int y, int size)
|
||||||
|
{
|
||||||
|
AnimatedSprite *sprite = new AnimatedSprite(textures[0]);
|
||||||
|
sprite->setPos({x,y});
|
||||||
|
}
|
||||||
48
source/explosions.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include "common/texture.h"
|
||||||
|
#include "common/animatedsprite.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct explosion_t
|
||||||
|
{
|
||||||
|
AnimatedSprite *sprite; // Sprite para dibujar la explosión
|
||||||
|
bool ended; // Indica si la explosión ha terminado
|
||||||
|
};
|
||||||
|
|
||||||
|
struct explision_texture_t
|
||||||
|
{
|
||||||
|
Texture *texture; // Textura para la explosión
|
||||||
|
int size; // Tamaño de la explosión
|
||||||
|
};
|
||||||
|
|
||||||
|
// Clase explosions
|
||||||
|
class Explosions
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
// Objetos y punteros
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
std::vector<Texture *> textures; // Vector con las texturas a utilizar
|
||||||
|
std::vector<explosion_t> explosions; // Lista con todas las explosiones
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
Explosions();
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Explosions();
|
||||||
|
|
||||||
|
// Actualiza la lógica de la clase
|
||||||
|
void update();
|
||||||
|
|
||||||
|
// Dibuja el objeto en pantalla
|
||||||
|
void render();
|
||||||
|
|
||||||
|
// Añade texturas al objetp
|
||||||
|
void addTexture(Texture *texture);
|
||||||
|
|
||||||
|
// Añade una explosión
|
||||||
|
void add(int x, int y, int size);
|
||||||
|
};
|
||||||
370
source/game.cpp
@@ -27,15 +27,7 @@ Game::Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *scree
|
|||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
scoreboard = new Scoreboard(renderer, screen, asset, lang, options);
|
scoreboard = new Scoreboard(renderer, screen, asset, lang, options);
|
||||||
background = new Background(renderer, screen, asset, param);
|
background = new Background(renderer, screen, asset, param);
|
||||||
|
explosions = new Explosions();
|
||||||
// Inicializa vectores
|
|
||||||
playerAnimations.clear();
|
|
||||||
balloonAnimations.clear();
|
|
||||||
itemAnimations.clear();
|
|
||||||
player1Textures.clear();
|
|
||||||
player2Textures.clear();
|
|
||||||
itemTextures.clear();
|
|
||||||
balloonTextures.clear();
|
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
loadMedia();
|
loadMedia();
|
||||||
@@ -50,15 +42,12 @@ Game::Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *scree
|
|||||||
loadDemoFile(asset->get("demo2.bin"), &this->demo.dataFile[index2]);
|
loadDemoFile(asset->get("demo2.bin"), &this->demo.dataFile[index2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la máxima puntuación desde fichero o desde las puntuaciones online
|
// Carga las puntuaciones desde el fichero y establece la máxima puntuación
|
||||||
setHiScore();
|
setHiScore();
|
||||||
|
|
||||||
n1000Sprite = new SmartSprite(gameTextTexture, renderer);
|
n1000Sprite = new SmartSprite(gameTextTexture);
|
||||||
n2500Sprite = new SmartSprite(gameTextTexture, renderer);
|
n2500Sprite = new SmartSprite(gameTextTexture);
|
||||||
n5000Sprite = new SmartSprite(gameTextTexture, renderer);
|
n5000Sprite = new SmartSprite(gameTextTexture);
|
||||||
|
|
||||||
gameOverSprite = new Sprite(16, 80, 128, 96, gameOverTexture, renderer);
|
|
||||||
gameOverEndSprite = new Sprite(PLAY_AREA_CENTER_X - gameOverEndTexture->getWidth() / 2, 80, 128, 96, gameOverEndTexture, renderer);
|
|
||||||
|
|
||||||
canvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, playArea.w, playArea.h);
|
canvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, playArea.w, playArea.h);
|
||||||
SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND);
|
||||||
@@ -74,130 +63,24 @@ Game::~Game()
|
|||||||
saveDemoFile();
|
saveDemoFile();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!demo.enabled)
|
|
||||||
{
|
|
||||||
hiScoreEntry_t entry = {"Sergio", players[0]->getScore()};
|
|
||||||
ManageHiScoreTable *m = new ManageHiScoreTable(&options->game.hiScoreTable);
|
|
||||||
m->add(entry);
|
|
||||||
delete m;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Elimina todos los objetos contenidos en vectores
|
// Elimina todos los objetos contenidos en vectores
|
||||||
deleteAllVectorObjects();
|
deleteAllVectorObjects();
|
||||||
|
|
||||||
bulletTexture->unload();
|
// Libera los recursos
|
||||||
delete bulletTexture;
|
unloadMedia();
|
||||||
|
|
||||||
gameTextTexture->unload();
|
|
||||||
delete gameTextTexture;
|
|
||||||
|
|
||||||
gameOverTexture->unload();
|
|
||||||
delete gameOverTexture;
|
|
||||||
|
|
||||||
gameOverEndTexture->unload();
|
|
||||||
delete gameOverEndTexture;
|
|
||||||
|
|
||||||
// Animaciones
|
|
||||||
for (auto animation : playerAnimations)
|
|
||||||
{
|
|
||||||
if (animation)
|
|
||||||
{
|
|
||||||
delete animation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
playerAnimations.clear();
|
|
||||||
|
|
||||||
for (auto animation : balloonAnimations)
|
|
||||||
{
|
|
||||||
if (animation)
|
|
||||||
{
|
|
||||||
delete animation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
balloonAnimations.clear();
|
|
||||||
|
|
||||||
for (auto animation : itemAnimations)
|
|
||||||
{
|
|
||||||
if (animation)
|
|
||||||
{
|
|
||||||
delete animation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
itemAnimations.clear();
|
|
||||||
|
|
||||||
// Texturas
|
|
||||||
for (auto texture : player1Textures)
|
|
||||||
{
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
texture->unload();
|
|
||||||
delete texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player1Textures.clear();
|
|
||||||
|
|
||||||
for (auto texture : player2Textures)
|
|
||||||
{
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
texture->unload();
|
|
||||||
delete texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player2Textures.clear();
|
|
||||||
|
|
||||||
for (auto texture : itemTextures)
|
|
||||||
{
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
texture->unload();
|
|
||||||
delete texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
itemTextures.clear();
|
|
||||||
|
|
||||||
for (auto texture : balloonTextures)
|
|
||||||
{
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
texture->unload();
|
|
||||||
delete texture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
balloonTextures.clear();
|
|
||||||
|
|
||||||
delete scoreboard;
|
delete scoreboard;
|
||||||
delete background;
|
delete background;
|
||||||
|
delete explosions;
|
||||||
|
|
||||||
delete text;
|
|
||||||
delete textBig;
|
|
||||||
delete textNokia2;
|
|
||||||
delete textNokiaBig2;
|
|
||||||
delete fade;
|
delete fade;
|
||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
|
|
||||||
delete n1000Sprite;
|
delete n1000Sprite;
|
||||||
delete n2500Sprite;
|
delete n2500Sprite;
|
||||||
delete n5000Sprite;
|
delete n5000Sprite;
|
||||||
delete gameOverSprite;
|
|
||||||
delete gameOverEndSprite;
|
|
||||||
|
|
||||||
SDL_DestroyTexture(canvas);
|
SDL_DestroyTexture(canvas);
|
||||||
|
|
||||||
JA_DeleteSound(balloonSound);
|
|
||||||
JA_DeleteSound(bulletSound);
|
|
||||||
JA_DeleteSound(playerCollisionSound);
|
|
||||||
JA_DeleteSound(hiScoreSound);
|
|
||||||
JA_DeleteSound(itemDropSound);
|
|
||||||
JA_DeleteSound(itemPickUpSound);
|
|
||||||
JA_DeleteSound(coffeeOutSound);
|
|
||||||
JA_DeleteSound(stageChangeSound);
|
|
||||||
JA_DeleteSound(bubble1Sound);
|
|
||||||
JA_DeleteSound(bubble2Sound);
|
|
||||||
JA_DeleteSound(bubble3Sound);
|
|
||||||
JA_DeleteSound(bubble4Sound);
|
|
||||||
JA_DeleteSound(clockSound);
|
|
||||||
JA_DeleteSound(powerBallSound);
|
|
||||||
JA_DeleteSound(coffeeMachineSound);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa las variables necesarias para la sección 'Game'
|
// Inicializa las variables necesarias para la sección 'Game'
|
||||||
@@ -217,10 +100,10 @@ void Game::init(int playerID)
|
|||||||
players.clear();
|
players.clear();
|
||||||
|
|
||||||
// Crea los dos jugadores
|
// Crea los dos jugadores
|
||||||
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, renderer, playerTextures[0], playerAnimations);
|
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, playerTextures[0], playerAnimations);
|
||||||
players.push_back(player1);
|
players.push_back(player1);
|
||||||
|
|
||||||
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, renderer, playerTextures[1], playerAnimations);
|
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, playerTextures[1], playerAnimations);
|
||||||
players.push_back(player2);
|
players.push_back(player2);
|
||||||
|
|
||||||
// Habilita el jugador seleccionado. playerID es player 1 o player 2
|
// Habilita el jugador seleccionado. playerID es player 1 o player 2
|
||||||
@@ -432,6 +315,15 @@ void Game::loadMedia()
|
|||||||
<< "** LOADING RESOURCES FOR GAME SECTION" << std::endl;
|
<< "** LOADING RESOURCES FOR GAME SECTION" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playerAnimations.clear();
|
||||||
|
balloonAnimations.clear();
|
||||||
|
itemAnimations.clear();
|
||||||
|
player1Textures.clear();
|
||||||
|
player2Textures.clear();
|
||||||
|
itemTextures.clear();
|
||||||
|
balloonTextures.clear();
|
||||||
|
explosionsTextures.clear();
|
||||||
|
|
||||||
// Texturas
|
// Texturas
|
||||||
bulletTexture = new Texture(renderer, asset->get("bullet.png"));
|
bulletTexture = new Texture(renderer, asset->get("bullet.png"));
|
||||||
gameTextTexture = new Texture(renderer, asset->get("game_text.png"));
|
gameTextTexture = new Texture(renderer, asset->get("game_text.png"));
|
||||||
@@ -439,18 +331,43 @@ void Game::loadMedia()
|
|||||||
gameOverEndTexture = new Texture(renderer, asset->get("menu_game_over_end.png"));
|
gameOverEndTexture = new Texture(renderer, asset->get("menu_game_over_end.png"));
|
||||||
|
|
||||||
// Texturas - Globos
|
// Texturas - Globos
|
||||||
Texture *balloon1Texture = new Texture(renderer, asset->get("balloon1.png"));
|
Texture *balloon1Texture = new Texture(renderer, asset->get("balloon1.gif"));
|
||||||
|
balloon1Texture->addPalette(asset->get("balloon_blue_pal.gif"));
|
||||||
|
balloon1Texture->addPalette(asset->get("balloon_yellow_pal.gif"));
|
||||||
|
balloon1Texture->addPalette(asset->get("balloon_green_pal.gif"));
|
||||||
balloonTextures.push_back(balloon1Texture);
|
balloonTextures.push_back(balloon1Texture);
|
||||||
|
|
||||||
Texture *balloon2Texture = new Texture(renderer, asset->get("balloon2.png"));
|
Texture *balloon2Texture = new Texture(renderer, asset->get("balloon2.gif"));
|
||||||
|
balloon2Texture->addPalette(asset->get("balloon_blue_pal.gif"));
|
||||||
|
balloon2Texture->addPalette(asset->get("balloon_yellow_pal.gif"));
|
||||||
|
balloon2Texture->addPalette(asset->get("balloon_green_pal.gif"));
|
||||||
balloonTextures.push_back(balloon2Texture);
|
balloonTextures.push_back(balloon2Texture);
|
||||||
|
|
||||||
Texture *balloon3Texture = new Texture(renderer, asset->get("balloon3.png"));
|
Texture *balloon3Texture = new Texture(renderer, asset->get("balloon3.gif"));
|
||||||
|
balloon3Texture->addPalette(asset->get("balloon_blue_pal.gif"));
|
||||||
|
balloon3Texture->addPalette(asset->get("balloon_yellow_pal.gif"));
|
||||||
|
balloon3Texture->addPalette(asset->get("balloon_green_pal.gif"));
|
||||||
balloonTextures.push_back(balloon3Texture);
|
balloonTextures.push_back(balloon3Texture);
|
||||||
|
|
||||||
Texture *balloon4Texture = new Texture(renderer, asset->get("balloon4.png"));
|
Texture *balloon4Texture = new Texture(renderer, asset->get("balloon4.gif"));
|
||||||
|
balloon4Texture->addPalette(asset->get("balloon_blue_pal.gif"));
|
||||||
|
balloon4Texture->addPalette(asset->get("balloon_yellow_pal.gif"));
|
||||||
|
balloon4Texture->addPalette(asset->get("balloon_green_pal.gif"));
|
||||||
balloonTextures.push_back(balloon4Texture);
|
balloonTextures.push_back(balloon4Texture);
|
||||||
|
|
||||||
|
// Texturas - Explosiones
|
||||||
|
Texture *explosion1Texture = new Texture(renderer, asset->get("balloon1_explosion.png"));
|
||||||
|
explosionsTextures.push_back(explosion1Texture);
|
||||||
|
|
||||||
|
Texture *explosion2Texture = new Texture(renderer, asset->get("balloon1_explosion.png"));
|
||||||
|
explosionsTextures.push_back(explosion2Texture);
|
||||||
|
|
||||||
|
Texture *explosion3Texture = new Texture(renderer, asset->get("balloon1_explosion.png"));
|
||||||
|
explosionsTextures.push_back(explosion3Texture);
|
||||||
|
|
||||||
|
Texture *explosion4Texture = new Texture(renderer, asset->get("balloon1_explosion.png"));
|
||||||
|
explosionsTextures.push_back(explosion4Texture);
|
||||||
|
|
||||||
// Texturas - Items
|
// Texturas - Items
|
||||||
Texture *item1 = new Texture(renderer, asset->get("item_points1_disk.png"));
|
Texture *item1 = new Texture(renderer, asset->get("item_points1_disk.png"));
|
||||||
itemTextures.push_back(item1);
|
itemTextures.push_back(item1);
|
||||||
@@ -520,6 +437,23 @@ void Game::loadMedia()
|
|||||||
loadAnimations(asset->get("balloon4.ani"), balloon4Animation);
|
loadAnimations(asset->get("balloon4.ani"), balloon4Animation);
|
||||||
balloonAnimations.push_back(balloon4Animation);
|
balloonAnimations.push_back(balloon4Animation);
|
||||||
|
|
||||||
|
// Animaciones -- Explosiones
|
||||||
|
std::vector<std::string> *explosions1Animation = new std::vector<std::string>;
|
||||||
|
loadAnimations(asset->get("balloon1_explosion.ani"), explosions1Animation);
|
||||||
|
explosionsAnimations.push_back(explosions1Animation);
|
||||||
|
|
||||||
|
std::vector<std::string> *explosions2Animation = new std::vector<std::string>;
|
||||||
|
loadAnimations(asset->get("balloon2_explosion.ani"), explosions2Animation);
|
||||||
|
explosionsAnimations.push_back(explosions2Animation);
|
||||||
|
|
||||||
|
std::vector<std::string> *explosions3Animation = new std::vector<std::string>;
|
||||||
|
loadAnimations(asset->get("balloon3_explosion.ani"), explosions3Animation);
|
||||||
|
explosionsAnimations.push_back(explosions3Animation);
|
||||||
|
|
||||||
|
std::vector<std::string> *explosions4Animation = new std::vector<std::string>;
|
||||||
|
loadAnimations(asset->get("balloon4_explosion.ani"), explosions4Animation);
|
||||||
|
explosionsAnimations.push_back(explosions4Animation);
|
||||||
|
|
||||||
// Animaciones -- Items
|
// Animaciones -- Items
|
||||||
std::vector<std::string> *item1Animation = new std::vector<std::string>;
|
std::vector<std::string> *item1Animation = new std::vector<std::string>;
|
||||||
loadAnimations(asset->get("item_points1_disk.ani"), item1Animation);
|
loadAnimations(asset->get("item_points1_disk.ani"), item1Animation);
|
||||||
@@ -575,6 +509,121 @@ void Game::loadMedia()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Libera los recursos previamente cargados
|
||||||
|
void Game::unloadMedia()
|
||||||
|
{
|
||||||
|
// Texturas
|
||||||
|
delete bulletTexture;
|
||||||
|
delete gameTextTexture;
|
||||||
|
delete gameOverTexture;
|
||||||
|
delete gameOverEndTexture;
|
||||||
|
|
||||||
|
for (auto texture : player1Textures)
|
||||||
|
{
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
delete texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player1Textures.clear();
|
||||||
|
|
||||||
|
for (auto texture : player2Textures)
|
||||||
|
{
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
delete texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player2Textures.clear();
|
||||||
|
|
||||||
|
for (auto texture : itemTextures)
|
||||||
|
{
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
delete texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemTextures.clear();
|
||||||
|
|
||||||
|
for (auto texture : balloonTextures)
|
||||||
|
{
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
delete texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
balloonTextures.clear();
|
||||||
|
|
||||||
|
for (auto texture : explosionsTextures)
|
||||||
|
{
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
delete texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
explosionsTextures.clear();
|
||||||
|
|
||||||
|
// Animaciones
|
||||||
|
for (auto animation : playerAnimations)
|
||||||
|
{
|
||||||
|
if (animation)
|
||||||
|
{
|
||||||
|
delete animation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playerAnimations.clear();
|
||||||
|
|
||||||
|
for (auto animation : balloonAnimations)
|
||||||
|
{
|
||||||
|
if (animation)
|
||||||
|
{
|
||||||
|
delete animation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
balloonAnimations.clear();
|
||||||
|
|
||||||
|
for (auto animation : explosionsAnimations)
|
||||||
|
{
|
||||||
|
if (animation)
|
||||||
|
{
|
||||||
|
delete animation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
explosionsAnimations.clear();
|
||||||
|
|
||||||
|
for (auto animation : itemAnimations)
|
||||||
|
{
|
||||||
|
if (animation)
|
||||||
|
{
|
||||||
|
delete animation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemAnimations.clear();
|
||||||
|
|
||||||
|
// Text
|
||||||
|
delete text;
|
||||||
|
delete textBig;
|
||||||
|
delete textNokia2;
|
||||||
|
delete textNokiaBig2;
|
||||||
|
|
||||||
|
// Sonidos
|
||||||
|
JA_DeleteSound(balloonSound);
|
||||||
|
JA_DeleteSound(bulletSound);
|
||||||
|
JA_DeleteSound(playerCollisionSound);
|
||||||
|
JA_DeleteSound(hiScoreSound);
|
||||||
|
JA_DeleteSound(itemDropSound);
|
||||||
|
JA_DeleteSound(itemPickUpSound);
|
||||||
|
JA_DeleteSound(coffeeOutSound);
|
||||||
|
JA_DeleteSound(stageChangeSound);
|
||||||
|
JA_DeleteSound(bubble1Sound);
|
||||||
|
JA_DeleteSound(bubble2Sound);
|
||||||
|
JA_DeleteSound(bubble3Sound);
|
||||||
|
JA_DeleteSound(bubble4Sound);
|
||||||
|
JA_DeleteSound(clockSound);
|
||||||
|
JA_DeleteSound(powerBallSound);
|
||||||
|
JA_DeleteSound(coffeeMachineSound);
|
||||||
|
}
|
||||||
|
|
||||||
// Carga el fichero de puntos
|
// Carga el fichero de puntos
|
||||||
bool Game::loadScoreFile()
|
bool Game::loadScoreFile()
|
||||||
{
|
{
|
||||||
@@ -733,6 +782,10 @@ bool Game::loadDemoFile(std::string f, demoKeys_t (*dataFile)[TOTAL_DEMO_DATA])
|
|||||||
// Guarda el fichero de puntos
|
// Guarda el fichero de puntos
|
||||||
bool Game::saveScoreFile()
|
bool Game::saveScoreFile()
|
||||||
{
|
{
|
||||||
|
// Almacena la máxima puntuación en el fichero junto con un checksum
|
||||||
|
scoreDataFile[0] = hiScore;
|
||||||
|
scoreDataFile[1] = hiScore % 43;
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
const std::string p = asset->get("score.bin");
|
const std::string p = asset->get("score.bin");
|
||||||
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
||||||
@@ -1564,12 +1617,6 @@ void Game::increaseStageCurrentPower(int power)
|
|||||||
stage[currentStage].currentPower += power;
|
stage[currentStage].currentPower += power;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Game::setHiScore(Uint32 score)
|
|
||||||
{
|
|
||||||
hiScore = score;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza el valor de hiScore en caso necesario
|
// Actualiza el valor de hiScore en caso necesario
|
||||||
void Game::updateHiScore()
|
void Game::updateHiScore()
|
||||||
{
|
{
|
||||||
@@ -1580,10 +1627,6 @@ void Game::updateHiScore()
|
|||||||
// Actualiza la máxima puntuación
|
// Actualiza la máxima puntuación
|
||||||
hiScore = player->getScore();
|
hiScore = player->getScore();
|
||||||
|
|
||||||
// Almacena la máxima puntuación en el fichero junto con un checksum
|
|
||||||
scoreDataFile[0] = hiScore;
|
|
||||||
scoreDataFile[1] = hiScore % 43;
|
|
||||||
|
|
||||||
// Si se supera la máxima puntuación emite sonido
|
// Si se supera la máxima puntuación emite sonido
|
||||||
if (hiScoreAchieved == false)
|
if (hiScoreAchieved == false)
|
||||||
{
|
{
|
||||||
@@ -1932,38 +1975,32 @@ void Game::popBalloon(Balloon *balloon)
|
|||||||
evaluateAndSetMenace();
|
evaluateAndSetMenace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explosiona un globo. Lo destruye
|
// Explosiona un globo. Lo destruye = no crea otros globos
|
||||||
void Game::destroyBalloon(Balloon *balloon)
|
void Game::destroyBalloon(Balloon *balloon)
|
||||||
{
|
{
|
||||||
int score = 0;
|
int score = 0;
|
||||||
int power = 0;
|
|
||||||
|
|
||||||
// Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos
|
// Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos
|
||||||
switch (balloon->getSize())
|
switch (balloon->getSize())
|
||||||
{
|
{
|
||||||
case BALLOON_SIZE_4:
|
case BALLOON_SIZE_4:
|
||||||
score = BALLOON_SCORE_4 + (2 * BALLOON_SCORE_3) + (4 * BALLOON_SCORE_2) + (8 * BALLOON_SCORE_1);
|
score = BALLOON_SCORE_4 + (2 * BALLOON_SCORE_3) + (4 * BALLOON_SCORE_2) + (8 * BALLOON_SCORE_1);
|
||||||
power = 15;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BALLOON_SIZE_3:
|
case BALLOON_SIZE_3:
|
||||||
score = BALLOON_SCORE_3 + (2 * BALLOON_SCORE_2) + (4 * BALLOON_SCORE_1);
|
score = BALLOON_SCORE_3 + (2 * BALLOON_SCORE_2) + (4 * BALLOON_SCORE_1);
|
||||||
power = 7;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BALLOON_SIZE_2:
|
case BALLOON_SIZE_2:
|
||||||
score = BALLOON_SCORE_2 + (2 * BALLOON_SCORE_1);
|
score = BALLOON_SCORE_2 + (2 * BALLOON_SCORE_1);
|
||||||
power = 3;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BALLOON_SIZE_1:
|
case BALLOON_SIZE_1:
|
||||||
score = BALLOON_SCORE_1;
|
score = BALLOON_SCORE_1;
|
||||||
power = 1;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
score = 0;
|
score = 0;
|
||||||
power = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1975,6 +2012,7 @@ void Game::destroyBalloon(Balloon *balloon)
|
|||||||
updateHiScore();
|
updateHiScore();
|
||||||
|
|
||||||
// Aumenta el poder de la fase
|
// Aumenta el poder de la fase
|
||||||
|
const int power = balloon->getPower();
|
||||||
increaseStageCurrentPower(power);
|
increaseStageCurrentPower(power);
|
||||||
balloonsPopped += power;
|
balloonsPopped += power;
|
||||||
|
|
||||||
@@ -1990,7 +2028,7 @@ void Game::popAllBalloons()
|
|||||||
{
|
{
|
||||||
for (auto balloon : balloons)
|
for (auto balloon : balloons)
|
||||||
{
|
{
|
||||||
if ((balloon->isEnabled()) && (!balloon->isPopping()) && (!balloon->isBeingCreated()))
|
if (balloon->canBePopped())
|
||||||
{
|
{
|
||||||
popBalloon(balloon);
|
popBalloon(balloon);
|
||||||
}
|
}
|
||||||
@@ -2004,7 +2042,7 @@ void Game::destroyAllBalloons()
|
|||||||
{
|
{
|
||||||
for (auto balloon : balloons)
|
for (auto balloon : balloons)
|
||||||
{
|
{
|
||||||
if ((balloon->isEnabled()) && (!balloon->isPopping()))
|
if (balloon->canBeDestroyed())
|
||||||
{
|
{
|
||||||
destroyBalloon(balloon);
|
destroyBalloon(balloon);
|
||||||
}
|
}
|
||||||
@@ -2061,7 +2099,7 @@ int Game::countBalloons()
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vacia el vector de globos
|
// Vacia del vector de globos los globos que ya no sirven
|
||||||
void Game::freeBalloons()
|
void Game::freeBalloons()
|
||||||
{
|
{
|
||||||
if (balloons.empty() == false)
|
if (balloons.empty() == false)
|
||||||
@@ -2243,7 +2281,7 @@ void Game::renderBullets()
|
|||||||
// Crea un objeto bala
|
// Crea un objeto bala
|
||||||
void Game::createBullet(int x, int y, int kind, bool poweredUp, int owner)
|
void Game::createBullet(int x, int y, int kind, bool poweredUp, int owner)
|
||||||
{
|
{
|
||||||
Bullet *b = new Bullet(x, y, kind, poweredUp, owner, bulletTexture, renderer);
|
Bullet *b = new Bullet(x, y, kind, poweredUp, owner, bulletTexture);
|
||||||
bullets.push_back(b);
|
bullets.push_back(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2368,7 +2406,7 @@ int Game::dropItem()
|
|||||||
// Crea un objeto item
|
// Crea un objeto item
|
||||||
void Game::createItem(int kind, float x, float y)
|
void Game::createItem(int kind, float x, float y)
|
||||||
{
|
{
|
||||||
Item *item = new Item(kind, x, y, itemTextures[kind - 1], itemAnimations[kind - 1], renderer);
|
Item *item = new Item(kind, x, y, itemTextures[kind - 1], itemAnimations[kind - 1]);
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2391,7 +2429,7 @@ void Game::freeItems()
|
|||||||
// Crea un objeto SmartSprite para mostrar la puntuación al coger un objeto
|
// Crea un objeto SmartSprite para mostrar la puntuación al coger un objeto
|
||||||
void Game::createItemScoreSprite(int x, int y, SmartSprite *sprite)
|
void Game::createItemScoreSprite(int x, int y, SmartSprite *sprite)
|
||||||
{
|
{
|
||||||
SmartSprite *ss = new SmartSprite(nullptr, renderer);
|
SmartSprite *ss = new SmartSprite(nullptr);
|
||||||
smartSprites.push_back(ss);
|
smartSprites.push_back(ss);
|
||||||
|
|
||||||
// Crea una copia del objeto
|
// Crea una copia del objeto
|
||||||
@@ -2423,7 +2461,7 @@ void Game::freeSmartSprites()
|
|||||||
// Crea un SmartSprite para arrojar el item café al recibir un impacto
|
// Crea un SmartSprite para arrojar el item café al recibir un impacto
|
||||||
void Game::throwCoffee(int x, int y)
|
void Game::throwCoffee(int x, int y)
|
||||||
{
|
{
|
||||||
SmartSprite *ss = new SmartSprite(itemTextures[4], renderer);
|
SmartSprite *ss = new SmartSprite(itemTextures[4]);
|
||||||
smartSprites.push_back(ss);
|
smartSprites.push_back(ss);
|
||||||
|
|
||||||
ss->setPosX(x - 8);
|
ss->setPosX(x - 8);
|
||||||
@@ -2487,6 +2525,10 @@ void Game::killPlayer(Player *player)
|
|||||||
JA_PlaySound(coffeeOutSound);
|
JA_PlaySound(coffeeOutSound);
|
||||||
player->setAlive(false);
|
player->setAlive(false);
|
||||||
allPlayersAreDead() ? JA_StopMusic() : JA_ResumeMusic();
|
allPlayersAreDead() ? JA_StopMusic() : JA_ResumeMusic();
|
||||||
|
if (!demo.enabled)
|
||||||
|
{
|
||||||
|
addScoreToScoreBoard("Sergio", player->getScore());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2638,6 +2680,8 @@ void Game::update()
|
|||||||
// Mueve los globos
|
// Mueve los globos
|
||||||
updateBalloons();
|
updateBalloons();
|
||||||
|
|
||||||
|
explosions->update();
|
||||||
|
|
||||||
// Mueve las balas
|
// Mueve las balas
|
||||||
moveBullets();
|
moveBullets();
|
||||||
|
|
||||||
@@ -2731,6 +2775,7 @@ void Game::fillCanvas()
|
|||||||
background->render();
|
background->render();
|
||||||
renderItems();
|
renderItems();
|
||||||
renderSmartSprites();
|
renderSmartSprites();
|
||||||
|
explosions->render();
|
||||||
renderBalloons();
|
renderBalloons();
|
||||||
renderBullets();
|
renderBullets();
|
||||||
renderMessages();
|
renderMessages();
|
||||||
@@ -2783,7 +2828,7 @@ void Game::updateMenace()
|
|||||||
if (menaceCurrent < menaceThreshold)
|
if (menaceCurrent < menaceThreshold)
|
||||||
{
|
{
|
||||||
// Crea una formación de enemigos
|
// Crea una formación de enemigos
|
||||||
deployEnemyFormation();
|
// deployEnemyFormation();
|
||||||
|
|
||||||
// Recalcula el nivel de amenaza con el nuevo globo
|
// Recalcula el nivel de amenaza con el nuevo globo
|
||||||
evaluateAndSetMenace();
|
evaluateAndSetMenace();
|
||||||
@@ -3397,7 +3442,7 @@ void Game::reloadTextures()
|
|||||||
background->reloadTextures();
|
background->reloadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la máxima puntuación desde fichero o desde las puntuaciones online
|
// Carga las puntuaciones desde el fichero y establece la máxima puntuación
|
||||||
void Game::setHiScore()
|
void Game::setHiScore()
|
||||||
{
|
{
|
||||||
// Carga el fichero de puntos
|
// Carga el fichero de puntos
|
||||||
@@ -3433,3 +3478,12 @@ void Game::pause(bool value)
|
|||||||
paused = value;
|
paused = value;
|
||||||
screen->attenuate(paused);
|
screen->attenuate(paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Añade una puntuación a la tabla de records
|
||||||
|
void Game::addScoreToScoreBoard(std::string name, int score)
|
||||||
|
{
|
||||||
|
hiScoreEntry_t entry = {name, score};
|
||||||
|
ManageHiScoreTable *m = new ManageHiScoreTable(&options->game.hiScoreTable);
|
||||||
|
m->add(entry);
|
||||||
|
delete m;
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "background.h"
|
#include "background.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
#include "manage_hiscore_table.h"
|
#include "manage_hiscore_table.h"
|
||||||
|
#include "explosions.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Cantidad de elementos a escribir en los ficheros de datos
|
// Cantidad de elementos a escribir en los ficheros de datos
|
||||||
@@ -114,6 +115,7 @@ private:
|
|||||||
section_t *section; // Seccion actual dentro del juego
|
section_t *section; // Seccion actual dentro del juego
|
||||||
Scoreboard *scoreboard; // Objeto para dibujar el marcador
|
Scoreboard *scoreboard; // Objeto para dibujar el marcador
|
||||||
Background *background; // Objeto para dibujar el fondo del juego
|
Background *background; // Objeto para dibujar el fondo del juego
|
||||||
|
Explosions *explosions; // Objeto para dibujar explosiones
|
||||||
SDL_Texture *canvas; // Textura para dibujar la zona de juego
|
SDL_Texture *canvas; // Textura para dibujar la zona de juego
|
||||||
|
|
||||||
std::vector<Player *> players; // Vector con los jugadores
|
std::vector<Player *> players; // Vector con los jugadores
|
||||||
@@ -125,6 +127,7 @@ private:
|
|||||||
Texture *bulletTexture; // Textura para las balas
|
Texture *bulletTexture; // Textura para las balas
|
||||||
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
|
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
|
||||||
std::vector<Texture *> balloonTextures; // Vector con las texturas de los globos
|
std::vector<Texture *> balloonTextures; // Vector con las texturas de los globos
|
||||||
|
std::vector<Texture *> explosionsTextures; // Vector con las texturas de las explosiones
|
||||||
std::vector<Texture *> player1Textures; // Vector con las texturas del jugador
|
std::vector<Texture *> player1Textures; // Vector con las texturas del jugador
|
||||||
std::vector<Texture *> player2Textures; // Vector con las texturas del jugador
|
std::vector<Texture *> player2Textures; // Vector con las texturas del jugador
|
||||||
std::vector<std::vector<Texture *>> playerTextures; // Vector con todas las texturas de los jugadores;
|
std::vector<std::vector<Texture *>> playerTextures; // Vector con todas las texturas de los jugadores;
|
||||||
@@ -133,9 +136,10 @@ private:
|
|||||||
Texture *gameOverTexture; // Textura para la pantalla de game over
|
Texture *gameOverTexture; // Textura para la pantalla de game over
|
||||||
Texture *gameOverEndTexture; // Textura para la pantalla de game over de acabar el juego
|
Texture *gameOverEndTexture; // Textura para la pantalla de game over de acabar el juego
|
||||||
|
|
||||||
std::vector<std::vector<std::string> *> itemAnimations; // Vector con las animaciones de los items
|
std::vector<std::vector<std::string> *> itemAnimations; // Vector con las animaciones de los items
|
||||||
std::vector<std::vector<std::string> *> playerAnimations; // Vector con las animaciones del jugador
|
std::vector<std::vector<std::string> *> playerAnimations; // Vector con las animaciones del jugador
|
||||||
std::vector<std::vector<std::string> *> balloonAnimations; // Vector con las animaciones de los globos
|
std::vector<std::vector<std::string> *> balloonAnimations; // Vector con las animaciones de los globos
|
||||||
|
std::vector<std::vector<std::string> *> explosionsAnimations; // Vector con las animaciones de las explosiones
|
||||||
|
|
||||||
Text *text; // Fuente para los textos del juego
|
Text *text; // Fuente para los textos del juego
|
||||||
Text *textBig; // Fuente de texto grande
|
Text *textBig; // Fuente de texto grande
|
||||||
@@ -149,9 +153,6 @@ private:
|
|||||||
SmartSprite *n2500Sprite; // Sprite con el texto 2.500
|
SmartSprite *n2500Sprite; // Sprite con el texto 2.500
|
||||||
SmartSprite *n5000Sprite; // Sprite con el texto 5.000
|
SmartSprite *n5000Sprite; // Sprite con el texto 5.000
|
||||||
|
|
||||||
Sprite *gameOverSprite; // Sprite para dibujar los graficos del game over
|
|
||||||
Sprite *gameOverEndSprite; // Sprite para dibujar los graficos del game over de acabar el juego
|
|
||||||
|
|
||||||
JA_Sound_t *balloonSound; // Sonido para la explosión del globo
|
JA_Sound_t *balloonSound; // Sonido para la explosión del globo
|
||||||
JA_Sound_t *bulletSound; // Sonido para los disparos
|
JA_Sound_t *bulletSound; // Sonido para los disparos
|
||||||
JA_Sound_t *playerCollisionSound; // Sonido para la colisión del jugador con un enemigo
|
JA_Sound_t *playerCollisionSound; // Sonido para la colisión del jugador con un enemigo
|
||||||
@@ -226,6 +227,9 @@ private:
|
|||||||
// Carga los recursos necesarios para la sección 'Game'
|
// Carga los recursos necesarios para la sección 'Game'
|
||||||
void loadMedia();
|
void loadMedia();
|
||||||
|
|
||||||
|
// Libera los recursos previamente cargados
|
||||||
|
void unloadMedia();
|
||||||
|
|
||||||
// Carga el fichero de puntos
|
// Carga el fichero de puntos
|
||||||
bool loadScoreFile();
|
bool loadScoreFile();
|
||||||
|
|
||||||
@@ -253,9 +257,6 @@ private:
|
|||||||
// Aumenta el poder de la fase
|
// Aumenta el poder de la fase
|
||||||
void increaseStageCurrentPower(int power);
|
void increaseStageCurrentPower(int power);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setHiScore(Uint32 score);
|
|
||||||
|
|
||||||
// Actualiza el valor de HiScore en caso necesario
|
// Actualiza el valor de HiScore en caso necesario
|
||||||
void updateHiScore();
|
void updateHiScore();
|
||||||
|
|
||||||
@@ -448,7 +449,7 @@ private:
|
|||||||
// Recarga las texturas
|
// Recarga las texturas
|
||||||
void reloadTextures();
|
void reloadTextures();
|
||||||
|
|
||||||
// Establece la máxima puntuación desde fichero o desde las puntuaciones online
|
// Carga las puntuaciones desde el fichero y establece la máxima puntuación
|
||||||
void setHiScore();
|
void setHiScore();
|
||||||
|
|
||||||
// Actualiza el marcador
|
// Actualiza el marcador
|
||||||
@@ -466,6 +467,9 @@ private:
|
|||||||
// Comprueba si la música ha de estar sonando
|
// Comprueba si la música ha de estar sonando
|
||||||
void checkMusicStatus();
|
void checkMusicStatus();
|
||||||
|
|
||||||
|
// Añade una puntuación a la tabla de records
|
||||||
|
void addScoreToScoreBoard(std::string name, int score);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
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, JA_Music_t *music);
|
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, JA_Music_t *music);
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ GameLogo::GameLogo(SDL_Renderer *renderer, Screen *screen, Asset *asset, param_t
|
|||||||
crisisTexture = new Texture(renderer, asset->get("title_crisis.png"));
|
crisisTexture = new Texture(renderer, asset->get("title_crisis.png"));
|
||||||
arcadeEditionTexture = new Texture(renderer, asset->get("title_arcade_edition.png"));
|
arcadeEditionTexture = new Texture(renderer, asset->get("title_arcade_edition.png"));
|
||||||
|
|
||||||
coffeeBitmap = new SmartSprite(coffeeTexture, renderer);
|
coffeeBitmap = new SmartSprite(coffeeTexture);
|
||||||
crisisBitmap = new SmartSprite(crisisTexture, renderer);
|
crisisBitmap = new SmartSprite(crisisTexture);
|
||||||
arcadeEditionBitmap = new Sprite((param->gameWidth - arcadeEditionTexture->getWidth()) / 2, param->arcadeEdition, arcadeEditionTexture->getWidth(), arcadeEditionTexture->getHeight(), arcadeEditionTexture, renderer);
|
arcadeEditionBitmap = new Sprite((param->gameWidth - arcadeEditionTexture->getWidth()) / 2, param->arcadeEdition, arcadeEditionTexture->getWidth(), arcadeEditionTexture->getHeight(), arcadeEditionTexture);
|
||||||
dustBitmapL = new AnimatedSprite(dustTexture, renderer, asset->get("title_dust.ani"));
|
dustBitmapL = new AnimatedSprite(dustTexture, asset->get("title_dust.ani"));
|
||||||
dustBitmapR = new AnimatedSprite(dustTexture, renderer, asset->get("title_dust.ani"));
|
dustBitmapR = new AnimatedSprite(dustTexture, asset->get("title_dust.ani"));
|
||||||
|
|
||||||
// Sonidos
|
// Sonidos
|
||||||
crashSound = JA_LoadSound(asset->get("title.wav").c_str());
|
crashSound = JA_LoadSound(asset->get("title.wav").c_str());
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ void Instructions::iniSprites()
|
|||||||
// Inicializa los sprites
|
// Inicializa los sprites
|
||||||
for (int i = 0; i < (int)itemTextures.size(); ++i)
|
for (int i = 0; i < (int)itemTextures.size(); ++i)
|
||||||
{
|
{
|
||||||
Sprite *sprite = new Sprite(0, 0, param->itemSize, param->itemSize, itemTextures[i], renderer);
|
Sprite *sprite = new Sprite(0, 0, param->itemSize, param->itemSize, itemTextures[i]);
|
||||||
sprite->setPos({spritePos.x, spritePos.y + ((param->itemSize + itemSpace) * i), param->itemSize, param->itemSize});
|
sprite->setPos({spritePos.x, spritePos.y + ((param->itemSize + itemSpace) * i)});
|
||||||
sprites.push_back(sprite);
|
sprites.push_back(sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input,
|
|||||||
const int totalBitmaps = 6;
|
const int totalBitmaps = 6;
|
||||||
for (int i = 0; i < totalBitmaps; ++i)
|
for (int i = 0; i < totalBitmaps; ++i)
|
||||||
{
|
{
|
||||||
SmartSprite *ss = new SmartSprite(texture, renderer);
|
SmartSprite *ss = new SmartSprite(texture);
|
||||||
ss->setWidth(128);
|
ss->setWidth(128);
|
||||||
ss->setHeight(96);
|
ss->setHeight(96);
|
||||||
ss->setEnabledCounter(20);
|
ss->setEnabledCounter(20);
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Item::Item(int kind, float x, float y, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
Item::Item(int kind, float x, float y, Texture *texture, std::vector<std::string> *animation)
|
||||||
{
|
{
|
||||||
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
sprite = new AnimatedSprite(texture, "", animation);
|
||||||
|
|
||||||
this->kind = kind;
|
this->kind = kind;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
Uint16 timeToLive; // Temporizador con el tiempo que el objeto está presente
|
Uint16 timeToLive; // Temporizador con el tiempo que el objeto está presente
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Item(int kind, float x, float y, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
Item(int kind, float x, float y, Texture *texture, std::vector<std::string> *animation);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Item();
|
~Item();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, p
|
|||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
jailTexture = new Texture(renderer, asset->get("logo_jailgames.png"));
|
jailTexture = new Texture(renderer, asset->get("logo_jailgames.png"));
|
||||||
sinceTexture = new Texture(renderer, asset->get("logo_since_1998.png"));
|
sinceTexture = new Texture(renderer, asset->get("logo_since_1998.png"));
|
||||||
sinceSprite = new Sprite((param->gameWidth - sinceTexture->getWidth()) / 2, 83 + jailTexture->getHeight() + 5, sinceTexture->getWidth(), sinceTexture->getHeight(), sinceTexture, renderer);
|
sinceSprite = new Sprite((param->gameWidth - sinceTexture->getWidth()) / 2, 83 + jailTexture->getHeight() + 5, sinceTexture->getWidth(), sinceTexture->getHeight(), sinceTexture);
|
||||||
sinceSprite->setSpriteClip(0, 0, sinceTexture->getWidth(), sinceTexture->getHeight());
|
sinceSprite->setSpriteClip(0, 0, sinceTexture->getWidth(), sinceTexture->getHeight());
|
||||||
sinceTexture->setColor(0, 0, 0);
|
sinceTexture->setColor(0, 0, 0);
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, p
|
|||||||
// Crea los sprites de cada linea
|
// Crea los sprites de cada linea
|
||||||
for (int i = 0; i < jailTexture->getHeight(); ++i)
|
for (int i = 0; i < jailTexture->getHeight(); ++i)
|
||||||
{
|
{
|
||||||
Sprite *temp = new Sprite(0, i, jailTexture->getWidth(), 1, jailTexture, renderer);
|
Sprite *temp = new Sprite(0, i, jailTexture->getWidth(), 1, jailTexture);
|
||||||
temp->setSpriteClip(0, i, jailTexture->getWidth(), 1);
|
temp->setSpriteClip(0, i, jailTexture->getWidth(), 1);
|
||||||
const int posX = (i % 2 == 0) ? param->gameWidth + (i * 3) : -jailTexture->getWidth() - (i * 3);
|
const int posX = (i % 2 == 0) ? param->gameWidth + (i * 3) : -jailTexture->getWidth() - (i * 3);
|
||||||
temp->setPosX(posX);
|
temp->setPosX(posX);
|
||||||
|
|||||||
@@ -2,14 +2,11 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations)
|
Player::Player(float x, int y, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
|
||||||
this->renderer = renderer;
|
|
||||||
|
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
playerSprite = new AnimatedSprite(texture[0], renderer, "", animations[0]);
|
playerSprite = new AnimatedSprite(texture[0], "", animations[0]);
|
||||||
powerSprite = new AnimatedSprite(texture[1], renderer, "", animations[1]);
|
powerSprite = new AnimatedSprite(texture[1], "", animations[1]);
|
||||||
powerSprite->getTexture()->setAlpha(224);
|
powerSprite->getTexture()->setAlpha(224);
|
||||||
|
|
||||||
// Establece la posición inicial del jugador
|
// Establece la posición inicial del jugador
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class Player
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
AnimatedSprite *playerSprite; // Sprite para dibujar el jugador
|
AnimatedSprite *playerSprite; // Sprite para dibujar el jugador
|
||||||
AnimatedSprite *powerSprite; // Sprite para dibujar el aura del jugador con el poder a tope
|
AnimatedSprite *powerSprite; // Sprite para dibujar el aura del jugador con el poder a tope
|
||||||
|
|
||||||
@@ -72,7 +71,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations);
|
Player(float x, int y, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Player();
|
~Player();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Scoreboard::Scoreboard(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lan
|
|||||||
|
|
||||||
// Crea objetos
|
// Crea objetos
|
||||||
gamePowerMeterTexture = new Texture(renderer, asset->get("game_power_meter.png"));
|
gamePowerMeterTexture = new Texture(renderer, asset->get("game_power_meter.png"));
|
||||||
powerMeterSprite = new Sprite(offsetPowerMeter.x - 20, offsetPowerMeter.y, 40, 7, gamePowerMeterTexture, renderer);
|
powerMeterSprite = new Sprite(offsetPowerMeter.x - 20, offsetPowerMeter.y, 40, 7, gamePowerMeterTexture);
|
||||||
textScoreBoard = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer);
|
textScoreBoard = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer);
|
||||||
|
|
||||||
// Crea la textura para dibujar el marcador
|
// Crea la textura para dibujar el marcador
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ void Tiledbg::fillTexture()
|
|||||||
{
|
{
|
||||||
// Crea los objetos para pintar en la textura de fondo
|
// Crea los objetos para pintar en la textura de fondo
|
||||||
Texture *bgTileTexture = new Texture(renderer, asset->get("title_bg_tile.png"));
|
Texture *bgTileTexture = new Texture(renderer, asset->get("title_bg_tile.png"));
|
||||||
Sprite *tile = new Sprite({0, 0, tileWidth, tileHeight}, bgTileTexture, renderer);
|
Sprite *tile = new Sprite({0, 0, tileWidth, tileHeight}, bgTileTexture);
|
||||||
|
|
||||||
// Prepara para dibujar sobre la textura
|
// Prepara para dibujar sobre la textura
|
||||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
|||||||
text2 = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer);
|
text2 = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer);
|
||||||
|
|
||||||
miniLogoTexture = new Texture(renderer, asset->get("logo_jailgames_mini.png"));
|
miniLogoTexture = new Texture(renderer, asset->get("logo_jailgames_mini.png"));
|
||||||
miniLogoSprite = new Sprite(GAMECANVAS_CENTER_X - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture, renderer);
|
miniLogoSprite = new Sprite(GAMECANVAS_CENTER_X - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture);
|
||||||
|
|
||||||
tiledbg = new Tiledbg(renderer, screen, asset, {0, 0, param->gameWidth, param->gameHeight}, TILED_MODE_RANDOM);
|
tiledbg = new Tiledbg(renderer, screen, asset, {0, 0, param->gameWidth, param->gameHeight}, TILED_MODE_RANDOM);
|
||||||
|
|
||||||
gameLogo = new GameLogo(renderer, screen, asset, param, GAMECANVAS_CENTER_X, param->titleCC);
|
gameLogo = new GameLogo(renderer, screen, asset, param, GAMECANVAS_CENTER_X, param->titleCC);
|
||||||
gameLogo->enable();
|
gameLogo->enable();
|
||||||
|
|
||||||
defineButtons = new DefineButtons(renderer, input, text2, param, options, section);
|
defineButtons = new DefineButtons(input, text2, param, options, section);
|
||||||
|
|
||||||
// Inicializa los valores
|
// Inicializa los valores
|
||||||
init();
|
init();
|
||||||
|
|||||||