update 19-02-21
This commit is contained in:
165
source/game.h
Normal file
165
source/game.h
Normal file
@@ -0,0 +1,165 @@
|
||||
#pragma once
|
||||
#include "ifdefs.h"
|
||||
#include "sprite.h"
|
||||
#include "movingsprite.h"
|
||||
#include "smartsprite.h"
|
||||
#include "player.h"
|
||||
#include "text.h"
|
||||
#include "text2.h"
|
||||
#include "menu.h"
|
||||
#include "const.h"
|
||||
#include "jail_audio.h"
|
||||
#include "utils.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
// GameDirector
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
Game();
|
||||
|
||||
// Destructor
|
||||
~Game();
|
||||
|
||||
// Iniciador
|
||||
void init();
|
||||
|
||||
// Arranca SDL y crea la ventana
|
||||
bool initSDL();
|
||||
|
||||
// Crea el indice de ficheros
|
||||
void setFileList();
|
||||
|
||||
// Comprueba que todos los ficheros existen
|
||||
bool checkFileList();
|
||||
|
||||
// Carga un archivo de imagen en una textura
|
||||
bool loadTextureFromFile(LTexture *texture, std::string path, SDL_Renderer *renderer);
|
||||
|
||||
// Carga los recursos necesarios
|
||||
bool loadMedia(Uint8 section);
|
||||
|
||||
// Descrga los recursos necesarios
|
||||
bool unLoadMedia(Uint8 section);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPath(std::string path);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint8 getGameSection();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setGameSection(Uint8 section);
|
||||
|
||||
// Cambia el valor de la variable de modo de pantalla completa
|
||||
void changeFullScreenMode();
|
||||
|
||||
// Bucle para el logo del juego
|
||||
void runLogo();
|
||||
|
||||
// Bucle para la intro del juego
|
||||
void runIntro();
|
||||
|
||||
// Bucle para el titulo del juego
|
||||
void runTitle();
|
||||
|
||||
// Bucle para el juego
|
||||
void runGame();
|
||||
|
||||
private:
|
||||
SDL_Window *mWindow; // La ventana de la aplicación
|
||||
SDL_Renderer *mRenderer; // El renderizador donde se dibuja todo
|
||||
SDL_Event *mEventHandler; // Manejador de eventos
|
||||
|
||||
SDL_Texture *mBackbuffer; // Texturas
|
||||
|
||||
SDL_Joystick *mGameController; // Manejador para el mando 1
|
||||
bool mGameControllerFound; // Indica si se ha encontrado algun mando conectado
|
||||
SDL_Haptic *mControllerHaptic; // Manejador para la vibración del mando
|
||||
|
||||
Uint32 mScoreData[TOTAL_SCORE_DATA]; // Datos del fichero de puntuación
|
||||
|
||||
Player *mPlayer; // El jugador
|
||||
|
||||
double mSen[360]; // Vector con los valores del seno para 360 grados
|
||||
|
||||
struct _text // Objetos de texto
|
||||
{
|
||||
Text *white;
|
||||
};
|
||||
|
||||
_text mText; // Variable con los objetos texto
|
||||
|
||||
struct _menu // Objetos menu
|
||||
{
|
||||
Menu *title; // Menu de la pantalla de título
|
||||
};
|
||||
|
||||
_menu mMenu; // Variable con los objetos menu
|
||||
|
||||
struct _options // Variables relacionadas con las opciones del juego
|
||||
{
|
||||
Uint32 fullScreenMode; // Guarda el valor elegido para el modo de pantalla completa
|
||||
Uint32 fullScreenModePrevious; // Guarda el valor previo del modo de pantalla completa
|
||||
Uint8 windowSize; // Guarda el valor elegido para el tamaño de la ventana
|
||||
Uint8 windowSizePrevious; // Guarda el valor previo del tamaño de la ventana
|
||||
};
|
||||
|
||||
struct _game // Variables para el control del juego
|
||||
{
|
||||
Uint32 score; // Puntuación actual
|
||||
Uint8 section; // Indicador para el bucle principal
|
||||
bool paused; // Idica si el juego está en pausa
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del juego
|
||||
Uint8 ticksSpeed; // Velocidad a la que se repite el bucle de juego
|
||||
Uint32 counter; // Contador para el juego
|
||||
_options options; // Contiene todas las opciones del juego
|
||||
std::string path; // Path donde está el ejecutable del juego
|
||||
};
|
||||
|
||||
_game mGame;
|
||||
|
||||
// Recursos
|
||||
struct _resourceFile
|
||||
{
|
||||
std::string file;
|
||||
bool loaded;
|
||||
};
|
||||
|
||||
struct _resourceSound
|
||||
{
|
||||
std::string file;
|
||||
bool loaded;
|
||||
JA_Sound sound;
|
||||
};
|
||||
|
||||
struct _resourceMusic
|
||||
{
|
||||
std::string file;
|
||||
bool loaded;
|
||||
JA_Music music;
|
||||
};
|
||||
|
||||
struct _resourceTexture
|
||||
{
|
||||
std::string file;
|
||||
bool loaded;
|
||||
LTexture *texture;
|
||||
};
|
||||
|
||||
struct _resource
|
||||
{
|
||||
_resourceFile file[TOTAL_FILE];
|
||||
_resourceSound sound[TOTAL_SOUND];
|
||||
_resourceMusic music[TOTAL_MUSIC];
|
||||
_resourceTexture texture[TOTAL_TEXTURE];
|
||||
};
|
||||
|
||||
_resource mResource;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user