Files
jdd_opendingux/source/ending.h

96 lines
2.4 KiB
C++

#pragma once
#include <SDL2/SDL.h>
#include "common/animatedsprite.h"
#include "common/asset.h"
#include "common/jail_audio.h"
#include "common/resource.h"
#include "common/screen.h"
#include "common/sprite.h"
#include "common/text.h"
#include "common/texture.h"
#include "common/utils.h"
#include "const.h"
#include <vector>
#include <string>
#ifndef ENDING_H
#define ENDING_H
class Ending
{
private:
// Estructuras
struct endingTexture_t
{
Texture *texture;
Sprite *sprite;
Texture *coverTexture;
Sprite *coverSprite;
};
struct textAndPos_t
{
std::string caption;
int pos;
};
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
Screen *screen; // Objeto encargado de dibujar en pantalla
Resource *resource; // Objeto con los recursos
Asset *asset; // Objeto con los ficheros de recursos
options_t *options; // Puntero a las opciones del juego
SDL_Event *eventHandler; // Manejador de eventos
Text *text; // Objeto para escribir texto en pantalla
SDL_Texture *canvasTexture; // Textura para dibujar el texto y los dibujos
SDL_Texture *coverTexture; // Textura para cubrir el texto
Texture *texture; // Textura con los graficos
Sprite *sprite; // Sprite para dibujar las imagenes
// Variables
int counter; // Contador
bool counterEnabled; // Indica si esta activo el contador
int subCounter; // Contador secundario
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
std::vector<textAndPos_t> texts; // Vector con los textos
std::vector<endingTexture_t> spriteTexts;
int scene; // Escena actual
std::vector<int> sceneLenght; // Duracion de cada escena
bool pause;
// Actualiza el objeto
void update();
// Dibuja el final en pantalla
void render();
// Comprueba el manejador de eventos
void checkEventHandler();
// Inicializa los textos
void iniTexts();
// Rellena la textura segun la escena
void fillTexture();
// Actualiza el contador
void updateCounter();
// Dibuja la coverTexture
void renderCoverTexture();
public:
// Constructor
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
// Destructor
~Ending();
// Bucle principal
section_t run();
};
#endif