Convertit "param" a variable global en lloc de anar marejant amb punterets i passant 8.000.000 de paràmetres
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
#include "background.h"
|
#include "background.h"
|
||||||
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Background::Background(SDL_Renderer *renderer, Asset *asset, param_t *param)
|
Background::Background(SDL_Renderer *renderer, Asset *asset)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->param = param;
|
|
||||||
|
|
||||||
// Carga las texturas
|
// Carga las texturas
|
||||||
buildingsTexture = new Texture(renderer, asset->get("game_buildings.png"));
|
buildingsTexture = new Texture(renderer, asset->get("game_buildings.png"));
|
||||||
@@ -27,8 +27,8 @@ Background::Background(SDL_Renderer *renderer, Asset *asset, param_t *param)
|
|||||||
dstRect = {0, 0, 320, 240};
|
dstRect = {0, 0, 320, 240};
|
||||||
|
|
||||||
base = rect.h;
|
base = rect.h;
|
||||||
color = {param->background.attenuateColor.r, param->background.attenuateColor.g, param->background.attenuateColor.b};
|
color = {param.background.attenuateColor.r, param.background.attenuateColor.g, param.background.attenuateColor.b};
|
||||||
alphaColorText = alphaColorTextTemp = param->background.attenuateAlpha;
|
alphaColorText = alphaColorTextTemp = param.background.attenuateAlpha;
|
||||||
|
|
||||||
gradientRect[0] = {0, 0, rect.w, rect.h};
|
gradientRect[0] = {0, 0, rect.w, rect.h};
|
||||||
gradientRect[1] = {rect.w, 0, rect.w, rect.h};
|
gradientRect[1] = {rect.w, 0, rect.w, rect.h};
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/screen.h"
|
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
#include "common/movingsprite.h"
|
#include "common/movingsprite.h"
|
||||||
|
#include "common/utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Esta clase es la encargada de dibujar el fondo que aparece durante la sección
|
Esta clase es la encargada de dibujar el fondo que aparece durante la sección
|
||||||
@@ -68,8 +68,6 @@ private:
|
|||||||
SDL_Texture *canvas; // Textura para componer el fondo
|
SDL_Texture *canvas; // Textura para componer el fondo
|
||||||
SDL_Texture *colorTexture; // Textura para atenuar el fondo
|
SDL_Texture *colorTexture; // Textura para atenuar el fondo
|
||||||
|
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
SDL_Rect gradientRect[4]; // Vector con las coordenadas de los 4 degradados para el cielo
|
SDL_Rect gradientRect[4]; // Vector con las coordenadas de los 4 degradados para el cielo
|
||||||
SDL_Rect topCloudsRect[4]; // Vector con las coordenadas de los 4 nubes de arriba
|
SDL_Rect topCloudsRect[4]; // Vector con las coordenadas de los 4 nubes de arriba
|
||||||
@@ -107,7 +105,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Background(SDL_Renderer *renderer, Asset *asset, param_t *param);
|
Background(SDL_Renderer *renderer, Asset *asset);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Background();
|
~Background();
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "const.h"
|
|
||||||
#include "balloon.h"
|
#include "balloon.h"
|
||||||
|
#include "const.h"
|
||||||
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, param_t *param)
|
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation)
|
||||||
{
|
{
|
||||||
this->param = param;
|
|
||||||
sprite = new AnimatedSprite(texture, "", animation);
|
sprite = new AnimatedSprite(texture, "", animation);
|
||||||
disable();
|
disable();
|
||||||
|
|
||||||
@@ -23,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 = param->balloon1.grav;
|
gravity = param.balloon1.grav;
|
||||||
defaultVelY = param->balloon1.vel;
|
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;
|
||||||
@@ -45,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 = param->balloon2.grav;
|
gravity = param.balloon2.grav;
|
||||||
defaultVelY = param->balloon2.vel;
|
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;
|
||||||
@@ -67,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 = param->balloon3.grav;
|
gravity = param.balloon3.grav;
|
||||||
defaultVelY = param->balloon3.vel;
|
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;
|
||||||
@@ -89,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 = param->balloon4.grav;
|
gravity = param.balloon4.grav;
|
||||||
defaultVelY = param->balloon4.vel;
|
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;
|
||||||
@@ -199,8 +199,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 = param->balloon4.grav;
|
gravity = param.balloon4.grav;
|
||||||
defaultVelY = param->balloon4.vel;
|
defaultVelY = param.balloon4.vel;
|
||||||
|
|
||||||
// Puntos que da el globo al ser destruido
|
// Puntos que da el globo al ser destruido
|
||||||
score = 0;
|
score = 0;
|
||||||
@@ -285,9 +285,9 @@ void Balloon::allignTo(int x)
|
|||||||
{
|
{
|
||||||
posX = PLAY_AREA_LEFT + 1;
|
posX = PLAY_AREA_LEFT + 1;
|
||||||
}
|
}
|
||||||
else if ((posX + width) > param->game.playArea.rect.w)
|
else if ((posX + width) > param.game.playArea.rect.w)
|
||||||
{
|
{
|
||||||
posX = float(param->game.playArea.rect.w - width - 1);
|
posX = float(param.game.playArea.rect.w - width - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Posición X,Y del sprite
|
// Posición X,Y del sprite
|
||||||
@@ -347,7 +347,7 @@ void Balloon::move()
|
|||||||
posX += (velX * speed);
|
posX += (velX * speed);
|
||||||
|
|
||||||
// Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido
|
// Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido
|
||||||
if ((posX < PLAY_AREA_LEFT) || (posX + width > param->game.playArea.rect.w))
|
if ((posX < PLAY_AREA_LEFT) || (posX + width > param.game.playArea.rect.w))
|
||||||
{
|
{
|
||||||
// Corrige posición
|
// Corrige posición
|
||||||
posX -= (velX * speed);
|
posX -= (velX * speed);
|
||||||
@@ -385,10 +385,10 @@ void Balloon::move()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si el globo se sale por la parte inferior
|
// Si el globo se sale por la parte inferior
|
||||||
if (posY + height > param->game.playArea.rect.h)
|
if (posY + height > param.game.playArea.rect.h)
|
||||||
{
|
{
|
||||||
// Corrige
|
// Corrige
|
||||||
posY = param->game.playArea.rect.h - height;
|
posY = param.game.playArea.rect.h - height;
|
||||||
|
|
||||||
// Invierte colocando una velocidad por defecto
|
// Invierte colocando una velocidad por defecto
|
||||||
velY = -defaultVelY;
|
velY = -defaultVelY;
|
||||||
@@ -508,7 +508,7 @@ void Balloon::updateState()
|
|||||||
posX += velX;
|
posX += velX;
|
||||||
|
|
||||||
// Comprueba no se salga por los laterales
|
// Comprueba no se salga por los laterales
|
||||||
if ((posX < PLAY_AREA_LEFT) || (posX > (param->game.playArea.rect.w - width)))
|
if ((posX < PLAY_AREA_LEFT) || (posX > (param.game.playArea.rect.w - width)))
|
||||||
{
|
{
|
||||||
// Corrige y cambia el sentido de la velocidad
|
// Corrige y cambia el sentido de la velocidad
|
||||||
posX -= velX;
|
posX -= velX;
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ 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
|
||||||
@@ -140,7 +139,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, param_t *param);
|
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Balloon();
|
~Balloon();
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
#include "define_buttons.h"
|
#include "define_buttons.h"
|
||||||
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
DefineButtons::DefineButtons(Input *input, Text *text, param_t *param, options_t *options, section_t *section)
|
DefineButtons::DefineButtons(Input *input, Text *text, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia punteros a los objetos
|
// Copia punteros a los objetos
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->text = text;
|
this->text = text;
|
||||||
this->param = param;
|
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
enabled = false;
|
enabled = false;
|
||||||
x = param->game.width / 2;
|
x = param.game.width / 2;
|
||||||
y = param->title.pressStartPosition;
|
y = param.title.pressStartPosition;
|
||||||
indexController = 0;
|
indexController = 0;
|
||||||
indexButton = 0;
|
indexButton = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ private:
|
|||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
options_t *options; // Opciones del programa
|
options_t *options; // Opciones del programa
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
section_t *section; // Indicador para el bucle del titulo
|
section_t *section; // Indicador para el bucle del titulo
|
||||||
bool enabled; // Indica si el objeto está habilitado
|
bool enabled; // Indica si el objeto está habilitado
|
||||||
int x; // Posición donde dibujar el texto
|
int x; // Posición donde dibujar el texto
|
||||||
@@ -47,7 +46,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
DefineButtons(Input *input, Text *text, param_t *param, options_t *options, section_t *section);
|
DefineButtons(Input *input, Text *text, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~DefineButtons();
|
~DefineButtons();
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ Director::~Director()
|
|||||||
delete input;
|
delete input;
|
||||||
delete screen;
|
delete screen;
|
||||||
delete options;
|
delete options;
|
||||||
delete param;
|
|
||||||
delete section;
|
delete section;
|
||||||
|
|
||||||
deleteSounds();
|
deleteSounds();
|
||||||
@@ -247,7 +246,7 @@ bool Director::initSDL()
|
|||||||
SDL_DisplayMode DM;
|
SDL_DisplayMode DM;
|
||||||
SDL_GetCurrentDisplayMode(0, &DM);
|
SDL_GetCurrentDisplayMode(0, &DM);
|
||||||
std::cout << "\nCurrent display mode: " + std::to_string(DM.w) + "x" + std::to_string(DM.h) + " @ " + std::to_string(DM.refresh_rate) + "Hz" << std::endl;
|
std::cout << "\nCurrent display mode: " + std::to_string(DM.w) + "x" + std::to_string(DM.h) + " @ " + std::to_string(DM.refresh_rate) + "Hz" << std::endl;
|
||||||
std::cout << "Window resolution : " + std::to_string(param->game.width) + "x" + std::to_string(param->game.height) + " x" + std::to_string(options->video.window.size) << std::endl;
|
std::cout << "Window resolution : " + std::to_string(param.game.width) + "x" + std::to_string(param.game.height) + " x" + std::to_string(options->video.window.size) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el filtro de la textura
|
// Establece el filtro de la textura
|
||||||
@@ -268,7 +267,7 @@ bool Director::initSDL()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Crea la ventana
|
// Crea la ventana
|
||||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, param->game.width * options->video.window.size, param->game.height * options->video.window.size, SDL_WINDOW_HIDDEN);
|
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, param.game.width * options->video.window.size, param.game.height * options->video.window.size, SDL_WINDOW_HIDDEN);
|
||||||
if (window == nullptr)
|
if (window == nullptr)
|
||||||
{
|
{
|
||||||
if (options->console)
|
if (options->console)
|
||||||
@@ -305,7 +304,7 @@ bool Director::initSDL()
|
|||||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||||
|
|
||||||
// Establece el tamaño del buffer de renderizado
|
// Establece el tamaño del buffer de renderizado
|
||||||
SDL_RenderSetLogicalSize(renderer, param->game.width, param->game.height);
|
SDL_RenderSetLogicalSize(renderer, param.game.width, param.game.height);
|
||||||
|
|
||||||
// Establece el modo de mezcla
|
// Establece el modo de mezcla
|
||||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||||
@@ -467,15 +466,13 @@ bool Director::setFileList()
|
|||||||
// Carga los parametros para configurar el juego
|
// Carga los parametros para configurar el juego
|
||||||
void Director::loadParams(std::string filepath)
|
void Director::loadParams(std::string filepath)
|
||||||
{
|
{
|
||||||
param = new param_t;
|
loadParamsFromFile(filepath);
|
||||||
|
|
||||||
loadParamsFromFile(param, filepath);
|
|
||||||
|
|
||||||
// Modifica las opciones desde el fichero de parametros
|
// Modifica las opciones desde el fichero de parametros
|
||||||
options->video.window.width = options->video.window.size * param->game.width;
|
options->video.window.width = options->video.window.size * param.game.width;
|
||||||
options->video.window.height = options->video.window.size * param->game.height;
|
options->video.window.height = options->video.window.size * param.game.height;
|
||||||
options->video.gameWidth = param->game.width;
|
options->video.gameWidth = param.game.width;
|
||||||
options->video.gameHeight = param->game.height;
|
options->video.gameHeight = param.game.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa las opciones del programa
|
// Inicializa las opciones del programa
|
||||||
@@ -886,7 +883,7 @@ void Director::deleteMusics()
|
|||||||
// Ejecuta la sección con el logo
|
// Ejecuta la sección con el logo
|
||||||
void Director::runLogo()
|
void Director::runLogo()
|
||||||
{
|
{
|
||||||
logo = new Logo(screen, asset, input, options, param, section);
|
logo = new Logo(screen, asset, input, options, section);
|
||||||
logo->run();
|
logo->run();
|
||||||
delete logo;
|
delete logo;
|
||||||
}
|
}
|
||||||
@@ -894,7 +891,7 @@ void Director::runLogo()
|
|||||||
// Ejecuta la sección con la secuencia de introducción
|
// Ejecuta la sección con la secuencia de introducción
|
||||||
void Director::runIntro()
|
void Director::runIntro()
|
||||||
{
|
{
|
||||||
intro = new Intro(screen, asset, input, options, param, section, getMusic(musics, "intro.ogg"));
|
intro = new Intro(screen, asset, input, options, section, getMusic(musics, "intro.ogg"));
|
||||||
intro->run();
|
intro->run();
|
||||||
delete intro;
|
delete intro;
|
||||||
}
|
}
|
||||||
@@ -902,7 +899,7 @@ void Director::runIntro()
|
|||||||
// Ejecuta la sección con el titulo del juego
|
// Ejecuta la sección con el titulo del juego
|
||||||
void Director::runTitle()
|
void Director::runTitle()
|
||||||
{
|
{
|
||||||
title = new Title(screen, asset, input, options, param, section, getMusic(musics, "title.ogg"));
|
title = new Title(screen, asset, input, options, section, getMusic(musics, "title.ogg"));
|
||||||
title->run();
|
title->run();
|
||||||
delete title;
|
delete title;
|
||||||
}
|
}
|
||||||
@@ -912,7 +909,7 @@ void Director::runGame()
|
|||||||
{
|
{
|
||||||
const int playerID = section->options;
|
const int playerID = section->options;
|
||||||
const int currentStage = 0;
|
const int currentStage = 0;
|
||||||
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, options, param, section, getMusic(musics, "playing.ogg"));
|
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, screen, asset, input, options, section, getMusic(musics, "playing.ogg"));
|
||||||
game->run();
|
game->run();
|
||||||
delete game;
|
delete game;
|
||||||
}
|
}
|
||||||
@@ -920,7 +917,7 @@ void Director::runGame()
|
|||||||
// Ejecuta la sección donde se muestran las instrucciones
|
// Ejecuta la sección donde se muestran las instrucciones
|
||||||
void Director::runInstructions()
|
void Director::runInstructions()
|
||||||
{
|
{
|
||||||
instructions = new Instructions(screen, asset, input, options, param, section, getMusic(musics, "title.ogg"));
|
instructions = new Instructions(screen, asset, input, options, section, getMusic(musics, "title.ogg"));
|
||||||
instructions->run();
|
instructions->run();
|
||||||
delete instructions;
|
delete instructions;
|
||||||
}
|
}
|
||||||
@@ -928,7 +925,7 @@ void Director::runInstructions()
|
|||||||
// Ejecuta la sección donde se muestra la tabla de puntuaciones
|
// Ejecuta la sección donde se muestra la tabla de puntuaciones
|
||||||
void Director::runHiScoreTable()
|
void Director::runHiScoreTable()
|
||||||
{
|
{
|
||||||
hiScoreTable = new HiScoreTable(screen, asset, input, options, param, section, getMusic(musics, "title.ogg"));
|
hiScoreTable = new HiScoreTable(screen, asset, input, options, section, getMusic(musics, "title.ogg"));
|
||||||
hiScoreTable->run();
|
hiScoreTable->run();
|
||||||
delete hiScoreTable;
|
delete hiScoreTable;
|
||||||
}
|
}
|
||||||
@@ -938,7 +935,7 @@ void Director::runDemoGame()
|
|||||||
{
|
{
|
||||||
const int playerID = (rand() % 2) + 1;
|
const int playerID = (rand() % 2) + 1;
|
||||||
const int currentStage = 0;
|
const int currentStage = 0;
|
||||||
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, screen, asset, input, options, param, section, nullptr);
|
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, screen, asset, input, options, section, nullptr);
|
||||||
demoGame->run();
|
demoGame->run();
|
||||||
delete demoGame;
|
delete demoGame;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "title.h"
|
#include "title.h"
|
||||||
#include "load_param.h"
|
#include "param.h"
|
||||||
#include "manage_hiscore_table.h"
|
#include "manage_hiscore_table.h"
|
||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
@@ -42,7 +42,6 @@ private:
|
|||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
options_t *options; // Opciones del programa
|
options_t *options; // Opciones del programa
|
||||||
param_t *param; // Variable con todos los parametros del programa
|
|
||||||
std::string executablePath; // Path del ejecutable
|
std::string executablePath; // Path del ejecutable
|
||||||
std::string systemFolder; // Carpeta del sistema donde guardar datos
|
std::string systemFolder; // Carpeta del sistema donde guardar datos
|
||||||
std::string paramFileArgument; // Argumento para gestionar el fichero con los parametros del programa
|
std::string paramFileArgument; // Argumento para gestionar el fichero con los parametros del programa
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "enemy_formations.h"
|
#include "enemy_formations.h"
|
||||||
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
EnemyFormations::EnemyFormations(param_t *param)
|
EnemyFormations::EnemyFormations()
|
||||||
{
|
{
|
||||||
this->param = param;
|
|
||||||
initEnemyFormations();
|
initEnemyFormations();
|
||||||
initEnemyPools();
|
initEnemyPools();
|
||||||
initGameStages();
|
initGameStages();
|
||||||
@@ -19,20 +19,20 @@ void EnemyFormations::initEnemyFormations()
|
|||||||
{
|
{
|
||||||
const int y4 = - BLOCK;
|
const int y4 = - BLOCK;
|
||||||
const int x4_0 = PLAY_AREA_LEFT;
|
const int x4_0 = PLAY_AREA_LEFT;
|
||||||
const int x4_100 = param->game.playArea.rect.w - BALLOON_WIDTH_4;
|
const int x4_100 = param.game.playArea.rect.w - BALLOON_WIDTH_4;
|
||||||
|
|
||||||
const int y3 = - BLOCK;
|
const int y3 = - BLOCK;
|
||||||
const int x3_0 = PLAY_AREA_LEFT;
|
const int x3_0 = PLAY_AREA_LEFT;
|
||||||
const int x3_100 = param->game.playArea.rect.w - BALLOON_WIDTH_3;
|
const int x3_100 = param.game.playArea.rect.w - BALLOON_WIDTH_3;
|
||||||
|
|
||||||
const int y2 = - BLOCK;
|
const int y2 = - BLOCK;
|
||||||
const int x2_0 = PLAY_AREA_LEFT;
|
const int x2_0 = PLAY_AREA_LEFT;
|
||||||
const int x2_100 = param->game.playArea.rect.w - BALLOON_WIDTH_2;
|
const int x2_100 = param.game.playArea.rect.w - BALLOON_WIDTH_2;
|
||||||
|
|
||||||
const int y1 = - BLOCK;
|
const int y1 = - BLOCK;
|
||||||
const int x1_0 = PLAY_AREA_LEFT;
|
const int x1_0 = PLAY_AREA_LEFT;
|
||||||
const int x1_50 = param->game.playArea.centerX - (BALLOON_WIDTH_1 / 2);
|
const int x1_50 = param.game.playArea.centerX - (BALLOON_WIDTH_1 / 2);
|
||||||
const int x1_100 = param->game.playArea.rect.w - BALLOON_WIDTH_1;
|
const int x1_100 = param.game.playArea.rect.w - BALLOON_WIDTH_1;
|
||||||
|
|
||||||
// Inicializa a cero las variables
|
// Inicializa a cero las variables
|
||||||
for (int i = 0; i < NUMBER_OF_ENEMY_FORMATIONS; i++)
|
for (int i = 0; i < NUMBER_OF_ENEMY_FORMATIONS; i++)
|
||||||
@@ -70,11 +70,11 @@ void EnemyFormations::initEnemyFormations()
|
|||||||
// #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro
|
// #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro
|
||||||
j = 1;
|
j = 1;
|
||||||
enemyFormation[j].numberOfEnemies = 2;
|
enemyFormation[j].numberOfEnemies = 2;
|
||||||
incX = param->game.playArea.centerX;
|
incX = param.game.playArea.centerX;
|
||||||
incTime = 0;
|
incTime = 0;
|
||||||
for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++)
|
for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++)
|
||||||
{
|
{
|
||||||
enemyFormation[j].init[i].x = param->game.playArea.firstQuarterX - (BALLOON_WIDTH_4 / 2) + (i * incX);
|
enemyFormation[j].init[i].x = param.game.playArea.firstQuarterX - (BALLOON_WIDTH_4 / 2) + (i * incX);
|
||||||
enemyFormation[j].init[i].y = y4;
|
enemyFormation[j].init[i].y = y4;
|
||||||
enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1);
|
enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1);
|
||||||
enemyFormation[j].init[i].kind = BALLOON_4;
|
enemyFormation[j].init[i].kind = BALLOON_4;
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ private:
|
|||||||
stage_t stage[10]; // Variable con los datos de cada pantalla
|
stage_t stage[10]; // Variable con los datos de cada pantalla
|
||||||
enemyFormation_t enemyFormation[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas
|
enemyFormation_t enemyFormation[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas
|
||||||
enemyPool_t enemyPool[10]; // Variable con los diferentes conjuntos de formaciones enemigas
|
enemyPool_t enemyPool[10]; // Variable con los diferentes conjuntos de formaciones enemigas
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
|
|
||||||
// Inicializa las formaciones enemigas
|
// Inicializa las formaciones enemigas
|
||||||
void initEnemyFormations();
|
void initEnemyFormations();
|
||||||
@@ -59,7 +58,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
EnemyFormations(param_t *param);
|
EnemyFormations();
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~EnemyFormations();
|
~EnemyFormations();
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#include "fade.h"
|
#include "fade.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
#include "param.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Fade::Fade(SDL_Renderer *renderer, param_t *param)
|
Fade::Fade(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Copia punteros y objetos
|
// Copia punteros y objetos
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->param = param;
|
|
||||||
|
|
||||||
// Crea la textura donde dibujar el fade
|
// Crea la textura donde dibujar el fade
|
||||||
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param->game.width, param->game.height);
|
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height);
|
||||||
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Inicializa las variables
|
// Inicializa las variables
|
||||||
@@ -37,10 +37,10 @@ void Fade::init()
|
|||||||
b = 0;
|
b = 0;
|
||||||
postDuration = 20;
|
postDuration = 20;
|
||||||
postCounter = 0;
|
postCounter = 0;
|
||||||
numSquaresWidth = param->fade.numSquaresWidth;
|
numSquaresWidth = param.fade.numSquaresWidth;
|
||||||
numSquaresHeight = param->fade.numSquaresHeight;
|
numSquaresHeight = param.fade.numSquaresHeight;
|
||||||
fadeRandomSquaresDelay = param->fade.randomSquaresDelay;
|
fadeRandomSquaresDelay = param.fade.randomSquaresDelay;
|
||||||
fadeRandomSquaresMult = param->fade.randomSquaresMult;
|
fadeRandomSquaresMult = param.fade.randomSquaresMult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resetea algunas variables para volver a hacer el fade sin perder ciertos parametros
|
// Resetea algunas variables para volver a hacer el fade sin perder ciertos parametros
|
||||||
@@ -97,7 +97,7 @@ void Fade::update()
|
|||||||
for (int i = 0; i < counter; i++)
|
for (int i = 0; i < counter; i++)
|
||||||
{
|
{
|
||||||
rect1.h = rect2.h = i * 4;
|
rect1.h = rect2.h = i * 4;
|
||||||
rect2.y = param->game.height - (i * 4);
|
rect2.y = param.game.height - (i * 4);
|
||||||
|
|
||||||
SDL_RenderFillRect(renderer, &rect1);
|
SDL_RenderFillRect(renderer, &rect1);
|
||||||
SDL_RenderFillRect(renderer, &rect2);
|
SDL_RenderFillRect(renderer, &rect2);
|
||||||
@@ -107,7 +107,7 @@ void Fade::update()
|
|||||||
SDL_SetRenderTarget(renderer, temp);
|
SDL_SetRenderTarget(renderer, temp);
|
||||||
|
|
||||||
// Comprueba si ha terminado
|
// Comprueba si ha terminado
|
||||||
if ((counter * 4) > param->game.height)
|
if ((counter * 4) > param.game.height)
|
||||||
{
|
{
|
||||||
finished = true;
|
finished = true;
|
||||||
a = 255;
|
a = 255;
|
||||||
@@ -152,7 +152,7 @@ void Fade::update()
|
|||||||
case FADE_VENETIAN:
|
case FADE_VENETIAN:
|
||||||
{
|
{
|
||||||
// Counter debe ir de 0 a 150
|
// Counter debe ir de 0 a 150
|
||||||
if (square.back().h < param->fade.venetianSize)
|
if (square.back().h < param.fade.venetianSize)
|
||||||
{
|
{
|
||||||
// Dibuja sobre el backbuffer
|
// Dibuja sobre el backbuffer
|
||||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
||||||
@@ -221,15 +221,15 @@ void Fade::activate()
|
|||||||
|
|
||||||
case FADE_CENTER:
|
case FADE_CENTER:
|
||||||
{
|
{
|
||||||
rect1 = {0, 0, param->game.width, 0};
|
rect1 = {0, 0, param.game.width, 0};
|
||||||
rect2 = {0, 0, param->game.width, 0};
|
rect2 = {0, 0, param.game.width, 0};
|
||||||
a = 64;
|
a = 64;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case FADE_RANDOM_SQUARE:
|
case FADE_RANDOM_SQUARE:
|
||||||
{
|
{
|
||||||
rect1 = {0, 0, param->game.width / numSquaresWidth, param->game.height / numSquaresHeight};
|
rect1 = {0, 0, param.game.width / numSquaresWidth, param.game.height / numSquaresHeight};
|
||||||
square.clear();
|
square.clear();
|
||||||
|
|
||||||
// Añade los cuadrados al vector
|
// Añade los cuadrados al vector
|
||||||
@@ -267,16 +267,16 @@ void Fade::activate()
|
|||||||
|
|
||||||
case FADE_VENETIAN:
|
case FADE_VENETIAN:
|
||||||
{
|
{
|
||||||
rect1 = {0, 0, param->game.width, 0};
|
rect1 = {0, 0, param.game.width, 0};
|
||||||
square.clear();
|
square.clear();
|
||||||
a = 255;
|
a = 255;
|
||||||
|
|
||||||
// Añade los cuadrados al vector
|
// Añade los cuadrados al vector
|
||||||
const int max = param->game.height / param->fade.venetianSize;
|
const int max = param.game.height / param.fade.venetianSize;
|
||||||
|
|
||||||
for (int i = 0; i < max; ++i)
|
for (int i = 0; i < max; ++i)
|
||||||
{
|
{
|
||||||
rect1.y = i * param->fade.venetianSize;
|
rect1.y = i * param.fade.venetianSize;
|
||||||
square.push_back(rect1);
|
square.push_back(rect1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ private:
|
|||||||
SDL_Rect rect2; // Rectangulo usado para crear los efectos de transición
|
SDL_Rect rect2; // Rectangulo usado para crear los efectos de transición
|
||||||
int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FADE_RANDOM_SQUARE
|
int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FADE_RANDOM_SQUARE
|
||||||
int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FADE_RANDOM_SQUARE
|
int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FADE_RANDOM_SQUARE
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
std::vector<SDL_Rect> square; // Vector con los indices de los cuadrados para el FADE_RANDOM_SQUARE
|
std::vector<SDL_Rect> square; // Vector con los indices de los cuadrados para el FADE_RANDOM_SQUARE
|
||||||
int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados
|
int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados
|
||||||
int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
|
int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
|
||||||
@@ -48,7 +47,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Fade(SDL_Renderer *renderer, param_t *param);
|
Fade(SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Fade();
|
~Fade();
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
#include "param.h"
|
||||||
|
|
||||||
#define GAME_OVER_COUNTER 350
|
#define GAME_OVER_COUNTER 350
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music)
|
Game::Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->param = param;
|
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
@@ -22,12 +22,12 @@ Game::Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *ass
|
|||||||
difficulty = options->game.difficulty;
|
difficulty = options->game.difficulty;
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
fade = new Fade(renderer, param);
|
fade = new Fade(renderer);
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
scoreboard = new Scoreboard(renderer, asset, options);
|
scoreboard = new Scoreboard(renderer, asset, options);
|
||||||
background = new Background(renderer, asset, param);
|
background = new Background(renderer, asset);
|
||||||
explosions = new Explosions();
|
explosions = new Explosions();
|
||||||
enemyFormations = new EnemyFormations(param);
|
enemyFormations = new EnemyFormations();
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
loadMedia();
|
loadMedia();
|
||||||
@@ -41,7 +41,7 @@ Game::Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *ass
|
|||||||
loadDemoFile(asset->get("demo2.bin"), &this->demo.dataFile[index2]);
|
loadDemoFile(asset->get("demo2.bin"), &this->demo.dataFile[index2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
background->setPos(param->game.playArea.rect);
|
background->setPos(param.game.playArea.rect);
|
||||||
|
|
||||||
n1000Sprite = new SmartSprite(gameTextTexture);
|
n1000Sprite = new SmartSprite(gameTextTexture);
|
||||||
n2500Sprite = new SmartSprite(gameTextTexture);
|
n2500Sprite = new SmartSprite(gameTextTexture);
|
||||||
@@ -52,7 +52,7 @@ Game::Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *ass
|
|||||||
explosions->addTexture(3, explosionsTextures[2], explosionsAnimations[2]);
|
explosions->addTexture(3, explosionsTextures[2], explosionsAnimations[2]);
|
||||||
explosions->addTexture(4, explosionsTextures[3], explosionsAnimations[3]);
|
explosions->addTexture(4, explosionsTextures[3], explosionsAnimations[3]);
|
||||||
|
|
||||||
canvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param->game.playArea.rect.w, param->game.playArea.rect.h);
|
canvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.playArea.rect.w, param.game.playArea.rect.h);
|
||||||
SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Inicializa las variables necesarias para la sección 'Game'
|
// Inicializa las variables necesarias para la sección 'Game'
|
||||||
@@ -107,14 +107,14 @@ void Game::init(int playerID)
|
|||||||
players.clear();
|
players.clear();
|
||||||
|
|
||||||
// Crea los dos jugadores
|
// Crea los dos jugadores
|
||||||
Player *player1 = new Player(1, (param->game.playArea.firstQuarterX * ((0 * 2) + 1)) - 11, param->game.playArea.rect.h - 30, ¶m->game.playArea.rect, playerTextures[0], playerAnimations);
|
Player *player1 = new Player(1, (param.game.playArea.firstQuarterX * ((0 * 2) + 1)) - 11, param.game.playArea.rect.h - 30, ¶m.game.playArea.rect, playerTextures[0], playerAnimations);
|
||||||
player1->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
player1->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
||||||
player1->setName(lang::getText(53));
|
player1->setName(lang::getText(53));
|
||||||
const int controller1 = getController(player1->getId());
|
const int controller1 = getController(player1->getId());
|
||||||
player1->setController(controller1);
|
player1->setController(controller1);
|
||||||
players.push_back(player1);
|
players.push_back(player1);
|
||||||
|
|
||||||
Player *player2 = new Player(2, (param->game.playArea.firstQuarterX * ((1 * 2) + 1)) - 11, param->game.playArea.rect.h - 30, ¶m->game.playArea.rect, playerTextures[1], playerAnimations);
|
Player *player2 = new Player(2, (param.game.playArea.firstQuarterX * ((1 * 2) + 1)) - 11, param.game.playArea.rect.h - 30, ¶m.game.playArea.rect, playerTextures[1], playerAnimations);
|
||||||
player2->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
player2->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
||||||
player2->setName(lang::getText(54));
|
player2->setName(lang::getText(54));
|
||||||
const int controller2 = getController(player2->getId());
|
const int controller2 = getController(player2->getId());
|
||||||
@@ -159,7 +159,7 @@ void Game::init(int playerID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Variables para el marcador
|
// Variables para el marcador
|
||||||
scoreboard->setPos({param->scoreboard.x, param->scoreboard.y, param->scoreboard.w, param->scoreboard.h});
|
scoreboard->setPos({param.scoreboard.x, param.scoreboard.y, param.scoreboard.w, param.scoreboard.h});
|
||||||
for (auto player : players)
|
for (auto player : players)
|
||||||
{
|
{
|
||||||
scoreboard->setName(player->getScoreBoardPanel(), player->getName());
|
scoreboard->setName(player->getScoreBoardPanel(), player->getName());
|
||||||
@@ -269,7 +269,7 @@ void Game::init(int playerID)
|
|||||||
|
|
||||||
// Inicializa el objeto para el fundido
|
// Inicializa el objeto para el fundido
|
||||||
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
||||||
fade->setPost(param->fade.postDuration);
|
fade->setPost(param.fade.postDuration);
|
||||||
fade->setType(FADE_VENETIAN);
|
fade->setType(FADE_VENETIAN);
|
||||||
|
|
||||||
// Con los globos creados, calcula el nivel de amenaza
|
// Con los globos creados, calcula el nivel de amenaza
|
||||||
@@ -977,7 +977,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], param);
|
Balloon *b = new Balloon(x, y, kind, velx, speed, creationtimer, balloonTextures[index], balloonAnimations[index]);
|
||||||
balloons.push_back(b);
|
balloons.push_back(b);
|
||||||
return (int)(balloons.size() - 1);
|
return (int)(balloons.size() - 1);
|
||||||
}
|
}
|
||||||
@@ -989,8 +989,8 @@ void Game::createPowerBall()
|
|||||||
const int posY = -BLOCK;
|
const int posY = -BLOCK;
|
||||||
|
|
||||||
const int left = PLAY_AREA_LEFT;
|
const int left = PLAY_AREA_LEFT;
|
||||||
const int center = param->game.playArea.centerX - (BALLOON_WIDTH_4 / 2);
|
const int center = param.game.playArea.centerX - (BALLOON_WIDTH_4 / 2);
|
||||||
const int right = param->game.playArea.rect.w - BALLOON_WIDTH_4;
|
const int right = param.game.playArea.rect.w - BALLOON_WIDTH_4;
|
||||||
|
|
||||||
const float vpos = BALLOON_VELX_POSITIVE;
|
const float vpos = BALLOON_VELX_POSITIVE;
|
||||||
const float vneg = BALLOON_VELX_NEGATIVE;
|
const float vneg = BALLOON_VELX_NEGATIVE;
|
||||||
@@ -999,7 +999,7 @@ void Game::createPowerBall()
|
|||||||
const int x[values] = {left, left, center, center, right, right};
|
const int x[values] = {left, left, center, center, right, right};
|
||||||
const float vx[values] = {vpos, vpos, vpos, vneg, vneg, vneg};
|
const float vx[values] = {vpos, vpos, vpos, vneg, vneg, vneg};
|
||||||
|
|
||||||
Balloon *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 300, balloonTextures[4], balloonAnimations[4], param);
|
Balloon *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 300, balloonTextures[4], balloonAnimations[4]);
|
||||||
balloons.push_back(b);
|
balloons.push_back(b);
|
||||||
|
|
||||||
powerBallEnabled = true;
|
powerBallEnabled = true;
|
||||||
@@ -1480,7 +1480,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, &(param->game.playArea.rect), bulletTexture);
|
Bullet *b = new Bullet(x, y, kind, poweredUp, owner, &(param.game.playArea.rect), bulletTexture);
|
||||||
bullets.push_back(b);
|
bullets.push_back(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1605,7 +1605,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, &(param->game.playArea.rect), itemTextures[kind - 1], itemAnimations[kind - 1]);
|
Item *item = new Item(kind, x, y, &(param.game.playArea.rect), itemTextures[kind - 1], itemAnimations[kind - 1]);
|
||||||
items.push_back(item);
|
items.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1665,17 +1665,17 @@ void Game::throwCoffee(int x, int y)
|
|||||||
|
|
||||||
ss->setPosX(x - 8);
|
ss->setPosX(x - 8);
|
||||||
ss->setPosY(y - 8);
|
ss->setPosY(y - 8);
|
||||||
ss->setWidth(param->game.itemSize);
|
ss->setWidth(param.game.itemSize);
|
||||||
ss->setHeight(param->game.itemSize);
|
ss->setHeight(param.game.itemSize);
|
||||||
ss->setVelX(-1.0f + ((rand() % 5) * 0.5f));
|
ss->setVelX(-1.0f + ((rand() % 5) * 0.5f));
|
||||||
ss->setVelY(-4.0f);
|
ss->setVelY(-4.0f);
|
||||||
ss->setAccelX(0.0f);
|
ss->setAccelX(0.0f);
|
||||||
ss->setAccelY(0.2f);
|
ss->setAccelY(0.2f);
|
||||||
ss->setDestX(x + (ss->getVelX() * 50));
|
ss->setDestX(x + (ss->getVelX() * 50));
|
||||||
ss->setDestY(param->game.height + 1);
|
ss->setDestY(param.game.height + 1);
|
||||||
ss->setEnabled(true);
|
ss->setEnabled(true);
|
||||||
ss->setEnabledCounter(1);
|
ss->setEnabledCounter(1);
|
||||||
ss->setSpriteClip(0, param->game.itemSize, param->game.itemSize, param->game.itemSize);
|
ss->setSpriteClip(0, param.game.itemSize, param.game.itemSize, param.game.itemSize);
|
||||||
ss->setRotate(true);
|
ss->setRotate(true);
|
||||||
ss->setRotateSpeed(10);
|
ss->setRotateSpeed(10);
|
||||||
ss->setRotateAmount(90.0);
|
ss->setRotateAmount(90.0);
|
||||||
@@ -1995,7 +1995,7 @@ void Game::render()
|
|||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
// Copia la textura con la zona de juego a la pantalla
|
// Copia la textura con la zona de juego a la pantalla
|
||||||
SDL_RenderCopy(renderer, canvas, nullptr, ¶m->game.playArea.rect);
|
SDL_RenderCopy(renderer, canvas, nullptr, ¶m.game.playArea.rect);
|
||||||
|
|
||||||
// Dibuja el marcador
|
// Dibuja el marcador
|
||||||
scoreboard->render();
|
scoreboard->render();
|
||||||
@@ -2283,7 +2283,7 @@ void Game::renderMessages()
|
|||||||
// GetReady
|
// GetReady
|
||||||
if ((counter < STAGE_COUNTER) && (!demo.enabled))
|
if ((counter < STAGE_COUNTER) && (!demo.enabled))
|
||||||
{
|
{
|
||||||
textNokiaBig2->write((int)getReadyBitmapPath[counter], param->game.playArea.centerY - 8, lang::getText(75), -2);
|
textNokiaBig2->write((int)getReadyBitmapPath[counter], param.game.playArea.centerY - 8, lang::getText(75), -2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time Stopped
|
// Time Stopped
|
||||||
@@ -2291,7 +2291,7 @@ void Game::renderMessages()
|
|||||||
{
|
{
|
||||||
if ((timeStoppedCounter > 100) || (timeStoppedCounter % 10 > 4))
|
if ((timeStoppedCounter > 100) || (timeStoppedCounter % 10 > 4))
|
||||||
{
|
{
|
||||||
textNokia2->writeDX(TXT_CENTER, param->game.playArea.centerX, param->game.playArea.firstQuarterY, lang::getText(36) + std::to_string(timeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor);
|
textNokia2->writeDX(TXT_CENTER, param.game.playArea.centerX, param.game.playArea.firstQuarterY, lang::getText(36) + std::to_string(timeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeStoppedCounter > 100)
|
if (timeStoppedCounter > 100)
|
||||||
@@ -2329,13 +2329,13 @@ void Game::renderMessages()
|
|||||||
|
|
||||||
if (!gameCompleted)
|
if (!gameCompleted)
|
||||||
{ // Escribe el número de fases restantes
|
{ // Escribe el número de fases restantes
|
||||||
textNokiaBig2->writeDX(TXT_CENTER, param->game.playArea.centerX, stageBitmapPath[stageBitmapCounter], text, -2, noColor, 2, shdwTxtColor);
|
textNokiaBig2->writeDX(TXT_CENTER, param.game.playArea.centerX, stageBitmapPath[stageBitmapCounter], text, -2, noColor, 2, shdwTxtColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Escribe el texto de juego completado
|
{ // Escribe el texto de juego completado
|
||||||
text = lang::getText(50);
|
text = lang::getText(50);
|
||||||
textNokiaBig2->writeDX(TXT_CENTER, param->game.playArea.centerX, stageBitmapPath[stageBitmapCounter], text, -2, noColor, 1, shdwTxtColor);
|
textNokiaBig2->writeDX(TXT_CENTER, param.game.playArea.centerX, stageBitmapPath[stageBitmapCounter], text, -2, noColor, 1, shdwTxtColor);
|
||||||
textNokia2->writeDX(TXT_CENTER, param->game.playArea.centerX, stageBitmapPath[stageBitmapCounter] + textNokiaBig2->getCharacterSize() + 2, lang::getText(76), -1, noColor, 1, shdwTxtColor);
|
textNokia2->writeDX(TXT_CENTER, param.game.playArea.centerX, stageBitmapPath[stageBitmapCounter] + textNokiaBig2->getCharacterSize() + 2, lang::getText(76), -1, noColor, 1, shdwTxtColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2439,8 +2439,8 @@ void Game::initPaths()
|
|||||||
// Letrero de STAGE #
|
// Letrero de STAGE #
|
||||||
const int firstPart = STAGE_COUNTER / 4; // 50
|
const int firstPart = STAGE_COUNTER / 4; // 50
|
||||||
const int secondPart = firstPart * 3; // 150
|
const int secondPart = firstPart * 3; // 150
|
||||||
const int centerPoint = param->game.playArea.centerY - (BLOCK * 2);
|
const int centerPoint = param.game.playArea.centerY - (BLOCK * 2);
|
||||||
const int distance = (param->game.playArea.rect.h) - (param->game.playArea.centerY - 16);
|
const int distance = (param.game.playArea.rect.h) - (param.game.playArea.centerY - 16);
|
||||||
|
|
||||||
for (int i = 0; i < STAGE_COUNTER; ++i)
|
for (int i = 0; i < STAGE_COUNTER; ++i)
|
||||||
{
|
{
|
||||||
@@ -2464,10 +2464,10 @@ void Game::initPaths()
|
|||||||
const int size = textNokiaBig2->lenght(lang::getText(75), -2);
|
const int size = textNokiaBig2->lenght(lang::getText(75), -2);
|
||||||
|
|
||||||
const float start1 = PLAY_AREA_LEFT - size;
|
const float start1 = PLAY_AREA_LEFT - size;
|
||||||
const float finish1 = param->game.playArea.centerX - (size / 2);
|
const float finish1 = param.game.playArea.centerX - (size / 2);
|
||||||
|
|
||||||
const float start2 = finish1;
|
const float start2 = finish1;
|
||||||
const float finish2 = param->game.playArea.rect.w;
|
const float finish2 = param.game.playArea.rect.w;
|
||||||
|
|
||||||
const float distance1 = finish1 - start1;
|
const float distance1 = finish1 - start1;
|
||||||
const float distance2 = finish2 - start2;
|
const float distance2 = finish2 - start2;
|
||||||
@@ -2600,7 +2600,7 @@ void Game::checkEvents()
|
|||||||
{
|
{
|
||||||
// CREA UN SPRITE DE 1000 PUNTOS
|
// CREA UN SPRITE DE 1000 PUNTOS
|
||||||
case SDLK_h:
|
case SDLK_h:
|
||||||
createItemScoreSprite(param->game.width / 2, param->game.width / 2, n1000Sprite);
|
createItemScoreSprite(param.game.width / 2, param.game.width / 2, n1000Sprite);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// CREA UNA POWERBALL
|
// CREA UNA POWERBALL
|
||||||
|
|||||||
@@ -195,7 +195,6 @@ private:
|
|||||||
float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad
|
float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad
|
||||||
color_t difficultyColor; // Color asociado a la dificultad
|
color_t difficultyColor; // Color asociado a la dificultad
|
||||||
options_t *options; // Opciones del programa
|
options_t *options; // Opciones del programa
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
int lastStageReached; // Contiene el número de la última pantalla que se ha alcanzado
|
int lastStageReached; // Contiene el número de la última pantalla que se ha alcanzado
|
||||||
demo_t demo; // Variable con todas las variables relacionadas con el modo demo
|
demo_t demo; // Variable con todas las variables relacionadas con el modo demo
|
||||||
int totalPowerToCompleteGame; // La suma del poder necesario para completar todas las fases
|
int totalPowerToCompleteGame; // La suma del poder necesario para completar todas las fases
|
||||||
@@ -450,7 +449,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music);
|
Game(int playerID, int currentStage, bool demo, Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#include "game_logo.h"
|
#include "game_logo.h"
|
||||||
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
GameLogo::GameLogo(SDL_Renderer *renderer, Screen *screen, Asset *asset, param_t *param, int x, int y)
|
GameLogo::GameLogo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int x, int y)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->param = param;
|
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ GameLogo::GameLogo(SDL_Renderer *renderer, Screen *screen, Asset *asset, param_t
|
|||||||
|
|
||||||
coffeeBitmap = new SmartSprite(coffeeTexture);
|
coffeeBitmap = new SmartSprite(coffeeTexture);
|
||||||
crisisBitmap = new SmartSprite(crisisTexture);
|
crisisBitmap = new SmartSprite(crisisTexture);
|
||||||
arcadeEditionBitmap = new Sprite((param->game.width - arcadeEditionTexture->getWidth()) / 2, param->title.arcadeEditionPosition, arcadeEditionTexture->getWidth(), arcadeEditionTexture->getHeight(), arcadeEditionTexture);
|
arcadeEditionBitmap = new Sprite((param.game.width - arcadeEditionTexture->getWidth()) / 2, param.title.arcadeEditionPosition, arcadeEditionTexture->getWidth(), arcadeEditionTexture->getHeight(), arcadeEditionTexture);
|
||||||
dustBitmapL = new AnimatedSprite(dustTexture, asset->get("title_dust.ani"));
|
dustBitmapL = new AnimatedSprite(dustTexture, asset->get("title_dust.ani"));
|
||||||
dustBitmapR = new AnimatedSprite(dustTexture, asset->get("title_dust.ani"));
|
dustBitmapR = new AnimatedSprite(dustTexture, asset->get("title_dust.ani"));
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ void GameLogo::reLoad()
|
|||||||
int GameLogo::getInitialVerticalDesp()
|
int GameLogo::getInitialVerticalDesp()
|
||||||
{
|
{
|
||||||
int despUp = y;
|
int despUp = y;
|
||||||
int despDown = param->game.height - y;
|
int despDown = param.game.height - y;
|
||||||
|
|
||||||
return std::max(despUp, despDown);
|
return std::max(despUp, despDown);
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,6 @@ private:
|
|||||||
Sprite *arcadeEditionBitmap; // Sprite con los graficos de "Arcade Edition"
|
Sprite *arcadeEditionBitmap; // Sprite con los graficos de "Arcade Edition"
|
||||||
|
|
||||||
JA_Sound_t *crashSound; // Sonido con el impacto del título
|
JA_Sound_t *crashSound; // Sonido con el impacto del título
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int x; // Posición donde dibujar el logo
|
int x; // Posición donde dibujar el logo
|
||||||
@@ -62,7 +61,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
GameLogo(SDL_Renderer *renderer, Screen *screen, Asset *asset, param_t *param, int x, int y);
|
GameLogo(SDL_Renderer *renderer, Screen *screen, Asset *asset, int x, int y);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~GameLogo();
|
~GameLogo();
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#include "hiscore_table.h"
|
#include "hiscore_table.h"
|
||||||
|
#include "param.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music)
|
HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
@@ -10,18 +11,17 @@ HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, options_t
|
|||||||
this->input = input;
|
this->input = input;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->param = param;
|
|
||||||
this->music = music;
|
this->music = music;
|
||||||
renderer = screen->getRenderer();
|
renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Objetos
|
// Objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
fade = new Fade(renderer, param);
|
fade = new Fade(renderer);
|
||||||
background = new Background(renderer, asset, param);
|
background = new Background(renderer, asset);
|
||||||
text = new Text(asset->get("smb2.gif"), asset->get("smb2.txt"), renderer);
|
text = new Text(asset->get("smb2.gif"), asset->get("smb2.txt"), renderer);
|
||||||
|
|
||||||
// Crea un backbuffer para el renderizador
|
// Crea un backbuffer para el renderizador
|
||||||
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param->game.width, param->game.height);
|
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height);
|
||||||
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
@@ -30,17 +30,17 @@ HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, options_t
|
|||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
counterEnd = 800;
|
counterEnd = 800;
|
||||||
viewArea = {0, 0, param->game.width, param->game.height};
|
viewArea = {0, 0, param.game.width, param.game.height};
|
||||||
fadeMode = FADE_IN;
|
fadeMode = FADE_IN;
|
||||||
|
|
||||||
// Inicializa objetos
|
// Inicializa objetos
|
||||||
background->setPos(param->game.gameArea.rect);
|
background->setPos(param.game.gameArea.rect);
|
||||||
background->setCloudsSpeed(-0.1f);
|
background->setCloudsSpeed(-0.1f);
|
||||||
background->setGradientNumber(1);
|
background->setGradientNumber(1);
|
||||||
background->setTransition(0.8f);
|
background->setTransition(0.8f);
|
||||||
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
||||||
fade->setType(FADE_RANDOM_SQUARE);
|
fade->setType(FADE_RANDOM_SQUARE);
|
||||||
fade->setPost(param->fade.postDuration);
|
fade->setPost(param.fade.postDuration);
|
||||||
fade->setMode(fadeMode);
|
fade->setMode(fadeMode);
|
||||||
fade->activate();
|
fade->activate();
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ void HiScoreTable::fillTexture()
|
|||||||
const int spaceBetweenHeader = 32;
|
const int spaceBetweenHeader = 32;
|
||||||
const int spaceBetweenLines = text->getCharacterSize() * 2.0f;
|
const int spaceBetweenLines = text->getCharacterSize() * 2.0f;
|
||||||
const int size = spaceBetweenHeader + spaceBetweenLines * (maxNames - 1) + text->getCharacterSize();
|
const int size = spaceBetweenHeader + spaceBetweenLines * (maxNames - 1) + text->getCharacterSize();
|
||||||
const int firstLine = (param->game.height - size) / 2;
|
const int firstLine = (param.game.height - size) / 2;
|
||||||
|
|
||||||
// Pinta en el backbuffer el texto y los sprites
|
// Pinta en el backbuffer el texto y los sprites
|
||||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
||||||
@@ -113,7 +113,7 @@ void HiScoreTable::fillTexture()
|
|||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
// Escribe el texto: Mejores puntuaciones
|
// Escribe el texto: Mejores puntuaciones
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param->game.gameArea.centerX, firstLine, lang::getText(42), 1, orangeColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param.game.gameArea.centerX, firstLine, lang::getText(42), 1, orangeColor, 1, shdwTxtColor);
|
||||||
|
|
||||||
// Escribe los nombres de la tabla de puntuaciones
|
// Escribe los nombres de la tabla de puntuaciones
|
||||||
for (int i = 0; i < maxNames; ++i)
|
for (int i = 0; i < maxNames; ++i)
|
||||||
@@ -128,7 +128,7 @@ void HiScoreTable::fillTexture()
|
|||||||
dots = dots + ".";
|
dots = dots + ".";
|
||||||
}
|
}
|
||||||
const std::string line = options->game.hiScoreTable[i].name + dots + score;
|
const std::string line = options->game.hiScoreTable[i].name + dots + score;
|
||||||
text->writeDX(TXT_CENTER | TXT_SHADOW, param->game.gameArea.centerX, (i * spaceBetweenLines) + firstLine + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_SHADOW, param.game.gameArea.centerX, (i * spaceBetweenLines) + firstLine + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el destino de renderizado
|
// Cambia el destino de renderizado
|
||||||
@@ -148,7 +148,7 @@ void HiScoreTable::render()
|
|||||||
background->render();
|
background->render();
|
||||||
|
|
||||||
// Establece la ventana del backbuffer
|
// Establece la ventana del backbuffer
|
||||||
viewArea.y = std::max(0, param->game.height - counter + 100);
|
viewArea.y = std::max(0, param.game.height - counter + 100);
|
||||||
|
|
||||||
// Copia el backbuffer al renderizador
|
// Copia el backbuffer al renderizador
|
||||||
SDL_RenderCopy(renderer, backbuffer, nullptr, &viewArea);
|
SDL_RenderCopy(renderer, backbuffer, nullptr, &viewArea);
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ private:
|
|||||||
JA_Music_t *music; // Musica de fondo
|
JA_Music_t *music; // Musica de fondo
|
||||||
options_t *options; // Opciones del programa
|
options_t *options; // Opciones del programa
|
||||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint16 counter; // Contador
|
Uint16 counter; // Contador
|
||||||
@@ -82,7 +81,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
HiScoreTable(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music);
|
HiScoreTable(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~HiScoreTable();
|
~HiScoreTable();
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#include "instructions.h"
|
#include "instructions.h"
|
||||||
|
#include "param.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Instructions::Instructions(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music)
|
Instructions::Instructions(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->param = param;
|
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
@@ -17,15 +17,15 @@ Instructions::Instructions(Screen *screen, Asset *asset, Input *input, options_t
|
|||||||
// Crea objetos
|
// Crea objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
text = new Text(asset->get("smb2.gif"), asset->get("smb2.txt"), renderer);
|
text = new Text(asset->get("smb2.gif"), asset->get("smb2.txt"), renderer);
|
||||||
tiledbg = new Tiledbg(renderer, asset, {0, 0, param->game.width, param->game.height}, TILED_MODE_STATIC);
|
tiledbg = new Tiledbg(renderer, asset, {0, 0, param.game.width, param.game.height}, TILED_MODE_STATIC);
|
||||||
fade = new Fade(renderer, param);
|
fade = new Fade(renderer);
|
||||||
|
|
||||||
// Crea un backbuffer para el renderizador
|
// Crea un backbuffer para el renderizador
|
||||||
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param->game.width, param->game.height);
|
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height);
|
||||||
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Crea una textura para el texto fijo
|
// Crea una textura para el texto fijo
|
||||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param->game.width, param->game.height);
|
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height);
|
||||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
@@ -34,14 +34,14 @@ Instructions::Instructions(Screen *screen, Asset *asset, Input *input, options_t
|
|||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
counterEnd = 700;
|
counterEnd = 700;
|
||||||
view = {0, 0, param->game.width, param->game.height};
|
view = {0, 0, param.game.width, param.game.height};
|
||||||
spritePos = {0, 0};
|
spritePos = {0, 0};
|
||||||
itemSpace = 2;
|
itemSpace = 2;
|
||||||
|
|
||||||
// Inicializa objetos
|
// Inicializa objetos
|
||||||
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
||||||
fade->setType(FADE_FULLSCREEN);
|
fade->setType(FADE_FULLSCREEN);
|
||||||
fade->setPost(param->fade.postDuration);
|
fade->setPost(param.fade.postDuration);
|
||||||
fade->setMode(FADE_IN);
|
fade->setMode(FADE_IN);
|
||||||
fade->activate();
|
fade->activate();
|
||||||
|
|
||||||
@@ -99,8 +99,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->game.itemSize, param->game.itemSize, itemTextures[i]);
|
Sprite *sprite = new Sprite(0, 0, param.game.itemSize, param.game.itemSize, itemTextures[i]);
|
||||||
sprite->setPos((SDL_Point){spritePos.x, spritePos.y + ((param->game.itemSize + itemSpace) * i)});
|
sprite->setPos((SDL_Point){spritePos.x, spritePos.y + ((param.game.itemSize + itemSpace) * i)});
|
||||||
sprites.push_back(sprite);
|
sprites.push_back(sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,33 +108,33 @@ void Instructions::iniSprites()
|
|||||||
// Actualiza los sprites
|
// Actualiza los sprites
|
||||||
void Instructions::updateSprites()
|
void Instructions::updateSprites()
|
||||||
{
|
{
|
||||||
SDL_Rect srcRect = {0, 0, param->game.itemSize, param->game.itemSize};
|
SDL_Rect srcRect = {0, 0, param.game.itemSize, param.game.itemSize};
|
||||||
|
|
||||||
// Disquito
|
// Disquito
|
||||||
srcRect.y = param->game.itemSize * (((counter + 12) / 36) % 2);
|
srcRect.y = param.game.itemSize * (((counter + 12) / 36) % 2);
|
||||||
sprites[0]->setSpriteClip(srcRect);
|
sprites[0]->setSpriteClip(srcRect);
|
||||||
|
|
||||||
// Gavineixon
|
// Gavineixon
|
||||||
srcRect.y = param->game.itemSize * (((counter + 9) / 36) % 2);
|
srcRect.y = param.game.itemSize * (((counter + 9) / 36) % 2);
|
||||||
sprites[1]->setSpriteClip(srcRect);
|
sprites[1]->setSpriteClip(srcRect);
|
||||||
|
|
||||||
// Pacmar
|
// Pacmar
|
||||||
srcRect.y = param->game.itemSize * (((counter + 6) / 36) % 2);
|
srcRect.y = param.game.itemSize * (((counter + 6) / 36) % 2);
|
||||||
sprites[2]->setSpriteClip(srcRect);
|
sprites[2]->setSpriteClip(srcRect);
|
||||||
|
|
||||||
// Time Stopper
|
// Time Stopper
|
||||||
srcRect.y = param->game.itemSize * (((counter + 3) / 36) % 2);
|
srcRect.y = param.game.itemSize * (((counter + 3) / 36) % 2);
|
||||||
sprites[3]->setSpriteClip(srcRect);
|
sprites[3]->setSpriteClip(srcRect);
|
||||||
|
|
||||||
// Coffee
|
// Coffee
|
||||||
srcRect.y = param->game.itemSize * (((counter + 0) / 36) % 2);
|
srcRect.y = param.game.itemSize * (((counter + 0) / 36) % 2);
|
||||||
sprites[4]->setSpriteClip(srcRect);
|
sprites[4]->setSpriteClip(srcRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rellena la textura de texto
|
// Rellena la textura de texto
|
||||||
void Instructions::fillTexture()
|
void Instructions::fillTexture()
|
||||||
{
|
{
|
||||||
const int despX = param->game.itemSize + 8;
|
const int despX = param.game.itemSize + 8;
|
||||||
|
|
||||||
// Modifica el renderizador para pintar en la textura
|
// Modifica el renderizador para pintar en la textura
|
||||||
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
SDL_Texture *temp = SDL_GetRenderTarget(renderer);
|
||||||
@@ -153,11 +153,11 @@ void Instructions::fillTexture()
|
|||||||
const int spacePostHeader = 20;
|
const int spacePostHeader = 20;
|
||||||
const int spacePreHeader = 28;
|
const int spacePreHeader = 28;
|
||||||
const int spaceBetweenLines = text->getCharacterSize() * 1.5f;
|
const int spaceBetweenLines = text->getCharacterSize() * 1.5f;
|
||||||
const int spaceBetweenItemLines = param->game.itemSize + itemSpace;
|
const int spaceBetweenItemLines = param.game.itemSize + itemSpace;
|
||||||
const int spaceNewParagraph = spaceBetweenLines * 0.5f;
|
const int spaceNewParagraph = spaceBetweenLines * 0.5f;
|
||||||
|
|
||||||
const int size = (numLines * spaceBetweenLines) + (numItemLines * spaceBetweenItemLines) + (numPostHeaders * spacePostHeader) + (numPreHeaders * spacePreHeader) + (spaceNewParagraph);
|
const int size = (numLines * spaceBetweenLines) + (numItemLines * spaceBetweenItemLines) + (numPostHeaders * spacePostHeader) + (numPreHeaders * spacePreHeader) + (spaceNewParagraph);
|
||||||
const int firstLine = (param->game.height - size) / 2;
|
const int firstLine = (param.game.height - size) / 2;
|
||||||
|
|
||||||
// Calcula cual es el texto más largo de las descripciones de los items
|
// Calcula cual es el texto más largo de las descripciones de los items
|
||||||
int lenght = 0;
|
int lenght = 0;
|
||||||
@@ -166,23 +166,23 @@ void Instructions::fillTexture()
|
|||||||
const int l = text->lenght(lang::getText(i));
|
const int l = text->lenght(lang::getText(i));
|
||||||
lenght = l > lenght ? l : lenght;
|
lenght = l > lenght ? l : lenght;
|
||||||
}
|
}
|
||||||
const int anchorItem = (param->game.width - (lenght + despX)) / 2;
|
const int anchorItem = (param.game.width - (lenght + despX)) / 2;
|
||||||
|
|
||||||
// Escribe el texto de las instrucciones
|
// Escribe el texto de las instrucciones
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param->game.gameArea.centerX, firstLine, lang::getText(11), 1, orangeColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param.game.gameArea.centerX, firstLine, lang::getText(11), 1, orangeColor, 1, shdwTxtColor);
|
||||||
|
|
||||||
const int anchor1 = firstLine + spacePostHeader;
|
const int anchor1 = firstLine + spacePostHeader;
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param->game.gameArea.centerX, anchor1 + spaceBetweenLines * 0, lang::getText(12), 1, noColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param.game.gameArea.centerX, anchor1 + spaceBetweenLines * 0, lang::getText(12), 1, noColor, 1, shdwTxtColor);
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param->game.gameArea.centerX, anchor1 + spaceBetweenLines * 1, lang::getText(13), 1, noColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param.game.gameArea.centerX, anchor1 + spaceBetweenLines * 1, lang::getText(13), 1, noColor, 1, shdwTxtColor);
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param->game.gameArea.centerX, anchor1 + spaceNewParagraph + spaceBetweenLines * 2, lang::getText(14), 1, noColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param.game.gameArea.centerX, anchor1 + spaceNewParagraph + spaceBetweenLines * 2, lang::getText(14), 1, noColor, 1, shdwTxtColor);
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param->game.gameArea.centerX, anchor1 + spaceNewParagraph + spaceBetweenLines * 3, lang::getText(15), 1, noColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param.game.gameArea.centerX, anchor1 + spaceNewParagraph + spaceBetweenLines * 3, lang::getText(15), 1, noColor, 1, shdwTxtColor);
|
||||||
|
|
||||||
// Escribe el texto de los objetos y sus puntos
|
// Escribe el texto de los objetos y sus puntos
|
||||||
const int anchor2 = anchor1 + spacePreHeader + spaceNewParagraph + spaceBetweenLines * 3;
|
const int anchor2 = anchor1 + spacePreHeader + spaceNewParagraph + spaceBetweenLines * 3;
|
||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param->game.gameArea.centerX, anchor2, lang::getText(16), 1, orangeColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, param.game.gameArea.centerX, anchor2, lang::getText(16), 1, orangeColor, 1, shdwTxtColor);
|
||||||
|
|
||||||
const int anchor3 = anchor2 + spacePostHeader;
|
const int anchor3 = anchor2 + spacePostHeader;
|
||||||
// const int anchor4 = anchor3 + ((param->game.itemSize + text->getCharacterSize()) / 2);
|
// const int anchor4 = anchor3 + ((param.game.itemSize + text->getCharacterSize()) / 2);
|
||||||
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 0, lang::getText(17), shdwTxtColor);
|
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 0, lang::getText(17), shdwTxtColor);
|
||||||
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 1, lang::getText(18), shdwTxtColor);
|
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 1, lang::getText(18), shdwTxtColor);
|
||||||
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 2, lang::getText(19), shdwTxtColor);
|
text->writeShadowed(anchorItem + despX, anchor3 + spaceBetweenItemLines * 2, lang::getText(19), shdwTxtColor);
|
||||||
@@ -194,7 +194,7 @@ void Instructions::fillTexture()
|
|||||||
|
|
||||||
// Da valor a la variable
|
// Da valor a la variable
|
||||||
spritePos.x = anchorItem;
|
spritePos.x = anchorItem;
|
||||||
spritePos.y = anchor3 - ((param->game.itemSize - text->getCharacterSize()) / 2);
|
spritePos.y = anchor3 - ((param.game.itemSize - text->getCharacterSize()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rellena el backbuffer
|
// Rellena el backbuffer
|
||||||
@@ -274,7 +274,7 @@ void Instructions::render()
|
|||||||
tiledbg->render();
|
tiledbg->render();
|
||||||
|
|
||||||
// Establece la ventana del backbuffer
|
// Establece la ventana del backbuffer
|
||||||
view.y = std::max(0, param->game.height - counter + 100);
|
view.y = std::max(0, param.game.height - counter + 100);
|
||||||
|
|
||||||
// Copia la textura y el backbuffer al renderizador
|
// Copia la textura y el backbuffer al renderizador
|
||||||
SDL_RenderCopy(renderer, backbuffer, nullptr, &view);
|
SDL_RenderCopy(renderer, backbuffer, nullptr, &view);
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ private:
|
|||||||
Fade *fade; // Objeto para renderizar fades
|
Fade *fade; // Objeto para renderizar fades
|
||||||
JA_Music_t *music; // Musica de fondo
|
JA_Music_t *music; // Musica de fondo
|
||||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
options_t *options; // Opciones del programa
|
options_t *options; // Opciones del programa
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
@@ -89,7 +88,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Instructions(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music);
|
Instructions(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Instructions();
|
~Instructions();
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro::Intro(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music)
|
Intro::Intro(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->param = param;
|
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
SDL_Renderer *renderer = screen->getRenderer();
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
@@ -32,28 +32,28 @@ Intro::Intro(Screen *screen, Asset *asset, Input *input, options_t *options, par
|
|||||||
ss->setWidth(128);
|
ss->setWidth(128);
|
||||||
ss->setHeight(96);
|
ss->setHeight(96);
|
||||||
ss->setEnabledCounter(20);
|
ss->setEnabledCounter(20);
|
||||||
ss->setDestX(param->game.gameArea.centerX - 64);
|
ss->setDestX(param.game.gameArea.centerX - 64);
|
||||||
ss->setDestY(param->game.gameArea.firstQuarterY - 24);
|
ss->setDestY(param.game.gameArea.firstQuarterY - 24);
|
||||||
bitmaps.push_back(ss);
|
bitmaps.push_back(ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmaps[0]->setPosX(-128);
|
bitmaps[0]->setPosX(-128);
|
||||||
bitmaps[0]->setPosY(param->game.gameArea.firstQuarterY - 24);
|
bitmaps[0]->setPosY(param.game.gameArea.firstQuarterY - 24);
|
||||||
bitmaps[0]->setVelX(0.0f);
|
bitmaps[0]->setVelX(0.0f);
|
||||||
bitmaps[0]->setVelY(0.0f);
|
bitmaps[0]->setVelY(0.0f);
|
||||||
bitmaps[0]->setAccelX(0.6f);
|
bitmaps[0]->setAccelX(0.6f);
|
||||||
bitmaps[0]->setAccelY(0.0f);
|
bitmaps[0]->setAccelY(0.0f);
|
||||||
bitmaps[0]->setSpriteClip(0, 0, 128, 96);
|
bitmaps[0]->setSpriteClip(0, 0, 128, 96);
|
||||||
|
|
||||||
bitmaps[1]->setPosX(param->game.width);
|
bitmaps[1]->setPosX(param.game.width);
|
||||||
bitmaps[1]->setPosY(param->game.gameArea.firstQuarterY - 24);
|
bitmaps[1]->setPosY(param.game.gameArea.firstQuarterY - 24);
|
||||||
bitmaps[1]->setVelX(-1.0f);
|
bitmaps[1]->setVelX(-1.0f);
|
||||||
bitmaps[1]->setVelY(0.0f);
|
bitmaps[1]->setVelY(0.0f);
|
||||||
bitmaps[1]->setAccelX(-0.3f);
|
bitmaps[1]->setAccelX(-0.3f);
|
||||||
bitmaps[1]->setAccelY(0.0f);
|
bitmaps[1]->setAccelY(0.0f);
|
||||||
bitmaps[1]->setSpriteClip(128, 0, 128, 96);
|
bitmaps[1]->setSpriteClip(128, 0, 128, 96);
|
||||||
|
|
||||||
bitmaps[2]->setPosX(param->game.gameArea.centerX - 64);
|
bitmaps[2]->setPosX(param.game.gameArea.centerX - 64);
|
||||||
bitmaps[2]->setPosY(-96);
|
bitmaps[2]->setPosY(-96);
|
||||||
bitmaps[2]->setVelX(0.0f);
|
bitmaps[2]->setVelX(0.0f);
|
||||||
bitmaps[2]->setVelY(3.0f);
|
bitmaps[2]->setVelY(3.0f);
|
||||||
@@ -62,15 +62,15 @@ Intro::Intro(Screen *screen, Asset *asset, Input *input, options_t *options, par
|
|||||||
bitmaps[2]->setSpriteClip(0, 96, 128, 96);
|
bitmaps[2]->setSpriteClip(0, 96, 128, 96);
|
||||||
bitmaps[2]->setEnabledCounter(250);
|
bitmaps[2]->setEnabledCounter(250);
|
||||||
|
|
||||||
bitmaps[3]->setPosX(param->game.gameArea.centerX - 64);
|
bitmaps[3]->setPosX(param.game.gameArea.centerX - 64);
|
||||||
bitmaps[3]->setPosY(param->game.height);
|
bitmaps[3]->setPosY(param.game.height);
|
||||||
bitmaps[3]->setVelX(0.0f);
|
bitmaps[3]->setVelX(0.0f);
|
||||||
bitmaps[3]->setVelY(-0.7f);
|
bitmaps[3]->setVelY(-0.7f);
|
||||||
bitmaps[3]->setAccelX(0.0f);
|
bitmaps[3]->setAccelX(0.0f);
|
||||||
bitmaps[3]->setAccelY(0.0f);
|
bitmaps[3]->setAccelY(0.0f);
|
||||||
bitmaps[3]->setSpriteClip(128, 96, 128, 96);
|
bitmaps[3]->setSpriteClip(128, 96, 128, 96);
|
||||||
|
|
||||||
bitmaps[4]->setPosX(param->game.gameArea.centerX - 64);
|
bitmaps[4]->setPosX(param.game.gameArea.centerX - 64);
|
||||||
bitmaps[4]->setPosY(-96);
|
bitmaps[4]->setPosY(-96);
|
||||||
bitmaps[4]->setVelX(0.0f);
|
bitmaps[4]->setVelX(0.0f);
|
||||||
bitmaps[4]->setVelY(3.0f);
|
bitmaps[4]->setVelY(3.0f);
|
||||||
@@ -78,8 +78,8 @@ Intro::Intro(Screen *screen, Asset *asset, Input *input, options_t *options, par
|
|||||||
bitmaps[4]->setAccelY(0.3f);
|
bitmaps[4]->setAccelY(0.3f);
|
||||||
bitmaps[4]->setSpriteClip(0, 192, 128, 96);
|
bitmaps[4]->setSpriteClip(0, 192, 128, 96);
|
||||||
|
|
||||||
bitmaps[5]->setPosX(param->game.width);
|
bitmaps[5]->setPosX(param.game.width);
|
||||||
bitmaps[5]->setPosY(param->game.gameArea.firstQuarterY - 24);
|
bitmaps[5]->setPosY(param.game.gameArea.firstQuarterY - 24);
|
||||||
bitmaps[5]->setVelX(-0.7f);
|
bitmaps[5]->setVelX(-0.7f);
|
||||||
bitmaps[5]->setVelY(0.0f);
|
bitmaps[5]->setVelY(0.0f);
|
||||||
bitmaps[5]->setAccelX(0.0f);
|
bitmaps[5]->setAccelX(0.0f);
|
||||||
@@ -92,7 +92,7 @@ Intro::Intro(Screen *screen, Asset *asset, Input *input, options_t *options, par
|
|||||||
{
|
{
|
||||||
Writer *w = new Writer(text);
|
Writer *w = new Writer(text);
|
||||||
w->setPosX(BLOCK * 0);
|
w->setPosX(BLOCK * 0);
|
||||||
w->setPosY(param->game.height - (BLOCK * 6));
|
w->setPosY(param.game.height - (BLOCK * 6));
|
||||||
w->setKerning(-1);
|
w->setKerning(-1);
|
||||||
w->setEnabled(false);
|
w->setEnabled(false);
|
||||||
w->setEnabledCounter(180);
|
w->setEnabledCounter(180);
|
||||||
@@ -137,7 +137,7 @@ Intro::Intro(Screen *screen, Asset *asset, Input *input, options_t *options, par
|
|||||||
|
|
||||||
for (auto text : texts)
|
for (auto text : texts)
|
||||||
{
|
{
|
||||||
text->center(param->game.gameArea.centerX);
|
text->center(param.game.gameArea.centerX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ private:
|
|||||||
Text *text; // Textos de la intro
|
Text *text; // Textos de la intro
|
||||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
options_t *options; // Opciones del programa
|
options_t *options; // Opciones del programa
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
@@ -63,7 +62,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music);
|
Intro(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Intro();
|
~Intro();
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#include "logo.h"
|
#include "logo.h"
|
||||||
|
#include "param.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section)
|
Logo::Logo(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->param = param;
|
|
||||||
this->section = section;
|
this->section = section;
|
||||||
SDL_Renderer *renderer = screen->getRenderer();
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ Logo::Logo(Screen *screen, Asset *asset, Input *input, options_t *options, param
|
|||||||
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->game.width - sinceTexture->getWidth()) / 2, 83 + jailTexture->getHeight() + 5, sinceTexture->getWidth(), sinceTexture->getHeight(), sinceTexture);
|
sinceSprite = new Sprite((param.game.width - sinceTexture->getWidth()) / 2, 83 + jailTexture->getHeight() + 5, sinceTexture->getWidth(), sinceTexture->getHeight(), sinceTexture);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
@@ -29,8 +29,8 @@ Logo::Logo(Screen *screen, Asset *asset, Input *input, options_t *options, param
|
|||||||
endLogo_cm = 400;
|
endLogo_cm = 400;
|
||||||
postLogoDuration = 20;
|
postLogoDuration = 20;
|
||||||
speed = 8;
|
speed = 8;
|
||||||
dest.x = param->game.gameArea.centerX - jailTexture->getWidth() / 2;
|
dest.x = param.game.gameArea.centerX - jailTexture->getWidth() / 2;
|
||||||
dest.y = param->game.gameArea.centerY - jailTexture->getHeight() / 2;
|
dest.y = param.game.gameArea.centerY - jailTexture->getHeight() / 2;
|
||||||
sinceSprite->setPosY(dest.y + jailTexture->getHeight() + 5);
|
sinceSprite->setPosY(dest.y + jailTexture->getHeight() + 5);
|
||||||
sinceSprite->setSpriteClip(0, 0, sinceTexture->getWidth(), sinceTexture->getHeight());
|
sinceSprite->setSpriteClip(0, 0, sinceTexture->getWidth(), sinceTexture->getHeight());
|
||||||
sinceSprite->setEnabled(false);
|
sinceSprite->setEnabled(false);
|
||||||
@@ -41,7 +41,7 @@ Logo::Logo(Screen *screen, Asset *asset, Input *input, options_t *options, param
|
|||||||
{
|
{
|
||||||
Sprite *temp = new Sprite(0, i, jailTexture->getWidth(), 1, jailTexture);
|
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->game.width + (i * 3) : -jailTexture->getWidth() - (i * 3);
|
const int posX = (i % 2 == 0) ? param.game.width + (i * 3) : -jailTexture->getWidth() - (i * 3);
|
||||||
temp->setPosX(posX);
|
temp->setPosX(posX);
|
||||||
temp->setPosY(dest.y + i);
|
temp->setPosY(dest.y + i);
|
||||||
jailSprite.push_back(temp);
|
jailSprite.push_back(temp);
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ private:
|
|||||||
std::vector<Sprite *> jailSprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
std::vector<Sprite *> jailSprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||||
Sprite *sinceSprite; // Sprite para manejar la sinceTexture
|
Sprite *sinceSprite; // Sprite para manejar la sinceTexture
|
||||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
options_t *options; // Opciones del programa
|
options_t *options; // Opciones del programa
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
@@ -74,7 +73,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section);
|
Logo(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Logo();
|
~Logo();
|
||||||
|
|||||||
@@ -1,61 +1,63 @@
|
|||||||
#include "load_param.h"
|
#include "param.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
param_t param;
|
||||||
|
|
||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
bool setOptions(param_t *param, std::string var, std::string value);
|
bool setOptions(std::string var, std::string value);
|
||||||
|
|
||||||
// Calcula variables a partir de otras variables
|
// Calcula variables a partir de otras variables
|
||||||
void precalculateZones(param_t *param);
|
void precalculateZones();
|
||||||
|
|
||||||
// Establece valores por defecto a las variables
|
// Establece valores por defecto a las variables
|
||||||
void initParam(param_t *param)
|
void initParam()
|
||||||
{
|
{
|
||||||
// GAME
|
// GAME
|
||||||
param->game.width = 320;
|
param.game.width = 320;
|
||||||
param->game.height = 256;
|
param.game.height = 256;
|
||||||
param->game.itemSize = 20;
|
param.game.itemSize = 20;
|
||||||
param->game.gameArea.rect = {0, 0, param->game.width, param->game.height};
|
param.game.gameArea.rect = {0, 0, param.game.width, param.game.height};
|
||||||
param->game.playArea.rect = {0, 0, param->game.width, 216};
|
param.game.playArea.rect = {0, 0, param.game.width, 216};
|
||||||
precalculateZones(param);
|
precalculateZones();
|
||||||
|
|
||||||
// SCOREBOARD
|
// SCOREBOARD
|
||||||
param->scoreboard = {0, 216, param->game.width, 40};
|
param.scoreboard = {0, 216, param.game.width, 40};
|
||||||
|
|
||||||
// FADE
|
// FADE
|
||||||
param->fade.numSquaresWidth = param->game.width / 2;
|
param.fade.numSquaresWidth = param.game.width / 2;
|
||||||
param->fade.numSquaresHeight = param->game.height / 2;
|
param.fade.numSquaresHeight = param.game.height / 2;
|
||||||
param->fade.randomSquaresDelay = 1;
|
param.fade.randomSquaresDelay = 1;
|
||||||
param->fade.randomSquaresMult = 500;
|
param.fade.randomSquaresMult = 500;
|
||||||
param->fade.postDuration = 80;
|
param.fade.postDuration = 80;
|
||||||
param->fade.venetianSize = 16;
|
param.fade.venetianSize = 16;
|
||||||
|
|
||||||
// TITLE
|
// TITLE
|
||||||
param->title.pressStartPosition = 160;
|
param.title.pressStartPosition = 160;
|
||||||
param->title.titleDuration = 800;
|
param.title.titleDuration = 800;
|
||||||
param->title.arcadeEditionPosition = 123;
|
param.title.arcadeEditionPosition = 123;
|
||||||
param->title.titleCCPosition = 11;
|
param.title.titleCCPosition = 11;
|
||||||
|
|
||||||
// BACKGROUND
|
// BACKGROUND
|
||||||
param->background.attenuateColor = {255, 255, 255};
|
param.background.attenuateColor = {255, 255, 255};
|
||||||
param->background.attenuateAlpha = 32;
|
param.background.attenuateAlpha = 32;
|
||||||
|
|
||||||
// BALLOONS
|
// BALLOONS
|
||||||
param->balloon1.vel = 2.60f;
|
param.balloon1.vel = 2.60f;
|
||||||
param->balloon1.grav = 0.09f;
|
param.balloon1.grav = 0.09f;
|
||||||
param->balloon2.vel = 3.50f;
|
param.balloon2.vel = 3.50f;
|
||||||
param->balloon2.grav = 0.10f;
|
param.balloon2.grav = 0.10f;
|
||||||
param->balloon3.vel = 4.50f;
|
param.balloon3.vel = 4.50f;
|
||||||
param->balloon3.grav = 0.10f;
|
param.balloon3.grav = 0.10f;
|
||||||
param->balloon4.vel = 4.95f;
|
param.balloon4.vel = 4.95f;
|
||||||
param->balloon4.grav = 0.10f;
|
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
|
||||||
void loadParamsFromFile(param_t *param, std::string filePath)
|
void loadParamsFromFile(std::string filePath)
|
||||||
{
|
{
|
||||||
// Pone valores por defecto a las variables
|
// Pone valores por defecto a las variables
|
||||||
initParam(param);
|
initParam();
|
||||||
|
|
||||||
// Variables para manejar el fichero
|
// Variables para manejar el fichero
|
||||||
std::string line;
|
std::string line;
|
||||||
@@ -134,7 +136,7 @@ void loadParamsFromFile(param_t *param, std::string filePath)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setOptions(param, param1, param2);
|
setOptions(param1, param2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cierra el fichero
|
// Cierra el fichero
|
||||||
@@ -145,11 +147,11 @@ void loadParamsFromFile(param_t *param, std::string filePath)
|
|||||||
std::cout << "Failed to load file: " << filePath << std::endl;
|
std::cout << "Failed to load file: " << filePath << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
precalculateZones(param);
|
precalculateZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
bool setOptions(param_t *param, std::string var, std::string value)
|
bool setOptions(std::string var, std::string value)
|
||||||
{
|
{
|
||||||
// Indicador de éxito en la asignación
|
// Indicador de éxito en la asignación
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@@ -157,172 +159,172 @@ bool setOptions(param_t *param, std::string var, std::string value)
|
|||||||
// GAME
|
// GAME
|
||||||
if (var == "game.width")
|
if (var == "game.width")
|
||||||
{
|
{
|
||||||
param->game.width = std::stoi(value);
|
param.game.width = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "game.height")
|
else if (var == "game.height")
|
||||||
{
|
{
|
||||||
param->game.height = std::stoi(value);
|
param.game.height = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "game.itemSize")
|
else if (var == "game.itemSize")
|
||||||
{
|
{
|
||||||
param->game.itemSize = std::stoi(value);
|
param.game.itemSize = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "game.playArea.rect.x")
|
else if (var == "game.playArea.rect.x")
|
||||||
{
|
{
|
||||||
param->game.playArea.rect.x = std::stoi(value);
|
param.game.playArea.rect.x = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "game.playArea.rect.y")
|
else if (var == "game.playArea.rect.y")
|
||||||
{
|
{
|
||||||
param->game.playArea.rect.y = std::stoi(value);
|
param.game.playArea.rect.y = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "game.playArea.rect.w")
|
else if (var == "game.playArea.rect.w")
|
||||||
{
|
{
|
||||||
param->game.playArea.rect.w = std::stoi(value);
|
param.game.playArea.rect.w = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "game.playArea.rect.h")
|
else if (var == "game.playArea.rect.h")
|
||||||
{
|
{
|
||||||
param->game.playArea.rect.h = std::stoi(value);
|
param.game.playArea.rect.h = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FADE
|
// FADE
|
||||||
else if (var == "fade.numSquaresWidth")
|
else if (var == "fade.numSquaresWidth")
|
||||||
{
|
{
|
||||||
param->fade.numSquaresWidth = std::stoi(value);
|
param.fade.numSquaresWidth = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "fade.numSquaresHeight")
|
else if (var == "fade.numSquaresHeight")
|
||||||
{
|
{
|
||||||
param->fade.numSquaresHeight = std::stoi(value);
|
param.fade.numSquaresHeight = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "fade.randomSquaresDelay")
|
else if (var == "fade.randomSquaresDelay")
|
||||||
{
|
{
|
||||||
param->fade.randomSquaresDelay = std::stoi(value);
|
param.fade.randomSquaresDelay = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "fade.randomSquaresMult")
|
else if (var == "fade.randomSquaresMult")
|
||||||
{
|
{
|
||||||
param->fade.randomSquaresMult = std::stoi(value);
|
param.fade.randomSquaresMult = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "fade.postDuration")
|
else if (var == "fade.postDuration")
|
||||||
{
|
{
|
||||||
param->fade.postDuration = std::stoi(value);
|
param.fade.postDuration = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "fade.venetianSize")
|
else if (var == "fade.venetianSize")
|
||||||
{
|
{
|
||||||
param->fade.venetianSize = std::stoi(value);
|
param.fade.venetianSize = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SCOREBOARD
|
// SCOREBOARD
|
||||||
else if (var == "scoreboard.x")
|
else if (var == "scoreboard.x")
|
||||||
{
|
{
|
||||||
param->scoreboard.x = std::stoi(value);
|
param.scoreboard.x = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "scoreboard.y")
|
else if (var == "scoreboard.y")
|
||||||
{
|
{
|
||||||
param->scoreboard.y = std::stoi(value);
|
param.scoreboard.y = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "scoreboard.w")
|
else if (var == "scoreboard.w")
|
||||||
{
|
{
|
||||||
param->scoreboard.w = std::stoi(value);
|
param.scoreboard.w = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "scoreboard.h")
|
else if (var == "scoreboard.h")
|
||||||
{
|
{
|
||||||
param->scoreboard.h = std::stoi(value);
|
param.scoreboard.h = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TITLE
|
// TITLE
|
||||||
else if (var == "title.pressStartPosition")
|
else if (var == "title.pressStartPosition")
|
||||||
{
|
{
|
||||||
param->title.pressStartPosition = std::stoi(value);
|
param.title.pressStartPosition = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "title.titleDuration")
|
else if (var == "title.titleDuration")
|
||||||
{
|
{
|
||||||
param->title.titleDuration = std::stoi(value);
|
param.title.titleDuration = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "title.arcadeEditionPosition")
|
else if (var == "title.arcadeEditionPosition")
|
||||||
{
|
{
|
||||||
param->title.arcadeEditionPosition = std::stoi(value);
|
param.title.arcadeEditionPosition = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "title.titleCCPosition")
|
else if (var == "title.titleCCPosition")
|
||||||
{
|
{
|
||||||
param->title.titleCCPosition = std::stoi(value);
|
param.title.titleCCPosition = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BACKGROUND
|
// BACKGROUND
|
||||||
else if (var == "background.attenuateColor.r")
|
else if (var == "background.attenuateColor.r")
|
||||||
{
|
{
|
||||||
param->background.attenuateColor.r = std::stoi(value);
|
param.background.attenuateColor.r = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "background.attenuateColor.g")
|
else if (var == "background.attenuateColor.g")
|
||||||
{
|
{
|
||||||
param->background.attenuateColor.g = std::stoi(value);
|
param.background.attenuateColor.g = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "background.attenuateColor.b")
|
else if (var == "background.attenuateColor.b")
|
||||||
{
|
{
|
||||||
param->background.attenuateColor.b = std::stoi(value);
|
param.background.attenuateColor.b = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "background.attenuateAlpha")
|
else if (var == "background.attenuateAlpha")
|
||||||
{
|
{
|
||||||
param->background.attenuateAlpha = std::stoi(value);
|
param.background.attenuateAlpha = std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BALLOON
|
// BALLOON
|
||||||
else if (var == "balloon1.vel")
|
else if (var == "balloon1.vel")
|
||||||
{
|
{
|
||||||
param->balloon1.vel = std::stof(value);
|
param.balloon1.vel = std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "balloon1.grav")
|
else if (var == "balloon1.grav")
|
||||||
{
|
{
|
||||||
param->balloon1.grav = std::stof(value);
|
param.balloon1.grav = std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "balloon2.vel")
|
else if (var == "balloon2.vel")
|
||||||
{
|
{
|
||||||
param->balloon2.vel = std::stof(value);
|
param.balloon2.vel = std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "balloon2.grav")
|
else if (var == "balloon2.grav")
|
||||||
{
|
{
|
||||||
param->balloon2.grav = std::stof(value);
|
param.balloon2.grav = std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "balloon3.vel")
|
else if (var == "balloon3.vel")
|
||||||
{
|
{
|
||||||
param->balloon3.vel = std::stof(value);
|
param.balloon3.vel = std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "balloon3.grav")
|
else if (var == "balloon3.grav")
|
||||||
{
|
{
|
||||||
param->balloon3.grav = std::stof(value);
|
param.balloon3.grav = std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "balloon4.vel")
|
else if (var == "balloon4.vel")
|
||||||
{
|
{
|
||||||
param->balloon4.vel = std::stof(value);
|
param.balloon4.vel = std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (var == "balloon4.grav")
|
else if (var == "balloon4.grav")
|
||||||
{
|
{
|
||||||
param->balloon4.grav = std::stof(value);
|
param.balloon4.grav = std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RESTO
|
// RESTO
|
||||||
@@ -335,23 +337,22 @@ bool setOptions(param_t *param, std::string var, std::string value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcula variables a partir de otras variables
|
// Calcula variables a partir de otras variables
|
||||||
void precalculateZones(param_t *param)
|
void precalculateZones()
|
||||||
{
|
{
|
||||||
|
|
||||||
// playArea
|
// playArea
|
||||||
param->game.playArea.centerX = param->game.playArea.rect.w / 2;
|
param.game.playArea.centerX = param.game.playArea.rect.w / 2;
|
||||||
param->game.playArea.firstQuarterX = param->game.playArea.rect.w / 4;
|
param.game.playArea.firstQuarterX = param.game.playArea.rect.w / 4;
|
||||||
param->game.playArea.thirdQuarterX = param->game.playArea.rect.w / 4 * 3;
|
param.game.playArea.thirdQuarterX = param.game.playArea.rect.w / 4 * 3;
|
||||||
param->game.playArea.centerY = param->game.playArea.rect.h / 2;
|
param.game.playArea.centerY = param.game.playArea.rect.h / 2;
|
||||||
param->game.playArea.firstQuarterY = param->game.playArea.rect.h / 4;
|
param.game.playArea.firstQuarterY = param.game.playArea.rect.h / 4;
|
||||||
param->game.playArea.thirdQuarterY = param->game.playArea.rect.h / 4 * 3;
|
param.game.playArea.thirdQuarterY = param.game.playArea.rect.h / 4 * 3;
|
||||||
|
|
||||||
// gameArea
|
// gameArea
|
||||||
param->game.gameArea.rect = {0, 0, param->game.width, param->game.height};
|
param.game.gameArea.rect = {0, 0, param.game.width, param.game.height};
|
||||||
param->game.gameArea.centerX = param->game.gameArea.rect.w / 2;
|
param.game.gameArea.centerX = param.game.gameArea.rect.w / 2;
|
||||||
param->game.gameArea.firstQuarterX = param->game.gameArea.rect.w / 4;
|
param.game.gameArea.firstQuarterX = param.game.gameArea.rect.w / 4;
|
||||||
param->game.gameArea.thirdQuarterX = param->game.gameArea.rect.w / 4 * 3;
|
param.game.gameArea.thirdQuarterX = param.game.gameArea.rect.w / 4 * 3;
|
||||||
param->game.gameArea.centerY = param->game.gameArea.rect.h / 2;
|
param.game.gameArea.centerY = param.game.gameArea.rect.h / 2;
|
||||||
param->game.gameArea.firstQuarterY = param->game.gameArea.rect.h / 4;
|
param.game.gameArea.firstQuarterY = param.game.gameArea.rect.h / 4;
|
||||||
param->game.gameArea.thirdQuarterY = param->game.gameArea.rect.h / 4 * 3;
|
param.game.gameArea.thirdQuarterY = param.game.gameArea.rect.h / 4 * 3;
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,7 @@
|
|||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
|
extern param_t param;
|
||||||
|
|
||||||
// Establece valores para los parametros a partir de un fichero de texto
|
// Establece valores para los parametros a partir de un fichero de texto
|
||||||
void loadParamsFromFile(param_t *param, std::string filePath);
|
void loadParamsFromFile(std::string filePath);
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
#include "title.h"
|
#include "title.h"
|
||||||
|
#include "param.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Title::Title(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music)
|
Title::Title(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia las direcciones de los punteros y objetos
|
// Copia las direcciones de los punteros y objetos
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->param = param;
|
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
SDL_Renderer *renderer = screen->getRenderer();
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Reserva memoria y crea los objetos
|
// Reserva memoria y crea los objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
fade = new Fade(renderer, param);
|
fade = new Fade(renderer);
|
||||||
|
|
||||||
text1 = new Text(asset->get("smb2.gif"), asset->get("smb2.txt"), renderer);
|
text1 = new Text(asset->get("smb2.gif"), asset->get("smb2.txt"), renderer);
|
||||||
text1->addPalette(asset->get("smb2_pal1.gif"));
|
text1->addPalette(asset->get("smb2_pal1.gif"));
|
||||||
@@ -23,14 +23,14 @@ Title::Title(Screen *screen, Asset *asset, Input *input, options_t *options, par
|
|||||||
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(param->game.gameArea.centerX - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture);
|
miniLogoSprite = new Sprite(param.game.gameArea.centerX - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture);
|
||||||
|
|
||||||
tiledbg = new Tiledbg(renderer, asset, {0, 0, param->game.width, param->game.height}, TILED_MODE_RANDOM);
|
tiledbg = new Tiledbg(renderer, asset, {0, 0, param.game.width, param.game.height}, TILED_MODE_RANDOM);
|
||||||
|
|
||||||
gameLogo = new GameLogo(renderer, screen, asset, param, param->game.gameArea.centerX, param->title.titleCCPosition);
|
gameLogo = new GameLogo(renderer, screen, asset, param.game.gameArea.centerX, param.title.titleCCPosition);
|
||||||
gameLogo->enable();
|
gameLogo->enable();
|
||||||
|
|
||||||
defineButtons = new DefineButtons(input, text2, param, options, section);
|
defineButtons = new DefineButtons(input, text2, options, section);
|
||||||
|
|
||||||
// Inicializa los valores
|
// Inicializa los valores
|
||||||
init();
|
init();
|
||||||
@@ -66,7 +66,7 @@ void Title::init()
|
|||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b);
|
||||||
fade->setType(FADE_RANDOM_SQUARE);
|
fade->setType(FADE_RANDOM_SQUARE);
|
||||||
fade->setPost(param->fade.postDuration);
|
fade->setPost(param.fade.postDuration);
|
||||||
demo = true;
|
demo = true;
|
||||||
numControllers = input->getNumControllers();
|
numControllers = input->getNumControllers();
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ void Title::update()
|
|||||||
// Actualiza el mosaico de fondo
|
// Actualiza el mosaico de fondo
|
||||||
tiledbg->update();
|
tiledbg->update();
|
||||||
|
|
||||||
if (counter == param->title.titleDuration)
|
if (counter == param.title.titleDuration)
|
||||||
{
|
{
|
||||||
fade->activate();
|
fade->activate();
|
||||||
postFade = -1;
|
postFade = -1;
|
||||||
@@ -167,17 +167,17 @@ void Title::render()
|
|||||||
// 'PULSA 1P o 2P PARA JUGAR'
|
// 'PULSA 1P o 2P PARA JUGAR'
|
||||||
if (counter % 50 > 14 && !defineButtons->isEnabled())
|
if (counter % 50 > 14 && !defineButtons->isEnabled())
|
||||||
{
|
{
|
||||||
text1->writeDX(TXT_CENTER | TXT_SHADOW, param->game.gameArea.centerX, param->title.pressStartPosition, lang::getText(23), 1, noColor, 1, shadow);
|
text1->writeDX(TXT_CENTER | TXT_SHADOW, param.game.gameArea.centerX, param.title.pressStartPosition, lang::getText(23), 1, noColor, 1, shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mini logo
|
// Mini logo
|
||||||
const int pos1 = (param->game.height / 5 * 4) + BLOCK;
|
const int pos1 = (param.game.height / 5 * 4) + BLOCK;
|
||||||
const int pos2 = pos1 + miniLogoSprite->getHeight() + 3;
|
const int pos2 = pos1 + miniLogoSprite->getHeight() + 3;
|
||||||
miniLogoSprite->setPosY(pos1);
|
miniLogoSprite->setPosY(pos1);
|
||||||
miniLogoSprite->render();
|
miniLogoSprite->render();
|
||||||
|
|
||||||
// Texto con el copyright
|
// Texto con el copyright
|
||||||
text1->writeDX(TXT_CENTER | TXT_SHADOW, param->game.gameArea.centerX, pos2, TEXT_COPYRIGHT, 1, noColor, 1, shadow);
|
text1->writeDX(TXT_CENTER | TXT_SHADOW, param.game.gameArea.centerX, pos2, TEXT_COPYRIGHT, 1, noColor, 1, shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define Buttons
|
// Define Buttons
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ private:
|
|||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
int postFade; // Opción a realizar cuando termina el fundido
|
int postFade; // Opción a realizar cuando termina el fundido
|
||||||
options_t *options; // Opciones del programa
|
options_t *options; // Opciones del programa
|
||||||
param_t *param; // Puntero con todos los parametros del programa
|
|
||||||
int numControllers; // Número de mandos conectados
|
int numControllers; // Número de mandos conectados
|
||||||
|
|
||||||
// Inicializa los valores de las variables
|
// Inicializa los valores de las variables
|
||||||
@@ -104,7 +103,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Title(Screen *screen, Asset *asset, Input *input, options_t *options, param_t *param, section_t *section, JA_Music_t *music);
|
Title(Screen *screen, Asset *asset, Input *input, options_t *options, section_t *section, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Title();
|
~Title();
|
||||||
|
|||||||
Reference in New Issue
Block a user