Pequeños cambios en las librerias comunes
This commit is contained in:
2
Makefile
2
Makefile
@@ -3,7 +3,7 @@ executable = coffee_crisis
|
|||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
if not exist bin\ (mkdir bin)
|
if not exist bin\ (mkdir bin)
|
||||||
g++ -std=c++11 -Wall -O2 source/*.cpp -lmingw32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -o bin/$(executable).exe
|
g++ -std=c++11 -Wall -O2 source/*.cpp -lmingw32 -lSDL2main -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows -o bin/$(executable).exe
|
||||||
strip -s -R .comment -R .gnu.version bin/$(executable).exe --strip-unneeded
|
strip -s -R .comment -R .gnu.version bin/$(executable).exe --strip-unneeded
|
||||||
macos:
|
macos:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Asset::Asset(std::string path)
|
Asset::Asset(std::string path)
|
||||||
{
|
{
|
||||||
executablePath = path;
|
executablePath = path;
|
||||||
longest_name = 0;
|
longestName = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -13,7 +13,7 @@ Asset::~Asset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void Asset::add(std::string file, enum assetType_e type, bool required)
|
void Asset::add(std::string file, enum assetType type, bool required)
|
||||||
{
|
{
|
||||||
item_t temp;
|
item_t temp;
|
||||||
temp.file = executablePath + file;
|
temp.file = executablePath + file;
|
||||||
@@ -22,7 +22,7 @@ void Asset::add(std::string file, enum assetType_e type, bool required)
|
|||||||
fileList.push_back(temp);
|
fileList.push_back(temp);
|
||||||
|
|
||||||
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
|
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
|
||||||
longest_name = SDL_max(longest_name, filename.size());
|
longestName = SDL_max(longestName, filename.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
||||||
@@ -106,7 +106,7 @@ bool Asset::checkFile(std::string path)
|
|||||||
SDL_RWclose(file);
|
SDL_RWclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string s = "Checking file %-" + std::to_string(longest_name) + "s [" + result + "]\n";
|
const std::string s = "Checking file %-" + std::to_string(longestName) + "s [" + result + "]\n";
|
||||||
printf(s.c_str(), filename.c_str());
|
printf(s.c_str(), filename.c_str());
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#ifndef ASSET_H
|
#ifndef ASSET_H
|
||||||
#define ASSET_H
|
#define ASSET_H
|
||||||
|
|
||||||
enum assetType_e
|
enum assetType
|
||||||
{
|
{
|
||||||
t_bitmap,
|
t_bitmap,
|
||||||
t_music,
|
t_music,
|
||||||
@@ -29,11 +29,11 @@ private:
|
|||||||
struct item_t
|
struct item_t
|
||||||
{
|
{
|
||||||
std::string file; // Ruta del fichero desde la raiz del directorio
|
std::string file; // Ruta del fichero desde la raiz del directorio
|
||||||
enum assetType_e type; // Indica el tipo de recurso
|
enum assetType type; // Indica el tipo de recurso
|
||||||
bool required; // Indica si es un fichero que debe de existir
|
bool required; // Indica si es un fichero que debe de existir
|
||||||
};
|
};
|
||||||
|
|
||||||
int longest_name; // Contiene la longitud del nombre de fichero mas largo
|
int longestName; // Contiene la longitud del nombre de fichero mas largo
|
||||||
|
|
||||||
std::vector<item_t> fileList;
|
std::vector<item_t> fileList;
|
||||||
std::string executablePath;
|
std::string executablePath;
|
||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
~Asset();
|
~Asset();
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void add(std::string file, enum assetType_e type, bool required = true);
|
void add(std::string file, enum assetType type, bool required = true);
|
||||||
|
|
||||||
// Devuelve un elemento de la lista a partir de una cadena
|
// Devuelve un elemento de la lista a partir de una cadena
|
||||||
std::string get(std::string text);
|
std::string get(std::string text);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
{
|
{
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
||||||
{
|
{
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
@@ -108,11 +108,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!gameControllerBindings[input].active)
|
if (!gameControllerBindings.at(input).active)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings[input].active = true;
|
gameControllerBindings.at(input).active = true;
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -122,9 +122,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings[input].button) == 0)
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) == 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings[input].active = false;
|
gameControllerBindings.at(input).active = false;
|
||||||
successGameController = false;
|
successGameController = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -138,6 +138,44 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
return (successKeyboard || successGameController);
|
return (successKeyboard || successGameController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Comprueba si hay almenos un input activo
|
||||||
|
bool Input::checkAnyInput(int device, int index)
|
||||||
|
{
|
||||||
|
if (device == INPUT_USE_ANY)
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device == INPUT_USE_KEYBOARD || device == INPUT_USE_ANY)
|
||||||
|
{
|
||||||
|
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)keyBindings.size(); ++i)
|
||||||
|
{
|
||||||
|
if (mKeystates[keyBindings.at(i).scancode] != 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameControllerFound())
|
||||||
|
{
|
||||||
|
if (device == INPUT_USE_GAMECONTROLLER || device == INPUT_USE_ANY)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
|
||||||
|
{
|
||||||
|
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(i).button) != 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Comprueba si hay un mando conectado
|
// Comprueba si hay un mando conectado
|
||||||
bool Input::discoverGameController()
|
bool Input::discoverGameController()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ public:
|
|||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
bool checkInput(Uint8 input, bool repeat, int device = INPUT_USE_ANY, int index = 0);
|
||||||
|
|
||||||
|
// Comprueba si hay almenos un input activo
|
||||||
|
bool checkAnyInput(int device, int index);
|
||||||
|
|
||||||
// Comprueba si hay algun mando conectado
|
// Comprueba si hay algun mando conectado
|
||||||
bool gameControllerFound();
|
bool gameControllerFound();
|
||||||
|
|
||||||
|
|||||||
@@ -171,9 +171,6 @@ bool Menu::load(std::string file_path)
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reorganiza el menu con los valores recien cargados
|
|
||||||
// reorganize();
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +208,7 @@ bool Menu::setItem(item_t *item, std::string var, std::string value)
|
|||||||
else if ((var == "") || (var == "[/item]"))
|
else if ((var == "") || (var == "[/item]"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
@@ -355,11 +353,6 @@ bool Menu::setVars(std::string var, std::string value)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa las variables
|
|
||||||
void Menu::init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carga los ficheros de audio
|
// Carga los ficheros de audio
|
||||||
void Menu::loadAudioFile(std::string file, int sound)
|
void Menu::loadAudioFile(std::string file, int sound)
|
||||||
{
|
{
|
||||||
@@ -412,7 +405,8 @@ void Menu::updateSelector()
|
|||||||
selector.moving = false;
|
selector.moving = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selector.despY < 0) // Va hacia arriba
|
|
||||||
|
else if (selector.despY < 0) // Va hacia arriba
|
||||||
{
|
{
|
||||||
if (selector.y < selector.targetY) // Ha llegado al destino
|
if (selector.y < selector.targetY) // Ha llegado al destino
|
||||||
{
|
{
|
||||||
@@ -440,7 +434,8 @@ void Menu::updateSelector()
|
|||||||
selector.resizing = false;
|
selector.resizing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selector.incH < 0) // Decrece
|
|
||||||
|
else if (selector.incH < 0) // Decrece
|
||||||
{
|
{
|
||||||
if (selector.h < selector.targetH) // Ha llegado al destino
|
if (selector.h < selector.targetH) // Ha llegado al destino
|
||||||
{
|
{
|
||||||
@@ -463,7 +458,7 @@ void Menu::setSelectorPos(int index)
|
|||||||
if (index < (int)item.size())
|
if (index < (int)item.size())
|
||||||
{
|
{
|
||||||
selector.index = index;
|
selector.index = index;
|
||||||
selector.rect.y = selector.y = selector.originY = selector.targetY = item[selector.index].rect.y;
|
selector.rect.y = selector.y = selector.originY = selector.targetY = item.at(selector.index).rect.y;
|
||||||
selector.rect.w = rectBG.rect.w;
|
selector.rect.w = rectBG.rect.w;
|
||||||
selector.rect.x = rectBG.rect.x;
|
selector.rect.x = rectBG.rect.x;
|
||||||
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
|
selector.originH = selector.targetH = selector.rect.h = getSelectorHeight(selector.index);
|
||||||
@@ -491,13 +486,13 @@ void Menu::reset()
|
|||||||
{
|
{
|
||||||
itemSelected = MENU_NO_OPTION;
|
itemSelected = MENU_NO_OPTION;
|
||||||
selector.index = 0;
|
selector.index = 0;
|
||||||
selector.originY = selector.targetY = selector.y = item[0].rect.y;
|
selector.originY = selector.targetY = selector.y = item.at(0).rect.y;
|
||||||
selector.originH = selector.targetH = item[0].rect.h;
|
selector.originH = selector.targetH = item.at(0).rect.h;
|
||||||
selector.moving = false;
|
selector.moving = false;
|
||||||
selector.resizing = false;
|
selector.resizing = false;
|
||||||
|
|
||||||
// Si el primer elemento no es seleccionable, incrementa el selector
|
// Si el primer elemento no es seleccionable, incrementa el selector
|
||||||
if (!item[selector.index].selectable)
|
if (!item.at(selector.index).selectable)
|
||||||
{
|
{
|
||||||
increaseSelectorIndex();
|
increaseSelectorIndex();
|
||||||
setSelectorPos(selector.index);
|
setSelectorPos(selector.index);
|
||||||
@@ -529,18 +524,18 @@ void Menu::reorganize()
|
|||||||
bool Menu::increaseSelectorIndex()
|
bool Menu::increaseSelectorIndex()
|
||||||
{
|
{
|
||||||
// Obten las coordenadas del elemento actual
|
// Obten las coordenadas del elemento actual
|
||||||
selector.y = selector.originY = item[selector.index].rect.y;
|
selector.y = selector.originY = item.at(selector.index).rect.y;
|
||||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||||
|
|
||||||
// Calcula cual es el siguiente elemento
|
// Calcula cual es el siguiente elemento
|
||||||
++selector.index %= item.size();
|
++selector.index %= item.size();
|
||||||
while (!item[selector.index].selectable)
|
while (!item.at(selector.index).selectable)
|
||||||
{
|
{
|
||||||
++selector.index %= item.size();
|
++selector.index %= item.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece las coordenadas y altura de destino
|
// Establece las coordenadas y altura de destino
|
||||||
selector.targetY = item[selector.index].rect.y;
|
selector.targetY = item.at(selector.index).rect.y;
|
||||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||||
|
|
||||||
selector.targetH = getSelectorHeight(selector.index);
|
selector.targetH = getSelectorHeight(selector.index);
|
||||||
@@ -559,7 +554,7 @@ bool Menu::increaseSelectorIndex()
|
|||||||
bool Menu::decreaseSelectorIndex()
|
bool Menu::decreaseSelectorIndex()
|
||||||
{
|
{
|
||||||
// Obten las coordenadas del elemento actual
|
// Obten las coordenadas del elemento actual
|
||||||
selector.y = selector.originY = item[selector.index].rect.y;
|
selector.y = selector.originY = item.at(selector.index).rect.y;
|
||||||
selector.h = selector.originH = getSelectorHeight(selector.index);
|
selector.h = selector.originH = getSelectorHeight(selector.index);
|
||||||
|
|
||||||
// Calcula cual es el siguiente elemento
|
// Calcula cual es el siguiente elemento
|
||||||
@@ -572,7 +567,7 @@ bool Menu::decreaseSelectorIndex()
|
|||||||
selector.index--;
|
selector.index--;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!item[selector.index].selectable)
|
while (!item.at(selector.index).selectable)
|
||||||
{
|
{
|
||||||
if (selector.index == 0)
|
if (selector.index == 0)
|
||||||
{
|
{
|
||||||
@@ -585,7 +580,7 @@ bool Menu::decreaseSelectorIndex()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece las coordenadas y altura de destino
|
// Establece las coordenadas y altura de destino
|
||||||
selector.targetY = item[selector.index].rect.y;
|
selector.targetY = item.at(selector.index).rect.y;
|
||||||
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
selector.despY = (selector.targetY - selector.originY) / selector.numJumps;
|
||||||
|
|
||||||
selector.targetH = getSelectorHeight(selector.index);
|
selector.targetH = getSelectorHeight(selector.index);
|
||||||
@@ -635,28 +630,29 @@ void Menu::render()
|
|||||||
if (i == selector.index)
|
if (i == selector.index)
|
||||||
{
|
{
|
||||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item[i].selectable)
|
else if (item.at(i).selectable)
|
||||||
{
|
{
|
||||||
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item[i].greyed)
|
else if (item.at(i).greyed)
|
||||||
{
|
{
|
||||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, colorGreyed);
|
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, colorGreyed);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{ // No seleccionable
|
{ // No seleccionable
|
||||||
if ((item[i].linkedUp) && (i == selector.index + 1))
|
if ((item.at(i).linkedUp) && (i == selector.index + 1))
|
||||||
{
|
{
|
||||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||||
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
|
text->writeColored(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label, color);
|
||||||
}
|
}
|
||||||
else // No enlazado con el de arriba
|
else // No enlazado con el de arriba
|
||||||
{
|
{
|
||||||
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
|
text->write(item.at(i).rect.x, item.at(i).rect.y, item.at(i).label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -918,42 +914,42 @@ int Menu::findHeight()
|
|||||||
// Recoloca los elementos del menu en el eje Y
|
// Recoloca los elementos del menu en el eje Y
|
||||||
void Menu::replaceElementsOnY()
|
void Menu::replaceElementsOnY()
|
||||||
{
|
{
|
||||||
item[0].rect.y = y;
|
item.at(0).rect.y = y;
|
||||||
|
|
||||||
for (int i = 1; i < (int)item.size(); i++)
|
for (int i = 1; i < (int)item.size(); i++)
|
||||||
{
|
{
|
||||||
item[i].rect.y = item[i - 1].rect.y + item[i - 1].rect.h + item[i - 1].hPaddingDown;
|
item.at(i).rect.y = item.at(i - 1).rect.y + item.at(i - 1).rect.h + item.at(i - 1).hPaddingDown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado seleccionable de un item
|
// Establece el estado seleccionable de un item
|
||||||
void Menu::setSelectable(int index, bool value)
|
void Menu::setSelectable(int index, bool value)
|
||||||
{
|
{
|
||||||
item[index].selectable = value;
|
item.at(index).selectable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado agrisado de un item
|
// Establece el estado agrisado de un item
|
||||||
void Menu::setGreyed(int index, bool value)
|
void Menu::setGreyed(int index, bool value)
|
||||||
{
|
{
|
||||||
item[index].greyed = value;
|
item.at(index).greyed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el estado de enlace de un item
|
// Establece el estado de enlace de un item
|
||||||
void Menu::setLinkedDown(int index, bool value)
|
void Menu::setLinkedDown(int index, bool value)
|
||||||
{
|
{
|
||||||
item[index].linkedDown = value;
|
item.at(index).linkedDown = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula la altura del selector
|
// Calcula la altura del selector
|
||||||
int Menu::getSelectorHeight(int value)
|
int Menu::getSelectorHeight(int value)
|
||||||
{
|
{
|
||||||
if (item[value].linkedDown)
|
if (item.at(value).linkedDown)
|
||||||
{
|
{
|
||||||
return item[value].rect.h + item[value].hPaddingDown + item[value + 1].rect.h;
|
return item.at(value).rect.h + item.at(value).hPaddingDown + item.at(value + 1).rect.h;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return item[value].rect.h;
|
return item.at(value).rect.h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,9 +108,6 @@ private:
|
|||||||
// Asigna variables a partir de dos cadenas
|
// Asigna variables a partir de dos cadenas
|
||||||
bool setItem(item_t *item, std::string var, std::string value);
|
bool setItem(item_t *item, std::string var, std::string value);
|
||||||
|
|
||||||
// Inicializa las variables
|
|
||||||
void init();
|
|
||||||
|
|
||||||
// Actualiza el menu para recolocarlo correctamente y establecer el tamaño
|
// Actualiza el menu para recolocarlo correctamente y establecer el tamaño
|
||||||
void reorganize();
|
void reorganize();
|
||||||
|
|
||||||
|
|||||||
@@ -160,11 +160,13 @@ double MovingSprite::getAngle()
|
|||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición y el tamaño del objeto
|
||||||
void MovingSprite::setPos(SDL_Rect rect)
|
void MovingSprite::setRect(SDL_Rect rect)
|
||||||
{
|
{
|
||||||
x = (float)rect.x;
|
x = (float)rect.x;
|
||||||
y = (float)rect.y;
|
y = (float)rect.y;
|
||||||
|
w = rect.w;
|
||||||
|
h = rect.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
@@ -333,15 +335,6 @@ SDL_Rect MovingSprite::getRect()
|
|||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece los valores de posición y tamaño del sprite
|
|
||||||
void MovingSprite::setRect(SDL_Rect rect)
|
|
||||||
{
|
|
||||||
x = (float)rect.x;
|
|
||||||
y = (float)rect.y;
|
|
||||||
w = rect.w;
|
|
||||||
h = rect.h;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deshace el último movimiento
|
// Deshace el último movimiento
|
||||||
void MovingSprite::undoMove()
|
void MovingSprite::undoMove()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ public:
|
|||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
Uint16 getRotateSpeed();
|
Uint16 getRotateSpeed();
|
||||||
|
|
||||||
// Establece la posición del objeto
|
// Establece la posición y el tamaño del objeto
|
||||||
void setPos(SDL_Rect rect);
|
void setRect(SDL_Rect rect);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setPosX(float value);
|
void setPosX(float value);
|
||||||
@@ -151,9 +151,6 @@ public:
|
|||||||
// Devuelve el rectangulo donde está el sprite
|
// Devuelve el rectangulo donde está el sprite
|
||||||
SDL_Rect getRect();
|
SDL_Rect getRect();
|
||||||
|
|
||||||
// Establece los valores de posición y tamaño del sprite
|
|
||||||
void setRect(SDL_Rect rect);
|
|
||||||
|
|
||||||
// Deshace el último movimiento
|
// Deshace el último movimiento
|
||||||
void undoMove();
|
void undoMove();
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i
|
|||||||
|
|
||||||
// Crea la textura donde se dibujan los graficos del juego
|
// Crea la textura donde se dibujan los graficos del juego
|
||||||
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight);
|
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight);
|
||||||
if (gameCanvas == NULL)
|
if (gameCanvas == nullptr)
|
||||||
{
|
{
|
||||||
printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError());
|
printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||||
}
|
}
|
||||||
@@ -61,14 +61,14 @@ void Screen::start()
|
|||||||
void Screen::blit()
|
void Screen::blit()
|
||||||
{
|
{
|
||||||
// Vuelve a dejar el renderizador en modo normal
|
// Vuelve a dejar el renderizador en modo normal
|
||||||
SDL_SetRenderTarget(renderer, NULL);
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
|
||||||
// Borra el contenido previo
|
// Borra el contenido previo
|
||||||
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
|
SDL_SetRenderDrawColor(renderer, borderColor.r, borderColor.g, borderColor.b, 0xFF);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
// Copia la textura de juego en el renderizador en la posición adecuada
|
// Copia la textura de juego en el renderizador en la posición adecuada
|
||||||
SDL_RenderCopy(renderer, gameCanvas, NULL, &dest);
|
SDL_RenderCopy(renderer, gameCanvas, nullptr, &dest);
|
||||||
|
|
||||||
// Muestra por pantalla el renderizador
|
// Muestra por pantalla el renderizador
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
|
|||||||
@@ -143,7 +143,9 @@ void Text::initOffsetFromFile(std::string file)
|
|||||||
{
|
{
|
||||||
// Almacena solo las lineas impares
|
// Almacena solo las lineas impares
|
||||||
if (line_read % 2 == 1)
|
if (line_read % 2 == 1)
|
||||||
|
{
|
||||||
offset[index++].w = std::stoi(buffer);
|
offset[index++].w = std::stoi(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
// Limpia el buffer
|
// Limpia el buffer
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user