Ya va pasando del titulo a las instrucciones, a la demo, etc..
This commit is contained in:
Binary file not shown.
@@ -3,206 +3,221 @@
|
|||||||
const Uint8 SELF = 0;
|
const Uint8 SELF = 0;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *mAsset, Lang *lang)
|
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
mRenderer = renderer;
|
this->renderer = renderer;
|
||||||
mScreen = screen;
|
this->screen = screen;
|
||||||
this->mAsset = mAsset;
|
this->asset = asset;
|
||||||
mLang = lang;
|
this->lang = lang;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
mEventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
mItemTexture = new LTexture(mRenderer, mAsset->get("items.png"));
|
itemTexture = new LTexture(renderer, asset->get("items.png"));
|
||||||
mSprite = new Sprite(0, 0, GAME_WIDTH, GAME_HEIGHT, mItemTexture, mRenderer);
|
sprite = new Sprite(0, 0, GAME_WIDTH, GAME_HEIGHT, itemTexture, renderer);
|
||||||
mText = new Text(mAsset->get("smb2.png"), mAsset->get("smb2.txt"), mRenderer);
|
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||||
|
|
||||||
// Crea un backbuffer para el renderizador
|
// Crea un backbuffer para el renderizador
|
||||||
mBackbuffer = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH, GAME_HEIGHT);
|
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH, GAME_HEIGHT);
|
||||||
if (mBackbuffer == nullptr)
|
if (backbuffer == nullptr)
|
||||||
{
|
{
|
||||||
printf("Backbuffer could not be created!\nSDL Error: %s\n", SDL_GetError());
|
printf("Backbuffer could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inicializa variables
|
||||||
|
section.name = SELF;
|
||||||
|
ticks = 0;
|
||||||
|
ticksSpeed = 15;
|
||||||
|
manualQuit = false;
|
||||||
|
counter = 0;
|
||||||
|
counterEnd = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Instructions::~Instructions()
|
Instructions::~Instructions()
|
||||||
{
|
{
|
||||||
mItemTexture->unload();
|
itemTexture->unload();
|
||||||
delete mItemTexture;
|
delete itemTexture;
|
||||||
|
|
||||||
delete mSprite;
|
delete sprite;
|
||||||
delete mEventHandler;
|
delete eventHandler;
|
||||||
delete mText;
|
delete text;
|
||||||
|
|
||||||
SDL_DestroyTexture(mBackbuffer);
|
SDL_DestroyTexture(backbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa las variables necesarias para la sección 'Instructions'
|
// Actualiza las variables
|
||||||
void Instructions::init()
|
void Instructions::update()
|
||||||
{
|
{
|
||||||
// Inicializa variables
|
// Comprueba los eventos
|
||||||
mSection.name = SELF;
|
checkEventHandler();
|
||||||
mTicks = 0;
|
|
||||||
mTicksSpeed = 15;
|
// Actualiza las variables
|
||||||
mManualQuit = false;
|
if (SDL_GetTicks() - ticks > ticksSpeed)
|
||||||
mCounter = 0;
|
{
|
||||||
|
// Actualiza el contador de ticks
|
||||||
|
ticks = SDL_GetTicks();
|
||||||
|
|
||||||
|
if (mode == m_auto)
|
||||||
|
{ // Modo automático
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
if (counter == counterEnd)
|
||||||
|
{
|
||||||
|
section.name = PROG_SECTION_TITLE;
|
||||||
|
section.subsection = TITLE_SECTION_1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Modo manual
|
||||||
|
++counter %= 60000;
|
||||||
|
|
||||||
|
if (manualQuit)
|
||||||
|
{
|
||||||
|
section.name = PROG_SECTION_TITLE;
|
||||||
|
section.subsection = TITLE_SECTION_3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pinta en pantalla
|
||||||
|
void Instructions::render()
|
||||||
|
{
|
||||||
|
// Pinta en pantalla
|
||||||
|
SDL_Rect window = {0, 0, GAME_WIDTH, GAME_HEIGHT};
|
||||||
|
SDL_Rect srcRect = {0, 0, 16, 16};
|
||||||
|
|
||||||
|
const color_t orangeColor = {0xFF, 0x7A, 0x00};
|
||||||
|
|
||||||
|
const SDL_Rect destRect1 = {60, 88 + (16 * 0), 16, 16}; // Disquito
|
||||||
|
const SDL_Rect destRect2 = {60, 88 + (16 * 1), 16, 16}; // Gavineixon
|
||||||
|
const SDL_Rect destRect3 = {60, 88 + (16 * 2), 16, 16}; // Pacmar
|
||||||
|
const SDL_Rect destRect4 = {60, 88 + (16 * 3), 16, 16}; // Time Stopper
|
||||||
|
const SDL_Rect destRect5 = {60, 88 + (16 * 4), 16, 16}; // Coffee
|
||||||
|
|
||||||
|
// Pinta en el backbuffer el texto y los sprites
|
||||||
|
SDL_SetRenderTarget(renderer, backbuffer);
|
||||||
|
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
// Escribe el texto
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, lang->getText(11), 1, orangeColor, 1, shdwTxtColor);
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 24, lang->getText(12), 1, noColor, 1, shdwTxtColor);
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 34, lang->getText(13), 1, noColor, 1, shdwTxtColor);
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 48, lang->getText(14), 1, noColor, 1, shdwTxtColor);
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 58, lang->getText(15), 1, noColor, 1, shdwTxtColor);
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 75, lang->getText(16), 1, orangeColor, 1, shdwTxtColor);
|
||||||
|
|
||||||
|
text->writeShadowed(84, 92, lang->getText(17), shdwTxtColor);
|
||||||
|
text->writeShadowed(84, 108, lang->getText(18), shdwTxtColor);
|
||||||
|
text->writeShadowed(84, 124, lang->getText(19), shdwTxtColor);
|
||||||
|
text->writeShadowed(84, 140, lang->getText(20), shdwTxtColor);
|
||||||
|
text->writeShadowed(84, 156, lang->getText(21), shdwTxtColor);
|
||||||
|
|
||||||
|
if ((mode == m_manual) && (counter % 50 > 14))
|
||||||
|
{
|
||||||
|
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, GAME_HEIGHT - 12, lang->getText(22), 1, orangeColor, 1, shdwTxtColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disquito
|
||||||
|
sprite->setPos(destRect1);
|
||||||
|
srcRect.x = 0;
|
||||||
|
srcRect.y = 16 * (((counter + 12) / 36) % 2);
|
||||||
|
sprite->setSpriteClip(srcRect);
|
||||||
|
sprite->render();
|
||||||
|
|
||||||
|
// Gavineixon
|
||||||
|
sprite->setPos(destRect2);
|
||||||
|
srcRect.x += srcRect.w;
|
||||||
|
srcRect.y = 16 * (((counter + 9) / 36) % 2);
|
||||||
|
sprite->setSpriteClip(srcRect);
|
||||||
|
sprite->render();
|
||||||
|
|
||||||
|
// Pacmar
|
||||||
|
sprite->setPos(destRect3);
|
||||||
|
srcRect.x += srcRect.w;
|
||||||
|
srcRect.y = 16 * (((counter + 6) / 36) % 2);
|
||||||
|
sprite->setSpriteClip(srcRect);
|
||||||
|
sprite->render();
|
||||||
|
|
||||||
|
// Time Stopper
|
||||||
|
sprite->setPos(destRect4);
|
||||||
|
srcRect.x += srcRect.w;
|
||||||
|
srcRect.y = 16 * (((counter + 3) / 36) % 2);
|
||||||
|
sprite->setSpriteClip(srcRect);
|
||||||
|
sprite->render();
|
||||||
|
|
||||||
|
// Coffee
|
||||||
|
sprite->setPos(destRect5);
|
||||||
|
srcRect.x += (srcRect.w * 2); // Se salta el icono del TNT
|
||||||
|
srcRect.y = 16 * (((counter + 0) / 36) % 2);
|
||||||
|
sprite->setSpriteClip(srcRect);
|
||||||
|
sprite->render();
|
||||||
|
|
||||||
|
// Cambia el destino de renderizado
|
||||||
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
|
||||||
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
|
screen->start();
|
||||||
|
|
||||||
|
// Limpia la pantalla
|
||||||
|
screen->clean(bgColor);
|
||||||
|
|
||||||
|
// Establece la ventana del backbuffer
|
||||||
|
if (mode == m_auto)
|
||||||
|
{
|
||||||
|
window.y = std::max(8, GAME_HEIGHT - counter + 100);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copia el backbuffer al renderizador
|
||||||
|
SDL_RenderCopy(renderer, backbuffer, nullptr, &window);
|
||||||
|
|
||||||
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
screen->blit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba los eventos
|
||||||
|
void Instructions::checkEventHandler()
|
||||||
|
{
|
||||||
|
// Comprueba los eventos que hay en la cola
|
||||||
|
while (SDL_PollEvent(eventHandler) != 0)
|
||||||
|
{
|
||||||
|
// Evento de salida de la aplicación
|
||||||
|
if (eventHandler->type == SDL_QUIT)
|
||||||
|
{
|
||||||
|
section.name = PROG_SECTION_QUIT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP))
|
||||||
|
{
|
||||||
|
if (mode == m_auto)
|
||||||
|
{
|
||||||
|
JA_StopMusic();
|
||||||
|
section.name = PROG_SECTION_TITLE;
|
||||||
|
section.subsection = TITLE_SECTION_1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
manualQuit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle para la pantalla de instrucciones
|
// Bucle para la pantalla de instrucciones
|
||||||
void Instructions::run(Uint8 mode)
|
void Instructions::run(mode_e mode)
|
||||||
{
|
{
|
||||||
init();
|
this->mode = mode;
|
||||||
|
|
||||||
while (mSection.name == SELF)
|
while (section.name == SELF)
|
||||||
{
|
{
|
||||||
// Comprueba los eventos que hay en la cola
|
update();
|
||||||
while (SDL_PollEvent(mEventHandler) != 0)
|
render();
|
||||||
{
|
|
||||||
// Evento de salida de la aplicación
|
|
||||||
if (mEventHandler->type == SDL_QUIT)
|
|
||||||
{
|
|
||||||
mSection.name = PROG_SECTION_QUIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mEventHandler->type == SDL_KEYDOWN) || (mEventHandler->type == SDL_JOYBUTTONDOWN))
|
|
||||||
{
|
|
||||||
if (mode == INSTRUCTIONS_MODE_AUTO)
|
|
||||||
{
|
|
||||||
JA_StopMusic();
|
|
||||||
mSection.name = PROG_SECTION_TITLE;
|
|
||||||
mSection.subsection = TITLE_SECTION_1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mManualQuit = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza las variables
|
|
||||||
if (SDL_GetTicks() - mTicks > mTicksSpeed)
|
|
||||||
{
|
|
||||||
// Actualiza el contador de ticks
|
|
||||||
mTicks = SDL_GetTicks();
|
|
||||||
|
|
||||||
if (mode == INSTRUCTIONS_MODE_AUTO)
|
|
||||||
{ // Modo automático
|
|
||||||
mCounter++;
|
|
||||||
|
|
||||||
if (mCounter == INSTRUCTIONS_COUNTER)
|
|
||||||
{
|
|
||||||
mSection.name = PROG_SECTION_TITLE;
|
|
||||||
mSection.subsection = TITLE_SECTION_1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Modo manual
|
|
||||||
++mCounter %= 60000;
|
|
||||||
|
|
||||||
if (mManualQuit)
|
|
||||||
{
|
|
||||||
mSection.name = PROG_SECTION_TITLE;
|
|
||||||
mSection.subsection = TITLE_SECTION_3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pinta en pantalla
|
|
||||||
SDL_Rect window = {0, 0, GAME_WIDTH, GAME_HEIGHT};
|
|
||||||
SDL_Rect srcRect = {0, 0, 16, 16};
|
|
||||||
|
|
||||||
const color_t orangeColor = {0xFF, 0x7A, 0x00};
|
|
||||||
|
|
||||||
const SDL_Rect destRect1 = {60, 88 + (16 * 0), 16, 16}; // Disquito
|
|
||||||
const SDL_Rect destRect2 = {60, 88 + (16 * 1), 16, 16}; // Gavineixon
|
|
||||||
const SDL_Rect destRect3 = {60, 88 + (16 * 2), 16, 16}; // Pacmar
|
|
||||||
const SDL_Rect destRect4 = {60, 88 + (16 * 3), 16, 16}; // Time Stopper
|
|
||||||
const SDL_Rect destRect5 = {60, 88 + (16 * 4), 16, 16}; // Coffee
|
|
||||||
|
|
||||||
// Pinta en el backbuffer el texto y los sprites
|
|
||||||
SDL_SetRenderTarget(mRenderer, mBackbuffer);
|
|
||||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
|
||||||
SDL_RenderClear(mRenderer);
|
|
||||||
|
|
||||||
// Escribe el texto
|
|
||||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, mLang->getText(11), 1, orangeColor, 1, shdwTxtColor);
|
|
||||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 24, mLang->getText(12), 1, noColor, 1, shdwTxtColor);
|
|
||||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 34, mLang->getText(13), 1, noColor, 1, shdwTxtColor);
|
|
||||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 48, mLang->getText(14), 1, noColor, 1, shdwTxtColor);
|
|
||||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 58, mLang->getText(15), 1, noColor, 1, shdwTxtColor);
|
|
||||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 75, mLang->getText(16), 1, orangeColor, 1, shdwTxtColor);
|
|
||||||
|
|
||||||
mText->writeShadowed(84, 92, mLang->getText(17), shdwTxtColor);
|
|
||||||
mText->writeShadowed(84, 108, mLang->getText(18), shdwTxtColor);
|
|
||||||
mText->writeShadowed(84, 124, mLang->getText(19), shdwTxtColor);
|
|
||||||
mText->writeShadowed(84, 140, mLang->getText(20), shdwTxtColor);
|
|
||||||
mText->writeShadowed(84, 156, mLang->getText(21), shdwTxtColor);
|
|
||||||
|
|
||||||
if ((mode == INSTRUCTIONS_MODE_MANUAL) && (mCounter % 50 > 14))
|
|
||||||
{
|
|
||||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, GAME_HEIGHT - 12, mLang->getText(22), 1, orangeColor, 1, shdwTxtColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disquito
|
|
||||||
mSprite->setPos(destRect1);
|
|
||||||
srcRect.x = 0;
|
|
||||||
srcRect.y = 16 * (((mCounter + 12) / 36) % 2);
|
|
||||||
mSprite->setSpriteClip(srcRect);
|
|
||||||
mSprite->render();
|
|
||||||
|
|
||||||
// Gavineixon
|
|
||||||
mSprite->setPos(destRect2);
|
|
||||||
srcRect.x += srcRect.w;
|
|
||||||
srcRect.y = 16 * (((mCounter + 9) / 36) % 2);
|
|
||||||
mSprite->setSpriteClip(srcRect);
|
|
||||||
mSprite->render();
|
|
||||||
|
|
||||||
// Pacmar
|
|
||||||
mSprite->setPos(destRect3);
|
|
||||||
srcRect.x += srcRect.w;
|
|
||||||
srcRect.y = 16 * (((mCounter + 6) / 36) % 2);
|
|
||||||
mSprite->setSpriteClip(srcRect);
|
|
||||||
mSprite->render();
|
|
||||||
|
|
||||||
// Time Stopper
|
|
||||||
mSprite->setPos(destRect4);
|
|
||||||
srcRect.x += srcRect.w;
|
|
||||||
srcRect.y = 16 * (((mCounter + 3) / 36) % 2);
|
|
||||||
mSprite->setSpriteClip(srcRect);
|
|
||||||
mSprite->render();
|
|
||||||
|
|
||||||
// Coffee
|
|
||||||
mSprite->setPos(destRect5);
|
|
||||||
srcRect.x += (srcRect.w * 2); // Se salta el icono del TNT
|
|
||||||
srcRect.y = 16 * (((mCounter + 0) / 36) % 2);
|
|
||||||
mSprite->setSpriteClip(srcRect);
|
|
||||||
mSprite->render();
|
|
||||||
|
|
||||||
// Cambia el destino de renderizado
|
|
||||||
SDL_SetRenderTarget(mRenderer, nullptr);
|
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
|
||||||
mScreen->start();
|
|
||||||
|
|
||||||
// Limpia la pantalla
|
|
||||||
mScreen->clean(bgColor);
|
|
||||||
|
|
||||||
// Establece la ventana del backbuffer
|
|
||||||
if (mode == INSTRUCTIONS_MODE_AUTO)
|
|
||||||
{
|
|
||||||
window.y = std::max(8, GAME_HEIGHT - mCounter + 100);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
window.y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copia el backbuffer al renderizador
|
|
||||||
SDL_RenderCopy(mRenderer, mBackbuffer, nullptr, &window);
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
|
||||||
mScreen->blit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,31 +12,35 @@
|
|||||||
#ifndef INSTRUCTIONS_H
|
#ifndef INSTRUCTIONS_H
|
||||||
#define INSTRUCTIONS_H
|
#define INSTRUCTIONS_H
|
||||||
|
|
||||||
// Contadores
|
enum mode_e
|
||||||
#define INSTRUCTIONS_COUNTER 600
|
{
|
||||||
|
m_manual,
|
||||||
// Modo para las instrucciones
|
m_auto
|
||||||
#define INSTRUCTIONS_MODE_MANUAL 0
|
};
|
||||||
#define INSTRUCTIONS_MODE_AUTO 1
|
|
||||||
|
|
||||||
// Clase Instructions
|
// Clase Instructions
|
||||||
class Instructions
|
class Instructions
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
// Objetos
|
||||||
Screen *mScreen; // Objeto encargado de dibujar en pantalla
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
LTexture *mItemTexture; // Textura con los graficos
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
SDL_Event *mEventHandler; // Manejador de eventos
|
LTexture *itemTexture; // Textura con los graficos
|
||||||
SDL_Texture *mBackbuffer; // Textura para usar como backbuffer
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *mSprite; // Sprite con la textura de las instrucciones
|
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
||||||
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
|
Sprite *sprite; // Sprite con la textura de las instrucciones
|
||||||
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
Text *mText; // Objeto para escribir texto
|
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||||
Uint16 mCounter; // Contador
|
Text *text; // Objeto para escribir texto
|
||||||
section_t mSection; // Estado del bucle principal para saber si continua o se sale
|
|
||||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
// Variables
|
||||||
Uint32 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint16 counter; // Contador
|
||||||
bool mManualQuit; // Indica si se quiere salir del modo manual
|
Uint16 counterEnd; // Valor final para el contador
|
||||||
|
section_t section; // Estado del bucle principal para saber si continua o se sale
|
||||||
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
|
bool manualQuit; // Indica si se quiere salir del modo manual
|
||||||
|
mode_e mode; // Modo en el que se van a ejecutar las instrucciones
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
@@ -44,8 +48,8 @@ private:
|
|||||||
// Pinta en pantalla
|
// Pinta en pantalla
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
// Inicializa las variables
|
// Comprueba los eventos
|
||||||
void init();
|
void checkEventHandler();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -55,7 +59,7 @@ public:
|
|||||||
~Instructions();
|
~Instructions();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
void run(Uint8 mode);
|
void run(mode_e mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
383
source/title.cpp
383
source/title.cpp
@@ -50,7 +50,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
|||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
fade->init(0x17, 0x17, 0x26);
|
fade->init(0x17, 0x17, 0x26);
|
||||||
demo = false;
|
demo = true;
|
||||||
|
|
||||||
// Pone valores por defecto a las opciones de control
|
// Pone valores por defecto a las opciones de control
|
||||||
options->input.clear();
|
options->input.clear();
|
||||||
@@ -235,7 +235,7 @@ void Title::update()
|
|||||||
dustBitmapL->update();
|
dustBitmapL->update();
|
||||||
|
|
||||||
step++;
|
step++;
|
||||||
|
|
||||||
if (step == 33)
|
if (step == 33)
|
||||||
{
|
{
|
||||||
section.subsection = TITLE_SECTION_3;
|
section.subsection = TITLE_SECTION_3;
|
||||||
@@ -246,190 +246,214 @@ void Title::update()
|
|||||||
// Sección 3 - La pantalla de titulo con el menú y la música
|
// Sección 3 - La pantalla de titulo con el menú y la música
|
||||||
case TITLE_SECTION_3:
|
case TITLE_SECTION_3:
|
||||||
{
|
{
|
||||||
// Reproduce la música
|
if (counter > 0)
|
||||||
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
{ // Reproduce la música
|
||||||
{
|
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
|
||||||
JA_PlayMusic(titleMusic);
|
|
||||||
}
|
|
||||||
|
|
||||||
dustBitmapR->update();
|
|
||||||
dustBitmapL->update();
|
|
||||||
|
|
||||||
// Actualiza la lógica del titulo
|
|
||||||
fade->update();
|
|
||||||
|
|
||||||
if (fade->hasEnded())
|
|
||||||
{
|
|
||||||
switch (postFade)
|
|
||||||
{
|
{
|
||||||
case 0: // 1 PLAYER
|
JA_PlayMusic(titleMusic);
|
||||||
section.name = PROG_SECTION_GAME;
|
}
|
||||||
section.subsection = GAME_SECTION_PLAY_1P;
|
|
||||||
JA_StopMusic();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // 2 PLAYERS
|
dustBitmapR->update();
|
||||||
section.name = PROG_SECTION_GAME;
|
dustBitmapL->update();
|
||||||
section.subsection = GAME_SECTION_PLAY_2P;
|
|
||||||
JA_StopMusic();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: // QUIT
|
// Actualiza la lógica del titulo
|
||||||
section.name = PROG_SECTION_QUIT;
|
fade->update();
|
||||||
JA_StopMusic();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: // TIME OUT
|
if (fade->hasEnded())
|
||||||
|
{
|
||||||
|
switch (postFade)
|
||||||
|
{
|
||||||
|
case 0: // 1 PLAYER
|
||||||
|
section.name = PROG_SECTION_GAME;
|
||||||
|
section.subsection = GAME_SECTION_PLAY_1P;
|
||||||
|
JA_StopMusic();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // 2 PLAYERS
|
||||||
|
section.name = PROG_SECTION_GAME;
|
||||||
|
section.subsection = GAME_SECTION_PLAY_2P;
|
||||||
|
JA_StopMusic();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // QUIT
|
||||||
|
section.name = PROG_SECTION_QUIT;
|
||||||
|
JA_StopMusic();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // TIME OUT
|
||||||
|
counter = TITLE_COUNTER;
|
||||||
|
menu.active->reset();
|
||||||
|
if (demo)
|
||||||
|
{
|
||||||
|
runDemoGame();
|
||||||
|
runInstructions(m_auto);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
section.name = PROG_SECTION_LOGO;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza el tileado de fondo
|
||||||
|
updateBG();
|
||||||
|
|
||||||
|
// Comprueba las entradas para el menu
|
||||||
|
if (menuVisible == true)
|
||||||
|
{
|
||||||
|
menu.active->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba si se ha seleccionado algún item del menú
|
||||||
|
if (menu.active->getName() == "TITLE")
|
||||||
|
{
|
||||||
|
switch (menu.active->getItemSelected())
|
||||||
|
{
|
||||||
|
case 0: // 1 PLAYER
|
||||||
|
postFade = 0;
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // 2 PLAYERS
|
||||||
|
postFade = 1;
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // OPTIONS
|
||||||
|
menu.active = menu.options;
|
||||||
|
optionsPrevious = *options;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // QUIT
|
||||||
|
postFade = 2;
|
||||||
|
fade->activateFade();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba si se ha seleccionado algún item de opciones
|
||||||
|
if (menu.active->getName() == "OPTIONS")
|
||||||
|
{
|
||||||
|
switch (menu.active->getItemSelected())
|
||||||
|
{
|
||||||
|
case 0: // Difficulty
|
||||||
|
if (options->difficulty == DIFFICULTY_EASY)
|
||||||
|
options->difficulty = DIFFICULTY_NORMAL;
|
||||||
|
else if (options->difficulty == DIFFICULTY_NORMAL)
|
||||||
|
options->difficulty = DIFFICULTY_HARD;
|
||||||
|
else
|
||||||
|
options->difficulty = DIFFICULTY_EASY;
|
||||||
|
updateMenuLabels();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1: // PLAYER 1 CONTROLS
|
||||||
|
updatePlayerInputs(0);
|
||||||
|
updateMenuLabels();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // PLAYER 2 CONTROLS
|
||||||
|
updatePlayerInputs(1);
|
||||||
|
updateMenuLabels();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5: // Language
|
||||||
|
options->language++;
|
||||||
|
if (options->language == 3)
|
||||||
|
options->language = 0;
|
||||||
|
updateMenuLabels();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6: // Display mode
|
||||||
|
switchFullScreenModeVar();
|
||||||
|
if (options->fullScreenMode != 0)
|
||||||
|
{
|
||||||
|
menu.options->setSelectable(8, false);
|
||||||
|
menu.options->setGreyed(8, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.options->setSelectable(8, true);
|
||||||
|
menu.options->setGreyed(8, false);
|
||||||
|
}
|
||||||
|
updateMenuLabels();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8: // Windows size
|
||||||
|
options->windowSize++;
|
||||||
|
if (options->windowSize == 5)
|
||||||
|
options->windowSize = 1;
|
||||||
|
updateMenuLabels();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 9: // FILTER
|
||||||
|
if (options->filter == FILTER_LINEAL)
|
||||||
|
options->filter = FILTER_NEAREST;
|
||||||
|
else
|
||||||
|
options->filter = FILTER_LINEAL;
|
||||||
|
updateMenuLabels();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10: // VSYNC
|
||||||
|
if (options->vSync)
|
||||||
|
options->vSync = false;
|
||||||
|
else
|
||||||
|
options->vSync = true;
|
||||||
|
updateMenuLabels();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 11: // HOW TO PLAY
|
||||||
|
runInstructions(m_manual);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 12: // ACCEPT
|
||||||
|
applyOptions();
|
||||||
|
menu.active->reset();
|
||||||
|
menu.active = menu.title;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 13: // CANCEL
|
||||||
|
options = &optionsPrevious;
|
||||||
|
updateMenuLabels();
|
||||||
|
menu.active->reset();
|
||||||
|
menu.active = menu.title;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu.active->getName() == "TITLE")
|
||||||
|
{
|
||||||
|
counter--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (counter == 0)
|
||||||
|
{
|
||||||
|
if (demo)
|
||||||
|
{
|
||||||
|
runDemoGame();
|
||||||
|
runInstructions(m_auto);
|
||||||
|
demo = false;
|
||||||
counter = TITLE_COUNTER;
|
counter = TITLE_COUNTER;
|
||||||
menu.active->reset();
|
|
||||||
if (demo)
|
|
||||||
{
|
|
||||||
runDemoGame();
|
|
||||||
runInstructions(INSTRUCTIONS_MODE_AUTO);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
section.name = PROG_SECTION_LOGO;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
// Actualiza el tileado de fondo
|
|
||||||
updateBG();
|
|
||||||
|
|
||||||
// Comprueba las entradas para el menu
|
|
||||||
if (menuVisible == true)
|
|
||||||
{
|
|
||||||
menu.active->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si se ha seleccionado algún item del menú
|
|
||||||
if (menu.active->getName() == "TITLE")
|
|
||||||
{
|
|
||||||
switch (menu.active->getItemSelected())
|
|
||||||
{
|
{
|
||||||
case 0: // 1 PLAYER
|
section.name = PROG_SECTION_LOGO;
|
||||||
postFade = 0;
|
|
||||||
fade->activateFade();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // 2 PLAYERS
|
|
||||||
postFade = 1;
|
|
||||||
fade->activateFade();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: // OPTIONS
|
|
||||||
menu.active = menu.options;
|
|
||||||
optionsPrevious = *options;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: // QUIT
|
|
||||||
postFade = 2;
|
|
||||||
fade->activateFade();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si se ha seleccionado algún item de opciones
|
// Sección Instrucciones
|
||||||
if (menu.active->getName() == "OPTIONS")
|
if (section.subsection == TITLE_SECTION_INSTRUCTIONS)
|
||||||
{
|
{
|
||||||
switch (menu.active->getItemSelected())
|
runInstructions(m_auto);
|
||||||
{
|
counter = TITLE_COUNTER;
|
||||||
case 0: // Difficulty
|
demo = true;
|
||||||
if (options->difficulty == DIFFICULTY_EASY)
|
|
||||||
options->difficulty = DIFFICULTY_NORMAL;
|
|
||||||
else if (options->difficulty == DIFFICULTY_NORMAL)
|
|
||||||
options->difficulty = DIFFICULTY_HARD;
|
|
||||||
else
|
|
||||||
options->difficulty = DIFFICULTY_EASY;
|
|
||||||
updateMenuLabels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1: // PLAYER 1 CONTROLS
|
|
||||||
updatePlayerInputs(0);
|
|
||||||
updateMenuLabels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: // PLAYER 2 CONTROLS
|
|
||||||
updatePlayerInputs(1);
|
|
||||||
updateMenuLabels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5: // Language
|
|
||||||
options->language++;
|
|
||||||
if (options->language == 3)
|
|
||||||
options->language = 0;
|
|
||||||
updateMenuLabels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6: // Display mode
|
|
||||||
switchFullScreenModeVar();
|
|
||||||
if (options->fullScreenMode != 0)
|
|
||||||
{
|
|
||||||
menu.options->setSelectable(8, false);
|
|
||||||
menu.options->setGreyed(8, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
menu.options->setSelectable(8, true);
|
|
||||||
menu.options->setGreyed(8, false);
|
|
||||||
}
|
|
||||||
updateMenuLabels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8: // Windows size
|
|
||||||
options->windowSize++;
|
|
||||||
if (options->windowSize == 5)
|
|
||||||
options->windowSize = 1;
|
|
||||||
updateMenuLabels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 9: // FILTER
|
|
||||||
if (options->filter == FILTER_LINEAL)
|
|
||||||
options->filter = FILTER_NEAREST;
|
|
||||||
else
|
|
||||||
options->filter = FILTER_LINEAL;
|
|
||||||
updateMenuLabels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 10: // VSYNC
|
|
||||||
if (options->vSync)
|
|
||||||
options->vSync = false;
|
|
||||||
else
|
|
||||||
options->vSync = true;
|
|
||||||
updateMenuLabels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 11: // HOW TO PLAY
|
|
||||||
runInstructions(INSTRUCTIONS_MODE_MANUAL);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 12: // ACCEPT
|
|
||||||
applyOptions();
|
|
||||||
menu.active->reset();
|
|
||||||
menu.active = menu.title;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 13: // CANCEL
|
|
||||||
options = &optionsPrevious;
|
|
||||||
updateMenuLabels();
|
|
||||||
menu.active->reset();
|
|
||||||
menu.active = menu.title;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menu.active->getName() == "TITLE")
|
|
||||||
{
|
|
||||||
counter--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -821,20 +845,13 @@ section_t Title::run()
|
|||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
render();
|
render();
|
||||||
// Sección 3 - La pantalla de titulo con el menú y la música
|
|
||||||
|
|
||||||
// Sección Instrucciones
|
|
||||||
// if (section.subsection == TITLE_SECTION_INSTRUCTIONS)
|
|
||||||
//{
|
|
||||||
// runInstructions(INSTRUCTIONS_MODE_AUTO);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la parte donde se muestran las instrucciones
|
// Ejecuta la parte donde se muestran las instrucciones
|
||||||
void Title::runInstructions(Uint8 mode)
|
void Title::runInstructions(mode_e mode)
|
||||||
{
|
{
|
||||||
instructions = new Instructions(renderer, screen, asset, lang);
|
instructions = new Instructions(renderer, screen, asset, lang);
|
||||||
instructions->run(mode);
|
instructions->run(mode);
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ private:
|
|||||||
void applyOptions();
|
void applyOptions();
|
||||||
|
|
||||||
// Ejecuta la parte donde se muestran las instrucciones
|
// Ejecuta la parte donde se muestran las instrucciones
|
||||||
void runInstructions(Uint8 mode);
|
void runInstructions(mode_e mode);
|
||||||
|
|
||||||
// Ejecuta el juego en modo demo
|
// Ejecuta el juego en modo demo
|
||||||
void runDemoGame();
|
void runDemoGame();
|
||||||
|
|||||||
2
todo.txt
2
todo.txt
@@ -3,7 +3,7 @@ x la maquina de cafe no toca el suelo
|
|||||||
x las bolas verdes nacen naranja al explotarlas
|
x las bolas verdes nacen naranja al explotarlas
|
||||||
falta el aura de superguerrero al pillar la maquina de cafe
|
falta el aura de superguerrero al pillar la maquina de cafe
|
||||||
x la powerball deja la mascara al explotarlas
|
x la powerball deja la mascara al explotarlas
|
||||||
los menus de pausa y game over falta poner bien los textos
|
x los menus de pausa y game over falta poner bien los textos
|
||||||
x cuando continuas la partida sigues muerto
|
x cuando continuas la partida sigues muerto
|
||||||
poder elegir el personaje para jugar
|
poder elegir el personaje para jugar
|
||||||
arreglar los smart sprites de muerte y de perder el cafe
|
arreglar los smart sprites de muerte y de perder el cafe
|
||||||
|
|||||||
Reference in New Issue
Block a user