Compare commits
3 Commits
4df505d263
...
9d5aee2562
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d5aee2562 | |||
| 477891cac7 | |||
| 45731c8294 |
@@ -432,3 +432,9 @@ void Screen::showNotification(std::string text1, std::string text2, int icon)
|
|||||||
{
|
{
|
||||||
notify->showText(text1, text2, icon);
|
notify->showText(text1, text2, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtiene el puntero al renderizador
|
||||||
|
SDL_Renderer *Screen::getRenderer()
|
||||||
|
{
|
||||||
|
return renderer;
|
||||||
|
}
|
||||||
@@ -134,4 +134,7 @@ public:
|
|||||||
|
|
||||||
// Muestra una notificación de texto por pantalla;
|
// Muestra una notificación de texto por pantalla;
|
||||||
void showNotification(std::string text1 = "", std::string text2 = "", int icon = -1);
|
void showNotification(std::string text1 = "", std::string text2 = "", int icon = -1);
|
||||||
|
|
||||||
|
// Obtiene el puntero al renderizador
|
||||||
|
SDL_Renderer *getRenderer();
|
||||||
};
|
};
|
||||||
@@ -836,7 +836,7 @@ void Director::deleteMusics()
|
|||||||
// Ejecuta la seccion de juego con el logo
|
// Ejecuta la seccion de juego con el logo
|
||||||
void Director::runLogo()
|
void Director::runLogo()
|
||||||
{
|
{
|
||||||
logo = new Logo(renderer, screen, asset, input, param, section);
|
logo = new Logo(screen, asset, input, param, section);
|
||||||
logo->run();
|
logo->run();
|
||||||
delete logo;
|
delete logo;
|
||||||
}
|
}
|
||||||
@@ -844,7 +844,7 @@ void Director::runLogo()
|
|||||||
// Ejecuta la seccion de juego de la introducción
|
// Ejecuta la seccion de juego de la introducción
|
||||||
void Director::runIntro()
|
void Director::runIntro()
|
||||||
{
|
{
|
||||||
intro = new Intro(renderer, screen, asset, input, lang, param, section, getMusic(musics, "intro.ogg"));
|
intro = new Intro(screen, asset, input, lang, param, section, getMusic(musics, "intro.ogg"));
|
||||||
intro->run();
|
intro->run();
|
||||||
delete intro;
|
delete intro;
|
||||||
}
|
}
|
||||||
@@ -852,7 +852,7 @@ void Director::runIntro()
|
|||||||
// Ejecuta la seccion de juego con el titulo y los menus
|
// Ejecuta la seccion de juego con el titulo y los menus
|
||||||
void Director::runTitle()
|
void Director::runTitle()
|
||||||
{
|
{
|
||||||
title = new Title(renderer, screen, input, asset, options, lang, param, section, getMusic(musics, "title.ogg"));
|
title = new Title(screen, asset, input, options, lang, param, section, getMusic(musics, "title.ogg"));
|
||||||
title->run();
|
title->run();
|
||||||
delete title;
|
delete title;
|
||||||
}
|
}
|
||||||
@@ -861,7 +861,7 @@ void Director::runTitle()
|
|||||||
void Director::runGame()
|
void Director::runGame()
|
||||||
{
|
{
|
||||||
const int playerID = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
const int playerID = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
||||||
game = new Game(playerID, 0, renderer, screen, asset, lang, input, false, param, options, section, getMusic(musics, "playing.ogg"));
|
game = new Game(playerID, 0, screen, asset, lang, input, false, param, options, section, getMusic(musics, "playing.ogg"));
|
||||||
game->run();
|
game->run();
|
||||||
delete game;
|
delete game;
|
||||||
}
|
}
|
||||||
@@ -869,7 +869,7 @@ void Director::runGame()
|
|||||||
// Ejecuta la parte donde se muestra la tabla de puntuaciones
|
// Ejecuta la parte donde se muestra la tabla de puntuaciones
|
||||||
void Director::runHiScoreTable()
|
void Director::runHiScoreTable()
|
||||||
{
|
{
|
||||||
hiScoreTable = new HiScoreTable(renderer, screen, asset, input, lang, param, options, section);
|
hiScoreTable = new HiScoreTable(screen, asset, input, lang, param, options, section);
|
||||||
hiScoreTable->run();
|
hiScoreTable->run();
|
||||||
delete hiScoreTable;
|
delete hiScoreTable;
|
||||||
}
|
}
|
||||||
@@ -877,7 +877,7 @@ void Director::runHiScoreTable()
|
|||||||
// Ejecuta la parte donde se muestran las instrucciones
|
// Ejecuta la parte donde se muestran las instrucciones
|
||||||
void Director::runInstructions()
|
void Director::runInstructions()
|
||||||
{
|
{
|
||||||
instructions = new Instructions(renderer, screen, asset, input, lang, param, section);
|
instructions = new Instructions(screen, asset, input, lang, param, section);
|
||||||
instructions->run();
|
instructions->run();
|
||||||
delete instructions;
|
delete instructions;
|
||||||
}
|
}
|
||||||
@@ -886,7 +886,7 @@ void Director::runInstructions()
|
|||||||
void Director::runDemoGame()
|
void Director::runDemoGame()
|
||||||
{
|
{
|
||||||
const int playerID = (rand() % 2) + 1;
|
const int playerID = (rand() % 2) + 1;
|
||||||
demoGame = new Game(playerID, 0, renderer, screen, asset, lang, input, true, param, options, section, nullptr);
|
demoGame = new Game(playerID, 0, screen, asset, lang, input, true, param, options, section, nullptr);
|
||||||
demoGame->run();
|
demoGame->run();
|
||||||
delete demoGame;
|
delete demoGame;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
#define DEATH_COUNTER 350
|
#define DEATH_COUNTER 350
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section, JA_Music_t *music)
|
Game::Game(int playerID, int currentStage, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->lang = lang;
|
this->lang = lang;
|
||||||
@@ -15,6 +14,7 @@ Game::Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *scree
|
|||||||
this->options = options;
|
this->options = options;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
|
renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Pasa variables
|
// Pasa variables
|
||||||
this->demo.enabled = demo;
|
this->demo.enabled = demo;
|
||||||
@@ -967,9 +967,9 @@ void Game::renderPlayers()
|
|||||||
{
|
{
|
||||||
player->render();
|
player->render();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
//SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
// SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||||
//const circle_t c = player->getCollider();
|
// const circle_t c = player->getCollider();
|
||||||
//DrawCircle(renderer, c.x, c.y, c.r);
|
// DrawCircle(renderer, c.x, c.y, c.r);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,32 @@
|
|||||||
// Valores para las variables asociadas a los objetos
|
// Valores para las variables asociadas a los objetos
|
||||||
#define TIME_STOPPED_COUNTER 300
|
#define TIME_STOPPED_COUNTER 300
|
||||||
|
|
||||||
|
/*
|
||||||
|
Esta clase gestiona un estado del programa. Se encarga de toda la parte en la
|
||||||
|
que se está jugando.
|
||||||
|
|
||||||
|
Tiene:
|
||||||
|
- Cacheadas todas las texturas y animaciones que usaran los diferentes objetos.
|
||||||
|
Mediante el método loadMedia() almacena en vectores todos los recursos
|
||||||
|
- Tiene vectores con objetos: jugadores, enemigos, balas, explosiones, objetos y otros (sprites con los puntos al coger objetos)
|
||||||
|
- Se encarga de comprobar las colisiones entre los diferentes objetos, los marca como deshabilitados si es el caso y
|
||||||
|
luego revisa los vectores para eliminar los objetos deshabilitados
|
||||||
|
|
||||||
|
Utiliza:
|
||||||
|
- Un objeto para dibujar el fondo animado
|
||||||
|
- Un objeto para dibujar el marcador
|
||||||
|
|
||||||
|
La clase comprueba el nivel de amenaza que hay en pantalla contando el número de enemigos y su peligrosidad y actua en consecuencia:
|
||||||
|
- Generando items
|
||||||
|
- Generando nuevas oleadas enemigas
|
||||||
|
|
||||||
|
Mientras haya un jugador activo siempre puede unirse un segundo jugador. Cada vez que un jugador muere
|
||||||
|
aparece una cuenta atras para permitirle continuar. Si la cuenta atras de ambos jugadores llega a cero,
|
||||||
|
el juego termina. Cuando ambos jugadores han finalizado, se permite introducir nombre para la tabla de records
|
||||||
|
adjuntando la máxima puntuación obtenida en la partida, solo en caso de que hayan conseguido superar la
|
||||||
|
puntuación mínima.
|
||||||
|
*/
|
||||||
|
|
||||||
// Clase Game
|
// Clase Game
|
||||||
class Game
|
class Game
|
||||||
{
|
{
|
||||||
@@ -428,7 +454,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section, JA_Music_t *music);
|
Game(int playerID, int currentStage, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Game();
|
~Game();
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, options_t *options, section_t *section)
|
HiScoreTable::HiScoreTable(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, options_t *options, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
this->renderer = renderer;
|
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
@@ -13,6 +12,7 @@ HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset,
|
|||||||
this->section = section;
|
this->section = section;
|
||||||
this->options = options;
|
this->options = options;
|
||||||
this->param = param;
|
this->param = param;
|
||||||
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Objetos
|
// Objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
|
|||||||
@@ -13,12 +13,21 @@
|
|||||||
#include "fade.h"
|
#include "fade.h"
|
||||||
#include "background.h"
|
#include "background.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Esta clase gestiona un estado del programa. Se encarga de mostrar la tabla con las puntuaciones
|
||||||
|
más altas. Para ello utiliza un objeto que se encarga de pintar el fondo y una textura
|
||||||
|
sobre la que escribe las puntuacions. Esta textura se recorre modificando la ventana de vista
|
||||||
|
para dar el efecto de que la textura se mueve sobre la pantalla.
|
||||||
|
|
||||||
|
Para mejorar la legibilidad de los textos, el objeto que dibuja el fondo es capaz de modificar
|
||||||
|
su atenuación.
|
||||||
|
*/
|
||||||
|
|
||||||
// Clase HiScoreTable
|
// Clase HiScoreTable
|
||||||
class HiScoreTable
|
class HiScoreTable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
||||||
@@ -69,7 +78,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, options_t *options, section_t *section);
|
HiScoreTable(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, options_t *options, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~HiScoreTable();
|
~HiScoreTable();
|
||||||
|
|||||||
@@ -2,21 +2,21 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section)
|
Instructions::Instructions(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->lang = lang;
|
this->lang = lang;
|
||||||
this->param = param;
|
this->param = param;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
// 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, screen, asset, {0, 0, param->gameWidth, param->gameHeight}, TILED_MODE_STATIC);
|
tiledbg = new Tiledbg(renderer, asset, {0, 0, param->gameWidth, param->gameHeight}, TILED_MODE_STATIC);
|
||||||
fade = new Fade(renderer, param);
|
fade = new Fade(renderer, param);
|
||||||
|
|
||||||
// Crea un backbuffer para el renderizador
|
// Crea un backbuffer para el renderizador
|
||||||
@@ -181,7 +181,7 @@ void Instructions::fillTexture()
|
|||||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, anchor2, lang->getText(16), 1, orangeColor, 1, shdwTxtColor);
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, anchor2, lang->getText(16), 1, orangeColor, 1, shdwTxtColor);
|
||||||
|
|
||||||
const int anchor3 = anchor2 + spacePostHeader;
|
const int anchor3 = anchor2 + spacePostHeader;
|
||||||
//const int anchor4 = anchor3 + ((param->itemSize + text->getCharacterSize()) / 2);
|
// const int anchor4 = anchor3 + ((param->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);
|
||||||
|
|||||||
@@ -13,12 +13,24 @@
|
|||||||
#include "tiledbg.h"
|
#include "tiledbg.h"
|
||||||
#include "fade.h"
|
#include "fade.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Esta clase gestiona un estado del programa. Se encarga de poner en pantalla
|
||||||
|
un texto explicativo para entender como se juega.
|
||||||
|
|
||||||
|
Ademas muestra algunos items y explica para qué sirven.
|
||||||
|
|
||||||
|
Utiliza dos texturas de apoyo, una con el texto ya escrito y otra donde se combina
|
||||||
|
tanto el texto de la primera textura como los sprites de los items.
|
||||||
|
|
||||||
|
Finalmente, una ventana recorre la textura para dar el efecto de que todo se desplaza
|
||||||
|
por la pantalla sobre el mosaico de fondo (gestionado por el correspondiente objeto)
|
||||||
|
*/
|
||||||
|
|
||||||
// Clase Instructions
|
// Clase Instructions
|
||||||
class Instructions
|
class Instructions
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
|
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
|
||||||
std::vector<Sprite *> sprites; // Vector con los sprites de los items
|
std::vector<Sprite *> sprites; // Vector con los sprites de los items
|
||||||
@@ -72,7 +84,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section);
|
Instructions(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Instructions();
|
~Instructions();
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section, JA_Music_t *music)
|
Intro::Intro(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->lang = lang;
|
this->lang = lang;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
@@ -12,6 +11,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input,
|
|||||||
this->param = param;
|
this->param = param;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
@@ -146,8 +146,6 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input,
|
|||||||
Intro::~Intro()
|
Intro::~Intro()
|
||||||
{
|
{
|
||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
|
|
||||||
texture->unload();
|
|
||||||
delete texture;
|
delete texture;
|
||||||
|
|
||||||
for (auto bitmap : bitmaps)
|
for (auto bitmap : bitmaps)
|
||||||
|
|||||||
@@ -12,12 +12,16 @@
|
|||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia
|
||||||
|
de introducción
|
||||||
|
*/
|
||||||
|
|
||||||
// Clase Intro
|
// Clase Intro
|
||||||
class Intro
|
class Intro
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Texture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
@@ -56,7 +60,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section, JA_Music_t *music);
|
Intro(Screen *screen, Asset *asset, Input *input, Lang *lang, param_t *param, section_t *section, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Intro();
|
~Intro();
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, param_t *param, section_t *section)
|
Logo::Logo(Screen *screen, Asset *asset, Input *input, param_t *param, section_t *section)
|
||||||
{
|
{
|
||||||
// Copia la dirección de los objetos
|
// Copia la dirección de los objetos
|
||||||
this->renderer = renderer;
|
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->param = param;
|
this->param = param;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
|
SDL_Renderer *renderer = screen->getRenderer();
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
|
|||||||
@@ -10,11 +10,19 @@
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el
|
||||||
|
logo de "JAILGAMES" utilizando un sencillo efecto consistente en generar un sprite por
|
||||||
|
cada linea del bitmap que forma la palabra "JAILGAMES". Posteriormente realiza una
|
||||||
|
modulación de color sobre la textura para simular un fade to black al estilo
|
||||||
|
ZX Spectrum
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Clase Logo
|
||||||
class Logo
|
class Logo
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Input *input; // Objeto pata gestionar la entrada
|
Input *input; // Objeto pata gestionar la entrada
|
||||||
@@ -60,7 +68,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, param_t *param, section_t *section);
|
Logo(Screen *screen, Asset *asset, Input *input, param_t *param, section_t *section);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Logo();
|
~Logo();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ ManageHiScoreTable::~ManageHiScoreTable()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Borra toda la tabla
|
// Resetea la tabla a los valores por defecto
|
||||||
void ManageHiScoreTable::clear()
|
void ManageHiScoreTable::clear()
|
||||||
{
|
{
|
||||||
// Limpia la tabla
|
// Limpia la tabla
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Esta clase sirve para añadir elementos hiScoreEntry_r a un vector (tabla), de manera
|
||||||
|
que la tabla siempre está ordenada. Además también tiene un método para dejar la tabla
|
||||||
|
con sus valores iniciales
|
||||||
|
*/
|
||||||
|
|
||||||
// Clase ManageHiScoreTable
|
// Clase ManageHiScoreTable
|
||||||
class ManageHiScoreTable
|
class ManageHiScoreTable
|
||||||
{
|
{
|
||||||
@@ -20,7 +26,7 @@ public:
|
|||||||
// Destructor
|
// Destructor
|
||||||
~ManageHiScoreTable();
|
~ManageHiScoreTable();
|
||||||
|
|
||||||
// Borra toda la tabla
|
// Resetea la tabla a los valores por defecto
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// Añade un elemento a la tabla
|
// Añade un elemento a la tabla
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#include "tiledbg.h"
|
#include "tiledbg.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Tiledbg::Tiledbg(SDL_Renderer *renderer, Screen *screen, Asset *asset, SDL_Rect pos, int mode)
|
Tiledbg::Tiledbg(SDL_Renderer *renderer, Asset *asset, SDL_Rect pos, int mode)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
this->screen = screen;
|
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
this->pos = pos;
|
this->pos = pos;
|
||||||
this->mode = mode;
|
this->mode = mode;
|
||||||
|
|||||||
@@ -6,21 +6,27 @@
|
|||||||
#include "common/sprite.h"
|
#include "common/sprite.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
|
// Modos de funcionamiento para el tileado de fondo
|
||||||
#define TILED_MODE_CIRCLE 0
|
#define TILED_MODE_CIRCLE 0
|
||||||
#define TILED_MODE_DIAGONAL 1
|
#define TILED_MODE_DIAGONAL 1
|
||||||
#define TILED_MODE_RANDOM 2
|
#define TILED_MODE_RANDOM 2
|
||||||
#define TILED_MODE_STATIC 3
|
#define TILED_MODE_STATIC 3
|
||||||
|
|
||||||
|
/*
|
||||||
|
Esta clase dibuja un tileado de fondo. Para ello se sirve de una textura "canvas", que rellena con los tiles.
|
||||||
|
El rectangulo "window" recorre la textura de diferentes formas para generar el efecto de movimiento de la
|
||||||
|
textura en pantalla
|
||||||
|
*/
|
||||||
|
|
||||||
// Clase Tiledbg
|
// Clase Tiledbg
|
||||||
class Tiledbg
|
class Tiledbg
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
SDL_Rect window; // Ventana visible para la textura de fondo del titulo
|
SDL_Rect window; // Ventana visible para la textura de fondo del titulo
|
||||||
SDL_Texture *canvas; // Textura dibujar el fondo del titulo
|
SDL_Texture *canvas; // Textura donde dibujar el fondo formado por tiles
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
SDL_Rect pos; // Posición y tamaña del mosaico
|
SDL_Rect pos; // Posición y tamaña del mosaico
|
||||||
@@ -38,7 +44,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Tiledbg(SDL_Renderer *renderer, Screen *screen, Asset *asset, SDL_Rect pos, int mode);
|
Tiledbg(SDL_Renderer *renderer, Asset *asset, SDL_Rect pos, int mode);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Tiledbg();
|
~Tiledbg();
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#include "title.h"
|
#include "title.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, param_t *param, section_t *section, JA_Music_t *music)
|
Title::Title(Screen *screen, Asset *asset, Input *input, options_t *options, Lang *lang, param_t *param, section_t *section, JA_Music_t *music)
|
||||||
{
|
{
|
||||||
// Copia las direcciones de los punteros y objetos
|
// Copia las direcciones de los punteros y objetos
|
||||||
this->renderer = renderer;
|
|
||||||
this->screen = screen;
|
this->screen = screen;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->asset = asset;
|
this->asset = asset;
|
||||||
@@ -13,6 +12,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
|||||||
this->param = param;
|
this->param = param;
|
||||||
this->section = section;
|
this->section = section;
|
||||||
this->music = music;
|
this->music = music;
|
||||||
|
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();
|
||||||
@@ -26,7 +26,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
|||||||
miniLogoTexture = new Texture(renderer, asset->get("logo_jailgames_mini.png"));
|
miniLogoTexture = new Texture(renderer, asset->get("logo_jailgames_mini.png"));
|
||||||
miniLogoSprite = new Sprite(GAMECANVAS_CENTER_X - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture);
|
miniLogoSprite = new Sprite(GAMECANVAS_CENTER_X - miniLogoTexture->getWidth() / 2, 0, miniLogoTexture->getWidth(), miniLogoTexture->getHeight(), miniLogoTexture);
|
||||||
|
|
||||||
tiledbg = new Tiledbg(renderer, screen, asset, {0, 0, param->gameWidth, param->gameHeight}, TILED_MODE_RANDOM);
|
tiledbg = new Tiledbg(renderer, asset, {0, 0, param->gameWidth, param->gameHeight}, TILED_MODE_RANDOM);
|
||||||
|
|
||||||
gameLogo = new GameLogo(renderer, screen, asset, param, GAMECANVAS_CENTER_X, param->titleCC);
|
gameLogo = new GameLogo(renderer, screen, asset, param, GAMECANVAS_CENTER_X, param->titleCC);
|
||||||
gameLogo->enable();
|
gameLogo->enable();
|
||||||
@@ -244,8 +244,8 @@ void Title::checkInput()
|
|||||||
const int index = input->checkAnyButtonPressed();
|
const int index = input->checkAnyButtonPressed();
|
||||||
if (index)
|
if (index)
|
||||||
{
|
{
|
||||||
if (section->subsection == SUBSECTION_TITLE_2)
|
if (section->subsection == SUBSECTION_TITLE_2 || ALLOW_TITLE_ANIMATION_SKIP)
|
||||||
{// No se puede empezar a jugar durante la animación del titulo
|
{ // No se puede empezar a jugar durante la animación del titulo
|
||||||
fade->activate();
|
fade->activate();
|
||||||
postFade = index;
|
postFade = index;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,29 @@
|
|||||||
// Textos
|
// Textos
|
||||||
#define TEXT_COPYRIGHT "@2020,2024 JailDesigner"
|
#define TEXT_COPYRIGHT "@2020,2024 JailDesigner"
|
||||||
|
|
||||||
|
// Parámetros
|
||||||
|
#define ALLOW_TITLE_ANIMATION_SKIP false
|
||||||
|
|
||||||
|
/*
|
||||||
|
Esta clase gestiona un estado del programa. Se encarga de la parte del titulo o menu
|
||||||
|
que sirve para empezar a jugar. Utiliza otras clases para:
|
||||||
|
- Mostrar el logo del juego
|
||||||
|
- Dibujar el tileado de fondo
|
||||||
|
- Redifinir los botones de los mandos de juego
|
||||||
|
|
||||||
|
Esta clase tiene dos estados:
|
||||||
|
- El titulo está animandose, con el fondo estático
|
||||||
|
- El titulo ya está en su sitio y el fondo se está animando
|
||||||
|
|
||||||
|
Por razones de diseño, no se permite saltarse la animación del titulo, aunque es
|
||||||
|
configurable mediante un define
|
||||||
|
*/
|
||||||
|
|
||||||
// Clase Title
|
// Clase Title
|
||||||
class Title
|
class Title
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
Input *input; // Objeto para leer las entradas de teclado o mando
|
Input *input; // Objeto para leer las entradas de teclado o mando
|
||||||
@@ -38,9 +55,9 @@ private:
|
|||||||
section_t *section; // Indicador para el bucle del titulo
|
section_t *section; // Indicador para el bucle del titulo
|
||||||
Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo
|
Tiledbg *tiledbg; // Objeto para dibujar el mosaico animado de fondo
|
||||||
GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego
|
GameLogo *gameLogo; // Objeto para dibujar el logo con el título del juego
|
||||||
|
DefineButtons *defineButtons; // Objeto para definir los botones del joystic
|
||||||
Texture *miniLogoTexture; // Textura con el logo de JailGames mini
|
Texture *miniLogoTexture; // Textura con el logo de JailGames mini
|
||||||
Sprite *miniLogoSprite; // Sprite con el logo de JailGames mini
|
Sprite *miniLogoSprite; // Sprite con el logo de JailGames mini
|
||||||
DefineButtons *defineButtons; // Objeto para definir los botones del joystic
|
|
||||||
|
|
||||||
Text *text1; // Objeto de texto para poder escribir textos en pantalla
|
Text *text1; // Objeto de texto para poder escribir textos en pantalla
|
||||||
Text *text2; // Objeto de texto para poder escribir textos en pantalla
|
Text *text2; // Objeto de texto para poder escribir textos en pantalla
|
||||||
@@ -79,7 +96,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, param_t *param, section_t *section, JA_Music_t *music);
|
Title(Screen *screen, Asset *asset, Input *input, options_t *options, Lang *lang, param_t *param, section_t *section, JA_Music_t *music);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Title();
|
~Title();
|
||||||
|
|||||||
Reference in New Issue
Block a user