TITULO bastante avanzado, se deja para el final ya que falta ver elmodo demo y demas
This commit is contained in:
@@ -237,7 +237,6 @@ bool Director::setFileList()
|
|||||||
asset->add("data/menu/title.men", t_data);
|
asset->add("data/menu/title.men", t_data);
|
||||||
asset->add("data/menu/options.men", t_data);
|
asset->add("data/menu/options.men", t_data);
|
||||||
|
|
||||||
|
|
||||||
return asset->check();
|
return asset->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,12 +244,23 @@ bool Director::setFileList()
|
|||||||
bool Director::loadConfigFile()
|
bool Director::loadConfigFile()
|
||||||
{
|
{
|
||||||
// Pone unos valores por defecto
|
// Pone unos valores por defecto
|
||||||
|
options->input.clear();
|
||||||
|
|
||||||
|
input_t inp;
|
||||||
|
inp.id = 0;
|
||||||
|
inp.name = "KEYBOARD";
|
||||||
|
inp.deviceType = INPUT_USE_KEYBOARD;
|
||||||
|
options->input.push_back(inp);
|
||||||
|
|
||||||
|
inp.id = 0;
|
||||||
|
inp.name = "GAME CONTROLLER";
|
||||||
|
inp.deviceType = INPUT_USE_GAMECONTROLLER;
|
||||||
|
options->input.push_back(inp);
|
||||||
|
|
||||||
options->fullScreenMode = 0;
|
options->fullScreenMode = 0;
|
||||||
options->windowSize = 3;
|
options->windowSize = 3;
|
||||||
options->language = ba_BA;
|
options->language = ba_BA;
|
||||||
options->difficulty = DIFFICULTY_NORMAL;
|
options->difficulty = DIFFICULTY_NORMAL;
|
||||||
options->input[0].deviceType = INPUT_USE_KEYBOARD;
|
|
||||||
options->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
|
||||||
options->filter = FILTER_NEAREST;
|
options->filter = FILTER_NEAREST;
|
||||||
options->vSync = true;
|
options->vSync = true;
|
||||||
options->screenWidth = GAME_WIDTH;
|
options->screenWidth = GAME_WIDTH;
|
||||||
@@ -283,8 +293,8 @@ bool Director::loadConfigFile()
|
|||||||
SDL_RWwrite(file, &options->windowSize, sizeof(options->windowSize), 1);
|
SDL_RWwrite(file, &options->windowSize, sizeof(options->windowSize), 1);
|
||||||
SDL_RWwrite(file, &options->language, sizeof(options->language), 1);
|
SDL_RWwrite(file, &options->language, sizeof(options->language), 1);
|
||||||
SDL_RWwrite(file, &options->difficulty, sizeof(options->difficulty), 1);
|
SDL_RWwrite(file, &options->difficulty, sizeof(options->difficulty), 1);
|
||||||
SDL_RWwrite(file, &options->input[0].deviceType, sizeof(options->input[0].deviceType), 1);
|
SDL_RWwrite(file, &options->input.at(0).deviceType, sizeof(options->input.at(0).deviceType), 1);
|
||||||
SDL_RWwrite(file, &options->input[1].deviceType, sizeof(options->input[1].deviceType), 1);
|
SDL_RWwrite(file, &options->input.at(1).deviceType, sizeof(options->input.at(1).deviceType), 1);
|
||||||
SDL_RWwrite(file, &options->filter, sizeof(options->filter), 1);
|
SDL_RWwrite(file, &options->filter, sizeof(options->filter), 1);
|
||||||
SDL_RWwrite(file, &options->vSync, sizeof(options->vSync), 1);
|
SDL_RWwrite(file, &options->vSync, sizeof(options->vSync), 1);
|
||||||
SDL_RWwrite(file, &options->screenWidth, sizeof(options->screenWidth), 1);
|
SDL_RWwrite(file, &options->screenWidth, sizeof(options->screenWidth), 1);
|
||||||
@@ -310,8 +320,8 @@ bool Director::loadConfigFile()
|
|||||||
SDL_RWread(file, &options->windowSize, sizeof(options->windowSize), 1);
|
SDL_RWread(file, &options->windowSize, sizeof(options->windowSize), 1);
|
||||||
SDL_RWread(file, &options->language, sizeof(options->language), 1);
|
SDL_RWread(file, &options->language, sizeof(options->language), 1);
|
||||||
SDL_RWread(file, &options->difficulty, sizeof(options->difficulty), 1);
|
SDL_RWread(file, &options->difficulty, sizeof(options->difficulty), 1);
|
||||||
SDL_RWread(file, &options->input[0].deviceType, sizeof(options->input[0].deviceType), 1);
|
SDL_RWread(file, &options->input.at(0).deviceType, sizeof(options->input.at(0).deviceType), 1);
|
||||||
SDL_RWread(file, &options->input[1].deviceType, sizeof(options->input[1].deviceType), 1);
|
SDL_RWread(file, &options->input.at(1).deviceType, sizeof(options->input.at(1).deviceType), 1);
|
||||||
SDL_RWread(file, &options->filter, sizeof(options->filter), 1);
|
SDL_RWread(file, &options->filter, sizeof(options->filter), 1);
|
||||||
SDL_RWread(file, &options->vSync, sizeof(options->vSync), 1);
|
SDL_RWread(file, &options->vSync, sizeof(options->vSync), 1);
|
||||||
SDL_RWread(file, &options->screenWidth, sizeof(options->screenWidth), 1);
|
SDL_RWread(file, &options->screenWidth, sizeof(options->screenWidth), 1);
|
||||||
@@ -359,8 +369,8 @@ bool Director::saveConfigFile()
|
|||||||
SDL_RWwrite(file, &options->windowSize, sizeof(options->windowSize), 1);
|
SDL_RWwrite(file, &options->windowSize, sizeof(options->windowSize), 1);
|
||||||
SDL_RWwrite(file, &options->language, sizeof(options->language), 1);
|
SDL_RWwrite(file, &options->language, sizeof(options->language), 1);
|
||||||
SDL_RWwrite(file, &options->difficulty, sizeof(options->difficulty), 1);
|
SDL_RWwrite(file, &options->difficulty, sizeof(options->difficulty), 1);
|
||||||
SDL_RWwrite(file, &options->input[0].deviceType, sizeof(options->input[0].deviceType), 1);
|
SDL_RWwrite(file, &options->input.at(0).deviceType, sizeof(options->input.at(0).deviceType), 1);
|
||||||
SDL_RWwrite(file, &options->input[1].deviceType, sizeof(options->input[1].deviceType), 1);
|
SDL_RWwrite(file, &options->input.at(1).deviceType, sizeof(options->input.at(1).deviceType), 1);
|
||||||
SDL_RWwrite(file, &options->filter, sizeof(options->filter), 1);
|
SDL_RWwrite(file, &options->filter, sizeof(options->filter), 1);
|
||||||
SDL_RWwrite(file, &options->vSync, sizeof(options->vSync), 1);
|
SDL_RWwrite(file, &options->vSync, sizeof(options->vSync), 1);
|
||||||
SDL_RWwrite(file, &options->screenWidth, sizeof(options->screenWidth), 1);
|
SDL_RWwrite(file, &options->screenWidth, sizeof(options->screenWidth), 1);
|
||||||
|
|||||||
139
source/input.cpp
139
source/input.cpp
@@ -5,38 +5,38 @@
|
|||||||
Input::Input(std::string file)
|
Input::Input(std::string file)
|
||||||
{
|
{
|
||||||
// Fichero gamecontrollerdb.txt
|
// Fichero gamecontrollerdb.txt
|
||||||
mDBpath = file;
|
dbPath = file;
|
||||||
|
|
||||||
// Inicializa las variables
|
// Inicializa las variables
|
||||||
for (int i = 0; i < 17; i++)
|
keyBindings_t kb;
|
||||||
{
|
kb.scancode = 0;
|
||||||
mKeyBindings[i].scancode = 0;
|
kb.active = false;
|
||||||
mKeyBindings[i].active = false;
|
keyBindings.resize(17, kb);
|
||||||
|
|
||||||
mGameControllerBindings[i].button = SDL_CONTROLLER_BUTTON_INVALID;
|
GameControllerBindings_t gcb;
|
||||||
mGameControllerBindings[i].active = false;
|
gcb.button = SDL_CONTROLLER_BUTTON_INVALID;
|
||||||
}
|
gcb.active = false;
|
||||||
|
gameControllerBindings.resize(17, gcb);
|
||||||
|
|
||||||
|
// Comprueba si hay un mando conectado
|
||||||
discoverGameController();
|
discoverGameController();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Input::~Input()
|
Input::~Input()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mNumGamepads; i++)
|
|
||||||
mConnectedControllers[i] = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||||
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
||||||
{
|
{
|
||||||
mKeyBindings[input].scancode = code;
|
keyBindings.at(input).scancode = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna uno de los posibles inputs a un botón del mando
|
// Asigna uno de los posibles inputs a un botón del mando
|
||||||
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
||||||
{
|
{
|
||||||
mGameControllerBindings[input].button = button;
|
gameControllerBindings.at(input).button = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
@@ -48,24 +48,14 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
if (device == INPUT_USE_ANY)
|
if (device == INPUT_USE_ANY)
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY))
|
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY)
|
||||||
{
|
{
|
||||||
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
|
const Uint8 *keyStates = SDL_GetKeyboardState(nullptr);
|
||||||
|
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (mKeystates[mKeyBindings[input].scancode] != 0)
|
if (keyStates[keyBindings.at(input).scancode] != 0)
|
||||||
successKeyboard = true;
|
|
||||||
else
|
|
||||||
successKeyboard = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (!mKeyBindings[input].active)
|
|
||||||
{
|
|
||||||
if (mKeystates[mKeyBindings[input].scancode] != 0)
|
|
||||||
{
|
|
||||||
mKeyBindings[input].active = true;
|
|
||||||
successKeyboard = true;
|
successKeyboard = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -75,9 +65,23 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mKeystates[mKeyBindings[input].scancode] == 0)
|
if (!keyBindings.at(input).active)
|
||||||
{
|
{
|
||||||
mKeyBindings[input].active = false;
|
if (keyStates[keyBindings.at(input).scancode] != 0)
|
||||||
|
{
|
||||||
|
keyBindings.at(input).active = true;
|
||||||
|
successKeyboard = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
successKeyboard = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (keyStates[keyBindings.at(input).scancode] == 0)
|
||||||
|
{
|
||||||
|
keyBindings.at(input).active = false;
|
||||||
successKeyboard = false;
|
successKeyboard = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -93,18 +97,8 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
{
|
{
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) != 0)
|
||||||
successGameController = true;
|
|
||||||
else
|
|
||||||
successGameController = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (!mGameControllerBindings[input].active)
|
|
||||||
{
|
|
||||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0)
|
|
||||||
{
|
|
||||||
mGameControllerBindings[input].active = true;
|
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -114,9 +108,23 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) == 0)
|
if (!gameControllerBindings[input].active)
|
||||||
{
|
{
|
||||||
mGameControllerBindings[input].active = false;
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) != 0)
|
||||||
|
{
|
||||||
|
gameControllerBindings[input].active = true;
|
||||||
|
successGameController = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
successGameController = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) == 0)
|
||||||
|
{
|
||||||
|
gameControllerBindings[input].active = false;
|
||||||
successGameController = false;
|
successGameController = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -136,45 +144,54 @@ bool Input::discoverGameController()
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) != 1)
|
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) != 1)
|
||||||
|
{
|
||||||
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
|
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||||
|
}
|
||||||
|
|
||||||
if (SDL_GameControllerAddMappingsFromFile(mDBpath.c_str()) < 0)
|
if (SDL_GameControllerAddMappingsFromFile(dbPath.c_str()) < 0)
|
||||||
printf("Error, could not load %s file: %s\n", mDBpath.c_str(), SDL_GetError());
|
{
|
||||||
|
printf("Error, could not load %s file: %s\n", dbPath.c_str(), SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
int nJoysticks = SDL_NumJoysticks();
|
const int nJoysticks = SDL_NumJoysticks();
|
||||||
mNumGamepads = 0;
|
numGamepads = 0;
|
||||||
|
|
||||||
// Cuenta el numero de mandos
|
// Cuenta el numero de mandos
|
||||||
for (int i = 0; i < nJoysticks; i++)
|
for (int i = 0; i < nJoysticks; ++i)
|
||||||
|
{
|
||||||
if (SDL_IsGameController(i))
|
if (SDL_IsGameController(i))
|
||||||
mNumGamepads++;
|
{
|
||||||
|
numGamepads++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("\nChecking for game controllers...\n");
|
printf("\nChecking for game controllers...\n");
|
||||||
printf("%i joysticks found, %i are gamepads\n", nJoysticks, mNumGamepads);
|
printf("%i joysticks found, %i are gamepads\n", nJoysticks, numGamepads);
|
||||||
|
|
||||||
if (mNumGamepads > 0)
|
if (numGamepads > 0)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
for (int i = 0; i < mNumGamepads; i++)
|
for (int i = 0; i < numGamepads; i++)
|
||||||
{
|
{
|
||||||
// Abre el mando y lo añade a la lista
|
// Abre el mando y lo añade a la lista
|
||||||
SDL_GameController *pad = SDL_GameControllerOpen(i);
|
SDL_GameController *pad = SDL_GameControllerOpen(i);
|
||||||
if (SDL_GameControllerGetAttached(pad) == 1)
|
if (SDL_GameControllerGetAttached(pad) == 1)
|
||||||
{
|
{
|
||||||
mConnectedControllers.push_back(pad);
|
connectedControllers.push_back(pad);
|
||||||
std::string separator(" #");
|
const std::string separator(" #");
|
||||||
std::string name = SDL_GameControllerNameForIndex(i);
|
std::string name = SDL_GameControllerNameForIndex(i);
|
||||||
name.resize(25);
|
name.resize(25);
|
||||||
name = name + separator + std::to_string(i);
|
name = name + separator + std::to_string(i);
|
||||||
std::cout << name << std::endl;
|
std::cout << name << std::endl;
|
||||||
mControllerNames.push_back(name);
|
controllerNames.push_back(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//mGameController = mConnectedControllers[0];
|
|
||||||
SDL_GameControllerEventState(SDL_ENABLE);
|
SDL_GameControllerEventState(SDL_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,23 +201,31 @@ bool Input::discoverGameController()
|
|||||||
// Comprueba si hay algun mando conectado
|
// Comprueba si hay algun mando conectado
|
||||||
bool Input::gameControllerFound()
|
bool Input::gameControllerFound()
|
||||||
{
|
{
|
||||||
if (mNumGamepads > 0)
|
if (numGamepads > 0)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el nombre de un mando de juego
|
// Obten el nombre de un mando de juego
|
||||||
std::string Input::getControllerName(int index)
|
std::string Input::getControllerName(int index)
|
||||||
{
|
{
|
||||||
if (mNumGamepads > 0)
|
if (numGamepads > 0)
|
||||||
return mControllerNames[index];
|
{
|
||||||
|
return controllerNames.at(index);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return "";
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el numero de mandos conectados
|
// Obten el numero de mandos conectados
|
||||||
int Input::getNumControllers()
|
int Input::getNumControllers()
|
||||||
{
|
{
|
||||||
return mNumGamepads;
|
return numGamepads;
|
||||||
}
|
}
|
||||||
@@ -41,19 +41,19 @@ private:
|
|||||||
Uint8 scancode; // Scancode asociado
|
Uint8 scancode; // Scancode asociado
|
||||||
bool active; // Indica si está activo
|
bool active; // Indica si está activo
|
||||||
};
|
};
|
||||||
keyBindings_t mKeyBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
|
||||||
|
|
||||||
struct GameControllerBindings_t
|
struct GameControllerBindings_t
|
||||||
{
|
{
|
||||||
SDL_GameControllerButton button; // GameControllerButton asociado
|
SDL_GameControllerButton button; // GameControllerButton asociado
|
||||||
bool active; // Indica si está activo
|
bool active; // Indica si está activo
|
||||||
};
|
};
|
||||||
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
|
||||||
|
|
||||||
std::vector<SDL_GameController *> mConnectedControllers; // Vector con todos los mandos conectados
|
std::vector<keyBindings_t> keyBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
||||||
std::vector<std::string> mControllerNames; // Vector con los nombres de los mandos
|
std::vector<GameControllerBindings_t> gameControllerBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
||||||
int mNumGamepads; // Numero de mandos conectados
|
std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos conectados
|
||||||
std::string mDBpath; // Ruta al archivo gamecontrollerdb.txt
|
std::vector<std::string> controllerNames; // Vector con los nombres de los mandos
|
||||||
|
int numGamepads; // Numero de mandos conectados
|
||||||
|
std::string dbPath; // Ruta al archivo gamecontrollerdb.txt
|
||||||
|
|
||||||
// Comprueba si hay un mando conectado
|
// Comprueba si hay un mando conectado
|
||||||
bool discoverGameController();
|
bool discoverGameController();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ private:
|
|||||||
Uint16 mCounter; // Contador
|
Uint16 mCounter; // Contador
|
||||||
section_t mSection; // Estado del bucle principal para saber si continua o se sale
|
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
|
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
bool mManualQuit; // Indica si se quiere salir del modo manual
|
bool mManualQuit; // Indica si se quiere salir del modo manual
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
|
|||||||
724
source/title.cpp
724
source/title.cpp
File diff suppressed because it is too large
Load Diff
@@ -42,54 +42,54 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Objetos
|
// Objetos
|
||||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *mScreen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
Input *mInput; // Objeto para leer las entradas de teclado o mando
|
Input *input; // Objeto para leer las entradas de teclado o mando
|
||||||
Lang *mLang; // Objeto para gestionar los textos en diferentes idiomas
|
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||||
Instructions *mInstructions; // Objeto para la sección de las instrucciones
|
Instructions *instructions; // Objeto para la sección de las instrucciones
|
||||||
Game *mDemoGame; // Objeto para lanzar la demo del juego
|
Game *demoGame; // Objeto para lanzar la demo del juego
|
||||||
SDL_Event *mEventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
|
|
||||||
LTexture *dustTexture; // Textura con los graficos del polvo
|
LTexture *dustTexture; // Textura con los graficos del polvo
|
||||||
LTexture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
LTexture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
||||||
LTexture *crisisTexture; // Textura con los graficos de la plabra crisis
|
LTexture *crisisTexture; // Textura con los graficos de la plabra crisis
|
||||||
LTexture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo
|
LTexture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo
|
||||||
|
|
||||||
SDL_Rect mBackgroundWindow; // Ventana visible para la textura de fondo del titulo
|
SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo
|
||||||
SDL_Texture *mBackground; // Textura dibujar el fondo del titulo
|
SDL_Texture *background; // Textura dibujar el fondo del titulo
|
||||||
|
|
||||||
AnimatedSprite *mDustBitmapL; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo
|
AnimatedSprite *dustBitmapL; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo
|
||||||
AnimatedSprite *mDustBitmapR; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo
|
AnimatedSprite *dustBitmapR; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo
|
||||||
|
|
||||||
SmartSprite *mCoffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo
|
SmartSprite *coffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo
|
||||||
SmartSprite *mCrisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo
|
SmartSprite *crisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo
|
||||||
|
|
||||||
Sprite *mGradient; // Sprite para dibujar el degradado del titulo
|
Sprite *gradient; // Sprite para dibujar el degradado del titulo
|
||||||
|
|
||||||
Text *mText; // Objeto de texto para poder escribir textos en pantalla
|
Text *text1; // Objeto de texto para poder escribir textos en pantalla
|
||||||
Text *mText2; // Objeto de texto para poder escribir textos en pantalla
|
Text *text2; // Objeto de texto para poder escribir textos en pantalla
|
||||||
Fade *mFade; // Objeto para realizar fundidos en pantalla
|
Fade *fade; // Objeto para realizar fundidos en pantalla
|
||||||
|
|
||||||
// Variable
|
// Variable
|
||||||
JA_Music mMusic; // Musica para el titulo
|
JA_Music titleMusic; // Musica para el titulo
|
||||||
JA_Sound mSound; // Sonido con el impacto del título
|
JA_Sound crashSound; // Sonido con el impacto del título
|
||||||
int mBackgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo
|
int backgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo
|
||||||
int mCounter; // Temporizador para la pantalla de titulo
|
int counter; // Temporizador para la pantalla de titulo
|
||||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint8 mBackgroundMode; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo
|
Uint8 backgroundMode; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo
|
||||||
float mSin[360]; // Vector con los valores del seno precalculados
|
float sin[360]; // Vector con los valores del seno precalculados
|
||||||
bool mMenuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente
|
bool menuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente
|
||||||
bool mDemo; // Indica si el modo demo estará activo
|
bool demo; // Indica si el modo demo estará activo
|
||||||
section_t mSection; // Indicador para el bucle del titulo
|
section_t section; // Indicador para el bucle del titulo
|
||||||
section_t mNextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
|
section_t nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
|
||||||
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
Uint8 mPostFade; // Opción a realizar cuando termina el fundido
|
Uint8 postFade; // Opción a realizar cuando termina el fundido
|
||||||
menu_t mMenu; // Variable con todos los objetos menus y sus variables
|
menu_t menu; // Variable con todos los objetos menus y sus variables
|
||||||
struct options_t *mOptions; // Variable con todas las variables de las opciones del programa
|
struct options_t *options; // Variable con todas las variables de las opciones del programa
|
||||||
options_t mOptionsPrevious; // Variable de respaldo para las opciones
|
options_t optionsPrevious; // Variable de respaldo para las opciones
|
||||||
std::vector<input_t> mAvailableInputDevices; // Vector con todos los metodos de control disponibles
|
std::vector<input_t> availableInputDevices; // Vector con todos los metodos de control disponibles
|
||||||
int mDeviceIndex[2]; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
|
std::vector<int> deviceIndex; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -100,7 +100,7 @@ private:
|
|||||||
// Comprueba los eventos
|
// Comprueba los eventos
|
||||||
void checkEventHandler();
|
void checkEventHandler();
|
||||||
|
|
||||||
//Actualiza el tileado de fondo
|
// Actualiza el tileado de fondo
|
||||||
void updateBG();
|
void updateBG();
|
||||||
|
|
||||||
// Cambia el valor de la variable de modo de pantalla completa
|
// Cambia el valor de la variable de modo de pantalla completa
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "ltexture.h"
|
#include "ltexture.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef UTILS_H
|
#ifndef UTILS_H
|
||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
@@ -86,7 +87,7 @@ struct input_t
|
|||||||
struct options_t
|
struct options_t
|
||||||
{
|
{
|
||||||
Uint8 difficulty; // Dificultad del juego
|
Uint8 difficulty; // Dificultad del juego
|
||||||
input_t input[2]; // Modo de control (teclado o mando)
|
std::vector<input_t> input; // Modo de control (teclado o mando)
|
||||||
Uint8 language; // Idioma usado en el juego
|
Uint8 language; // Idioma usado en el juego
|
||||||
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
|
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
|
||||||
Uint8 windowSize; // Contiene el valor por el que se multiplica el tamaño de la ventana
|
Uint8 windowSize; // Contiene el valor por el que se multiplica el tamaño de la ventana
|
||||||
|
|||||||
Reference in New Issue
Block a user