añadido a param.txt los parametros de los globos para velocidad y gravedad
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
# GAME
|
## GAME
|
||||||
gameWidth 320
|
gameWidth 320
|
||||||
gameHeight 240
|
gameHeight 240
|
||||||
itemSize 20
|
itemSize 20
|
||||||
|
|
||||||
# FADE
|
## FADE
|
||||||
numSquaresWidth 160
|
numSquaresWidth 160
|
||||||
numSquaresHeight 120
|
numSquaresHeight 120
|
||||||
fadeRandomSquaresDelay 1
|
fadeRandomSquaresDelay 1
|
||||||
@@ -11,20 +11,33 @@ fadeRandomSquaresMult 500
|
|||||||
fadePostDuration 80
|
fadePostDuration 80
|
||||||
venetianSize 16
|
venetianSize 16
|
||||||
|
|
||||||
# SCOREBOARD
|
## SCOREBOARD
|
||||||
scoreboard.x 0
|
scoreboard.x 0
|
||||||
scoreboard.y 200
|
scoreboard.y 200
|
||||||
scoreboard.w 320
|
scoreboard.w 320
|
||||||
scoreboard.h 40
|
scoreboard.h 40
|
||||||
|
|
||||||
# TITLE
|
## TITLE
|
||||||
pressStart 170
|
pressStart 170
|
||||||
titleCounter 800
|
titleCounter 800
|
||||||
arcadeEdition 123
|
arcadeEdition 123
|
||||||
titleCC 80
|
titleCC 80
|
||||||
|
|
||||||
# BACKGROUND
|
## BACKGROUND
|
||||||
backgroundAttenuateColor.r 255
|
backgroundAttenuateColor.r 255
|
||||||
backgroundAttenuateColor.g 255
|
backgroundAttenuateColor.g 255
|
||||||
backgroundAttenuateColor.b 255
|
backgroundAttenuateColor.b 255
|
||||||
backgroundAttenuateColor.a 0
|
backgroundAttenuateColor.a 0
|
||||||
|
|
||||||
|
## BALLOONS
|
||||||
|
balloon1.vel 2.6f
|
||||||
|
balloon1.grav 0.09f
|
||||||
|
|
||||||
|
balloon2.vel 3.5f
|
||||||
|
balloon2.grav 0.10f
|
||||||
|
|
||||||
|
balloon3.vel 4.50f
|
||||||
|
balloon3.grav 0.10f
|
||||||
|
|
||||||
|
balloon4.vel 4.95f
|
||||||
|
balloon4.grav 0.10f
|
||||||
@@ -2,8 +2,9 @@
|
|||||||
#include "balloon.h"
|
#include "balloon.h"
|
||||||
|
|
||||||
// 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, param_t *param)
|
||||||
{
|
{
|
||||||
|
this->param = param;
|
||||||
sprite = new AnimatedSprite(texture, "", animation);
|
sprite = new AnimatedSprite(texture, "", animation);
|
||||||
disable();
|
disable();
|
||||||
|
|
||||||
@@ -22,8 +23,8 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
this->velX = velx;
|
this->velX = velx;
|
||||||
velY = 0;
|
velY = 0;
|
||||||
maxVelY = 3.0f;
|
maxVelY = 3.0f;
|
||||||
gravity = 0.09f;
|
gravity = param->balloon1.grav;
|
||||||
defaultVelY = 2.6f;
|
defaultVelY = param->balloon1.vel;
|
||||||
|
|
||||||
// Puntos que da el globo al ser destruido
|
// Puntos que da el globo al ser destruido
|
||||||
score = BALLOON_SCORE_1;
|
score = BALLOON_SCORE_1;
|
||||||
@@ -44,8 +45,8 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
this->velX = velx;
|
this->velX = velx;
|
||||||
velY = 0;
|
velY = 0;
|
||||||
maxVelY = 3.0f;
|
maxVelY = 3.0f;
|
||||||
gravity = 0.10f;
|
gravity = param->balloon2.grav;
|
||||||
defaultVelY = 3.5f;
|
defaultVelY = param->balloon2.vel;
|
||||||
|
|
||||||
// Puntos que da el globo al ser destruido
|
// Puntos que da el globo al ser destruido
|
||||||
score = BALLOON_SCORE_2;
|
score = BALLOON_SCORE_2;
|
||||||
@@ -66,8 +67,8 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
this->velX = velx;
|
this->velX = velx;
|
||||||
velY = 0;
|
velY = 0;
|
||||||
maxVelY = 3.0f;
|
maxVelY = 3.0f;
|
||||||
gravity = 0.10f;
|
gravity = param->balloon3.grav;
|
||||||
defaultVelY = 4.50f;
|
defaultVelY = param->balloon3.vel;
|
||||||
|
|
||||||
// Puntos que da el globo al ser destruido
|
// Puntos que da el globo al ser destruido
|
||||||
score = BALLOON_SCORE_3;
|
score = BALLOON_SCORE_3;
|
||||||
@@ -88,8 +89,8 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
|
|||||||
this->velX = velx;
|
this->velX = velx;
|
||||||
velY = 0;
|
velY = 0;
|
||||||
maxVelY = 3.0f;
|
maxVelY = 3.0f;
|
||||||
gravity = 0.10f;
|
gravity = param->balloon4.grav;
|
||||||
defaultVelY = 4.95f;
|
defaultVelY = param->balloon4.vel;
|
||||||
|
|
||||||
// Puntos que da el globo al ser destruido
|
// Puntos que da el globo al ser destruido
|
||||||
score = BALLOON_SCORE_4;
|
score = BALLOON_SCORE_4;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ private:
|
|||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
AnimatedSprite *sprite; // Sprite del objeto globo
|
AnimatedSprite *sprite; // Sprite del objeto globo
|
||||||
|
param_t *param; // Puntero con todos los parametros del programa
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
float posX; // Posición en el eje X
|
float posX; // Posición en el eje X
|
||||||
@@ -139,7 +140,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, param_t *param);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Balloon();
|
~Balloon();
|
||||||
|
|||||||
@@ -171,6 +171,13 @@ struct options_t
|
|||||||
std::vector<op_controller_t> controller; // Opciones con las asignaciones del mando para cada jugador
|
std::vector<op_controller_t> controller; // Opciones con las asignaciones del mando para cada jugador
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Estructura para guardar los parametros de un globo
|
||||||
|
struct balloon_t
|
||||||
|
{
|
||||||
|
float grav; // Aceleración en el eje Y. Modifica la velocidad
|
||||||
|
float vel; // Velocidad inicial que tienen al rebotar contra el suelo
|
||||||
|
};
|
||||||
|
|
||||||
// Estructura para almacenar todos los parámetros del juego
|
// Estructura para almacenar todos los parámetros del juego
|
||||||
struct param_t
|
struct param_t
|
||||||
{
|
{
|
||||||
@@ -199,6 +206,9 @@ struct param_t
|
|||||||
// BACKGROUND
|
// BACKGROUND
|
||||||
color_t backgroundAttenuateColor;
|
color_t backgroundAttenuateColor;
|
||||||
int backgroundAttenuateAlpha;
|
int backgroundAttenuateAlpha;
|
||||||
|
|
||||||
|
// BALLOONS
|
||||||
|
balloon_t balloon1, balloon2, balloon3, balloon4; // Parametros de velocidad y gravedad de cada tipo de globo
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar ficheros de sonido y su nombre
|
// Estructura para almacenar ficheros de sonido y su nombre
|
||||||
|
|||||||
@@ -1071,7 +1071,7 @@ void Game::renderBalloons()
|
|||||||
int Game::createBalloon(float x, int y, int kind, float velx, float speed, int creationtimer)
|
int Game::createBalloon(float x, int y, int kind, float velx, float speed, int creationtimer)
|
||||||
{
|
{
|
||||||
const int index = (kind - 1) % 4;
|
const int index = (kind - 1) % 4;
|
||||||
Balloon *b = new Balloon(x, y, kind, velx, speed, creationtimer, balloonTextures[index], balloonAnimations[index], renderer);
|
Balloon *b = new Balloon(x, y, kind, velx, speed, creationtimer, balloonTextures[index], balloonAnimations[index], param);
|
||||||
balloons.push_back(b);
|
balloons.push_back(b);
|
||||||
return (int)(balloons.size() - 1);
|
return (int)(balloons.size() - 1);
|
||||||
}
|
}
|
||||||
@@ -1089,7 +1089,7 @@ void Game::createPowerBall()
|
|||||||
const int x[3] = {left, center, right};
|
const int x[3] = {left, center, right};
|
||||||
const float vx[3] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE};
|
const float vx[3] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE};
|
||||||
|
|
||||||
Balloon *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 100, balloonTextures[4], balloonAnimations[4], renderer);
|
Balloon *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 100, balloonTextures[4], balloonAnimations[4], param);
|
||||||
balloons.push_back(b);
|
balloons.push_back(b);
|
||||||
|
|
||||||
powerBallEnabled = true;
|
powerBallEnabled = true;
|
||||||
|
|||||||
@@ -33,6 +33,16 @@ void initParam(param_t *param)
|
|||||||
// BACKGROUND
|
// BACKGROUND
|
||||||
param->backgroundAttenuateColor = {255, 255, 255};
|
param->backgroundAttenuateColor = {255, 255, 255};
|
||||||
param->backgroundAttenuateAlpha = 32;
|
param->backgroundAttenuateAlpha = 32;
|
||||||
|
|
||||||
|
// BALLOONS
|
||||||
|
param->balloon1.vel = 2.60f;
|
||||||
|
param->balloon1.grav = 0.09f;
|
||||||
|
param->balloon2.vel = 3.50f;
|
||||||
|
param->balloon2.grav = 0.10f;
|
||||||
|
param->balloon3.vel = 4.50f;
|
||||||
|
param->balloon3.grav = 0.10f;
|
||||||
|
param->balloon4.vel = 4.95f;
|
||||||
|
param->balloon4.grav = 0.10f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece valores para los parametros a partir de un fichero de texto
|
// Establece valores para los parametros a partir de un fichero de texto
|
||||||
@@ -238,6 +248,47 @@ bool setOptions(param_t *param, std::string var, std::string value)
|
|||||||
param->backgroundAttenuateAlpha = std::stoi(value);
|
param->backgroundAttenuateAlpha = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BALLOON
|
||||||
|
else if (var == "balloon1.vel")
|
||||||
|
{
|
||||||
|
param->balloon1.vel = std::stof(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var == "balloon1.grav")
|
||||||
|
{
|
||||||
|
param->balloon1.grav = std::stof(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var == "balloon2.vel")
|
||||||
|
{
|
||||||
|
param->balloon2.vel = std::stof(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var == "balloon2.grav")
|
||||||
|
{
|
||||||
|
param->balloon2.grav = std::stof(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var == "balloon3.vel")
|
||||||
|
{
|
||||||
|
param->balloon3.vel = std::stof(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var == "balloon3.grav")
|
||||||
|
{
|
||||||
|
param->balloon3.grav = std::stof(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var == "balloon4.vel")
|
||||||
|
{
|
||||||
|
param->balloon4.vel = std::stof(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (var == "balloon4.grav")
|
||||||
|
{
|
||||||
|
param->balloon4.grav = std::stof(value);
|
||||||
|
}
|
||||||
|
|
||||||
// RESTO
|
// RESTO
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user