81 lines
3.2 KiB
C++
81 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include <SDL2/SDL_render.h> // Para SDL_Texture
|
|
#include <SDL2/SDL_stdinc.h> // Para Uint32
|
|
#include <memory> // Para unique_ptr
|
|
#include "param.h"
|
|
class BalloonManager;
|
|
class TiledBG;
|
|
class Player;
|
|
|
|
class Credits
|
|
{
|
|
private:
|
|
// Objetos
|
|
std::unique_ptr<BalloonManager> balloon_manager_; // Objeto para gestionar los globos
|
|
SDL_Texture *text_texture_; // Textura con el texto
|
|
std::unique_ptr<TiledBG> tiled_bg_; // Objeto para dibujar el mosaico animado de fondo
|
|
std::vector<std::shared_ptr<Player>> players_; // Vector con los jugadores
|
|
|
|
// Variables
|
|
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
|
Uint32 counter_ = 0; // Contador para la lógica de la clase
|
|
int black_bars_size_ = 28; // Tamaño de las barras negras
|
|
int mini_logo_final_pos_ = 0; // Ubicación donde se detiene el minilogo
|
|
bool fading = false; // Indica si se está realizando el fade final
|
|
|
|
// Rectangulos
|
|
SDL_Rect credits_rect_src_ = param.game.game_area.rect; // Rectangulo con el texto de los créditos (origen)
|
|
SDL_Rect credits_rect_dst_ = param.game.game_area.rect; // Rectangulo con el texto de los créditos (destino)
|
|
SDL_Rect mini_logo_rect_src_ = param.game.game_area.rect; // Rectangulo con el mini logo de JailGames y el texto de copyright (origen)
|
|
SDL_Rect mini_logo_rect_dst_ = param.game.game_area.rect; // Rectangulo con el mini logo de JailGames y el texto de copyright (destino)
|
|
SDL_Rect play_area_ = {
|
|
param.game.game_area.rect.x,
|
|
param.game.game_area.rect.y + black_bars_size_,
|
|
param.game.game_area.rect.w,
|
|
param.game.game_area.rect.h - black_bars_size_}; // Area visible para los creditos
|
|
SDL_Rect top_black_rect_ = {play_area_.x, 0, play_area_.w, black_bars_size_}; // Rectangulo negro superior
|
|
SDL_Rect bottom_black_rect_ = {play_area_.x, param.game.game_area.rect.h - black_bars_size_, play_area_.w, black_bars_size_}; // Rectangulo negro inferior
|
|
SDL_Rect left_black_rect_ = {play_area_.x, param.game.game_area.center_y - 1, 0, 2}; // Rectangulo negro situado a la izquierda
|
|
SDL_Rect right_black_rect_ = {play_area_.x + play_area_.w, param.game.game_area.center_y - 1, 0, 2}; // Rectangulo negro situado a la derecha
|
|
|
|
// Actualiza las variables
|
|
void update();
|
|
|
|
// Dibuja en pantalla
|
|
void render();
|
|
|
|
// Comprueba el manejador de eventos
|
|
void checkEvents();
|
|
|
|
// Comprueba las entradas
|
|
void checkInput();
|
|
|
|
// Crea la textura con el texto
|
|
void fillTextTexture();
|
|
|
|
// Actualiza el destino de los rectangulos de las texturas
|
|
void updateTextureDstRects();
|
|
|
|
// Tira globos al escenario
|
|
void throwBalloons();
|
|
|
|
// Inicializa los jugadores
|
|
void initPlayers();
|
|
|
|
// Actualiza los rectangulos negros
|
|
void updateBlackRects();
|
|
|
|
// Actualiza el estado de fade
|
|
void updateFinalFade();
|
|
|
|
public:
|
|
// Constructor
|
|
Credits();
|
|
|
|
// Destructor
|
|
~Credits();
|
|
|
|
// Bucle principal
|
|
void run();
|
|
}; |