Eliminados la mayor parte de accesos a vector mediante at()
This commit is contained in:
@@ -222,121 +222,121 @@ int AnimatedSprite::getIndex(std::string name)
|
|||||||
// Calcula el frame correspondiente a la animación
|
// Calcula el frame correspondiente a la animación
|
||||||
void AnimatedSprite::animate()
|
void AnimatedSprite::animate()
|
||||||
{
|
{
|
||||||
if (!enabled || animation.at(currentAnimation).speed == 0)
|
if (!enabled || animation[currentAnimation].speed == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el frame actual a partir del contador
|
// Calcula el frame actual a partir del contador
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).counter / animation.at(currentAnimation).speed;
|
animation[currentAnimation].currentFrame = animation[currentAnimation].counter / animation[currentAnimation].speed;
|
||||||
|
|
||||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
// Si alcanza el final de la animación, reinicia el contador de la animación
|
||||||
// en función de la variable loop y coloca el nuevo frame
|
// en función de la variable loop y coloca el nuevo frame
|
||||||
if (animation.at(currentAnimation).currentFrame >= (int)animation.at(currentAnimation).frames.size())
|
if (animation[currentAnimation].currentFrame >= (int)animation[currentAnimation].frames.size())
|
||||||
{
|
{
|
||||||
if (animation.at(currentAnimation).loop == -1)
|
if (animation[currentAnimation].loop == -1)
|
||||||
{ // Si no hay loop, deja el último frame
|
{ // Si no hay loop, deja el último frame
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).frames.size();
|
animation[currentAnimation].currentFrame = animation[currentAnimation].frames.size();
|
||||||
animation.at(currentAnimation).completed = true;
|
animation[currentAnimation].completed = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Si hay loop, vuelve al frame indicado
|
{ // Si hay loop, vuelve al frame indicado
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).currentFrame = animation.at(currentAnimation).loop;
|
animation[currentAnimation].currentFrame = animation[currentAnimation].loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// En caso contrario
|
// En caso contrario
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Escoge el frame correspondiente de la animación
|
// Escoge el frame correspondiente de la animación
|
||||||
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
|
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
||||||
|
|
||||||
// Incrementa el contador de la animacion
|
// Incrementa el contador de la animacion
|
||||||
animation.at(currentAnimation).counter++;
|
animation[currentAnimation].counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el numero de frames de la animación actual
|
// Obtiene el numero de frames de la animación actual
|
||||||
int AnimatedSprite::getNumFrames()
|
int AnimatedSprite::getNumFrames()
|
||||||
{
|
{
|
||||||
return (int)animation.at(currentAnimation).frames.size();
|
return (int)animation[currentAnimation].frames.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el frame actual de la animación
|
// Establece el frame actual de la animación
|
||||||
void AnimatedSprite::setCurrentFrame(int num)
|
void AnimatedSprite::setCurrentFrame(int num)
|
||||||
{
|
{
|
||||||
// Descarta valores fuera de rango
|
// Descarta valores fuera de rango
|
||||||
if (num >= (int)animation.at(currentAnimation).frames.size())
|
if (num >= (int)animation[currentAnimation].frames.size())
|
||||||
{
|
{
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el valor de la variable
|
// Cambia el valor de la variable
|
||||||
animation.at(currentAnimation).currentFrame = num;
|
animation[currentAnimation].currentFrame = num;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
|
|
||||||
// Escoge el frame correspondiente de la animación
|
// Escoge el frame correspondiente de la animación
|
||||||
setSpriteClip(animation.at(currentAnimation).frames.at(animation.at(currentAnimation).currentFrame));
|
setSpriteClip(animation[currentAnimation].frames[animation[currentAnimation].currentFrame]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor del contador
|
// Establece el valor del contador
|
||||||
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
void AnimatedSprite::setAnimationCounter(std::string name, int num)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).counter = num;
|
animation[getIndex(name)].counter = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
// Establece la velocidad de una animación
|
||||||
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
void AnimatedSprite::setAnimationSpeed(std::string name, int speed)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).counter = speed;
|
animation[getIndex(name)].counter = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece la velocidad de una animación
|
// Establece la velocidad de una animación
|
||||||
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
void AnimatedSprite::setAnimationSpeed(int index, int speed)
|
||||||
{
|
{
|
||||||
animation.at(index).counter = speed;
|
animation[index].counter = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
// Establece si la animación se reproduce en bucle
|
||||||
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
void AnimatedSprite::setAnimationLoop(std::string name, int loop)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).loop = loop;
|
animation[getIndex(name)].loop = loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece si la animación se reproduce en bucle
|
// Establece si la animación se reproduce en bucle
|
||||||
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
void AnimatedSprite::setAnimationLoop(int index, int loop)
|
||||||
{
|
{
|
||||||
animation.at(index).loop = loop;
|
animation[index].loop = loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
void AnimatedSprite::setAnimationCompleted(std::string name, bool value)
|
||||||
{
|
{
|
||||||
animation.at(getIndex(name)).completed = value;
|
animation[getIndex(name)].completed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OLD - Establece el valor de la variable
|
// OLD - Establece el valor de la variable
|
||||||
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
void AnimatedSprite::setAnimationCompleted(int index, bool value)
|
||||||
{
|
{
|
||||||
animation.at(index).completed = value;
|
animation[index].completed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
// Comprueba si ha terminado la animación
|
||||||
bool AnimatedSprite::animationIsCompleted()
|
bool AnimatedSprite::animationIsCompleted()
|
||||||
{
|
{
|
||||||
return animation.at(currentAnimation).completed;
|
return animation[currentAnimation].completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
// Devuelve el rectangulo de una animación y frame concreto
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
SDL_Rect AnimatedSprite::getAnimationClip(std::string name, Uint8 index)
|
||||||
{
|
{
|
||||||
return animation.at(getIndex(name)).frames.at(index);
|
return animation[getIndex(name)].frames[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el rectangulo de una animación y frame concreto
|
// Devuelve el rectangulo de una animación y frame concreto
|
||||||
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
SDL_Rect AnimatedSprite::getAnimationClip(int indexA, Uint8 indexF)
|
||||||
{
|
{
|
||||||
return animation.at(indexA).frames.at(indexF);
|
return animation[indexA].frames[indexF];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga la animación desde un vector
|
// Carga la animación desde un vector
|
||||||
@@ -484,9 +484,9 @@ void AnimatedSprite::setCurrentAnimation(std::string name)
|
|||||||
if (currentAnimation != newAnimation)
|
if (currentAnimation != newAnimation)
|
||||||
{
|
{
|
||||||
currentAnimation = newAnimation;
|
currentAnimation = newAnimation;
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,9 +497,9 @@ void AnimatedSprite::setCurrentAnimation(int index)
|
|||||||
if (currentAnimation != newAnimation)
|
if (currentAnimation != newAnimation)
|
||||||
{
|
{
|
||||||
currentAnimation = newAnimation;
|
currentAnimation = newAnimation;
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ void AnimatedSprite::update()
|
|||||||
// Establece el rectangulo para un frame de una animación
|
// Establece el rectangulo para un frame de una animación
|
||||||
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
animation.at(index_animation).frames.push_back({x, y, w, h});
|
animation[index_animation].frames.push_back({x, y, w, h});
|
||||||
}
|
}
|
||||||
|
|
||||||
// OLD - Establece el contador para todas las animaciones
|
// OLD - Establece el contador para todas las animaciones
|
||||||
@@ -528,7 +528,7 @@ void AnimatedSprite::setAnimationCounter(int value)
|
|||||||
// Reinicia la animación
|
// Reinicia la animación
|
||||||
void AnimatedSprite::resetAnimation()
|
void AnimatedSprite::resetAnimation()
|
||||||
{
|
{
|
||||||
animation.at(currentAnimation).currentFrame = 0;
|
animation[currentAnimation].currentFrame = 0;
|
||||||
animation.at(currentAnimation).counter = 0;
|
animation[currentAnimation].counter = 0;
|
||||||
animation.at(currentAnimation).completed = false;
|
animation[currentAnimation].completed = false;
|
||||||
}
|
}
|
||||||
@@ -34,13 +34,13 @@ void Input::update()
|
|||||||
// Asigna inputs a teclas
|
// Asigna inputs a teclas
|
||||||
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
void Input::bindKey(Uint8 input, SDL_Scancode code)
|
||||||
{
|
{
|
||||||
keyBindings.at(input).scancode = code;
|
keyBindings[input].scancode = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna inputs a botones del mando
|
// Asigna inputs a botones del mando
|
||||||
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton button)
|
||||||
{
|
{
|
||||||
gameControllerBindings.at(input).button = button;
|
gameControllerBindings[input].button = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si un input esta activo
|
// Comprueba si un input esta activo
|
||||||
@@ -65,7 +65,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
|
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (keyStates[keyBindings.at(input).scancode] != 0)
|
if (keyStates[keyBindings[input].scancode] != 0)
|
||||||
{
|
{
|
||||||
successKeyboard = true;
|
successKeyboard = true;
|
||||||
}
|
}
|
||||||
@@ -76,11 +76,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!keyBindings.at(input).active)
|
if (!keyBindings[input].active)
|
||||||
{
|
{
|
||||||
if (keyStates[keyBindings.at(input).scancode] != 0)
|
if (keyStates[keyBindings[input].scancode] != 0)
|
||||||
{
|
{
|
||||||
keyBindings.at(input).active = true;
|
keyBindings[input].active = true;
|
||||||
successKeyboard = true;
|
successKeyboard = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -90,9 +90,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (keyStates[keyBindings.at(input).scancode] == 0)
|
if (keyStates[keyBindings[input].scancode] == 0)
|
||||||
{
|
{
|
||||||
keyBindings.at(input).active = false;
|
keyBindings[input].active = false;
|
||||||
successKeyboard = false;
|
successKeyboard = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -108,7 +108,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
{
|
{
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
|
||||||
{
|
{
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
@@ -119,11 +119,11 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!gameControllerBindings.at(input).active)
|
if (!gameControllerBindings[input].active)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) != 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings.at(input).active = true;
|
gameControllerBindings[input].active = true;
|
||||||
successGameController = true;
|
successGameController = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -133,9 +133,9 @@ bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(input).button) == 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[input].button) == 0)
|
||||||
{
|
{
|
||||||
gameControllerBindings.at(input).active = false;
|
gameControllerBindings[input].active = false;
|
||||||
successGameController = false;
|
successGameController = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -163,7 +163,7 @@ bool Input::checkAnyInput(int device, int index)
|
|||||||
|
|
||||||
for (int i = 0; i < (int)keyBindings.size(); ++i)
|
for (int i = 0; i < (int)keyBindings.size(); ++i)
|
||||||
{
|
{
|
||||||
if (mKeystates[keyBindings.at(i).scancode] != 0)
|
if (mKeystates[keyBindings[i].scancode] != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ bool Input::checkAnyInput(int device, int index)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
|
for (int i = 0; i < (int)gameControllerBindings.size(); ++i)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connectedControllers.at(index), gameControllerBindings.at(i).button) != 0)
|
if (SDL_GameControllerGetButton(connectedControllers[index], gameControllerBindings[i].button) != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -277,7 +277,7 @@ std::string Input::getControllerName(int index)
|
|||||||
{
|
{
|
||||||
if (numGamepads > 0)
|
if (numGamepads > 0)
|
||||||
{
|
{
|
||||||
return controllerNames.at(index);
|
return controllerNames[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ void Notify::render()
|
|||||||
{
|
{
|
||||||
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
notifications.at(i).sprite->render();
|
notifications[i].sprite->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,63 +47,63 @@ void Notify::update()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)notifications.size(); ++i)
|
for (int i = 0; i < (int)notifications.size(); ++i)
|
||||||
{
|
{
|
||||||
notifications.at(i).counter++;
|
notifications[i].counter++;
|
||||||
|
|
||||||
// Comprueba los estados
|
// Comprueba los estados
|
||||||
if (notifications.at(i).state == ns_rising)
|
if (notifications[i].state == ns_rising)
|
||||||
{
|
{
|
||||||
const float step = ((float)notifications.at(i).counter / notifications.at(i).travelDist);
|
const float step = ((float)notifications[i].counter / notifications[i].travelDist);
|
||||||
const int alpha = 255 * step;
|
const int alpha = 255 * step;
|
||||||
|
|
||||||
if (options->notifications.posV == pos_top)
|
if (options->notifications.posV == pos_top)
|
||||||
{
|
{
|
||||||
notifications.at(i).rect.y++;
|
notifications[i].rect.y++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
notifications.at(i).rect.y--;
|
notifications[i].rect.y--;
|
||||||
}
|
}
|
||||||
notifications.at(i).texture->setAlpha(alpha);
|
notifications[i].texture->setAlpha(alpha);
|
||||||
|
|
||||||
if (notifications.at(i).rect.y == notifications.at(i).y)
|
if (notifications[i].rect.y == notifications[i].y)
|
||||||
{
|
{
|
||||||
notifications.at(i).state = ns_stay;
|
notifications[i].state = ns_stay;
|
||||||
notifications.at(i).texture->setAlpha(255);
|
notifications[i].texture->setAlpha(255);
|
||||||
notifications.at(i).counter = 0;
|
notifications[i].counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (notifications.at(i).state == ns_stay)
|
else if (notifications[i].state == ns_stay)
|
||||||
{
|
{
|
||||||
if (notifications.at(i).counter == waitTime)
|
if (notifications[i].counter == waitTime)
|
||||||
{
|
{
|
||||||
notifications.at(i).state = ns_vanishing;
|
notifications[i].state = ns_vanishing;
|
||||||
notifications.at(i).counter = 0;
|
notifications[i].counter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (notifications.at(i).state == ns_vanishing)
|
else if (notifications[i].state == ns_vanishing)
|
||||||
{
|
{
|
||||||
|
|
||||||
const float step = (notifications.at(i).counter / (float)notifications.at(i).travelDist);
|
const float step = (notifications[i].counter / (float)notifications[i].travelDist);
|
||||||
const int alpha = 255 * (1 - step);
|
const int alpha = 255 * (1 - step);
|
||||||
|
|
||||||
if (options->notifications.posV == pos_top)
|
if (options->notifications.posV == pos_top)
|
||||||
{
|
{
|
||||||
notifications.at(i).rect.y--;
|
notifications[i].rect.y--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
notifications.at(i).rect.y++;
|
notifications[i].rect.y++;
|
||||||
}
|
}
|
||||||
notifications.at(i).texture->setAlpha(alpha);
|
notifications[i].texture->setAlpha(alpha);
|
||||||
|
|
||||||
if (notifications.at(i).rect.y == notifications.at(i).y - notifications.at(i).travelDist)
|
if (notifications[i].rect.y == notifications[i].y - notifications[i].travelDist)
|
||||||
{
|
{
|
||||||
notifications.at(i).state = ns_finished;
|
notifications[i].state = ns_finished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications.at(i).sprite->setRect(notifications.at(i).rect);
|
notifications[i].sprite->setRect(notifications[i].rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearFinishedNotifications();
|
clearFinishedNotifications();
|
||||||
@@ -114,10 +114,10 @@ void Notify::clearFinishedNotifications()
|
|||||||
{
|
{
|
||||||
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
for (int i = (int)notifications.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (notifications.at(i).state == ns_finished)
|
if (notifications[i].state == ns_finished)
|
||||||
{
|
{
|
||||||
delete notifications.at(i).sprite;
|
delete notifications[i].sprite;
|
||||||
delete notifications.at(i).texture;
|
delete notifications[i].texture;
|
||||||
notifications.erase(notifications.begin() + i);
|
notifications.erase(notifications.begin() + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ void Screen::renderSpectrumFade()
|
|||||||
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
|
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
|
||||||
const int max = spectrumColor.size() - 1;
|
const int max = spectrumColor.size() - 1;
|
||||||
const int index = max + (0 - max) * step;
|
const int index = max + (0 - max) * step;
|
||||||
const color_t c = spectrumColor.at(index);
|
const color_t c = spectrumColor[index];
|
||||||
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
|
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ void Credits::fillTexture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el corazón
|
// Escribe el corazón
|
||||||
const int textLenght = text->lenght(texts.at(22).label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
const int textLenght = text->lenght(texts[22].label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
||||||
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
|
const int posX = ((PLAY_AREA_WIDTH - textLenght) / 2) + textLenght;
|
||||||
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));
|
text->writeColored(posX, 176, "}", stringToColor(options->palette, "bright_red"));
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Item::~Item()
|
|||||||
void Item::render()
|
void Item::render()
|
||||||
{
|
{
|
||||||
const int index = (counter / colorChangeSpeed) % color.size();
|
const int index = (counter / colorChangeSpeed) % color.size();
|
||||||
sprite->getTexture()->setColor(color.at(index).r, color.at(index).g, color.at(index).b);
|
sprite->getTexture()->setColor(color[index].r, color[index].g, color[index].b);
|
||||||
sprite->render();
|
sprite->render();
|
||||||
sprite->getTexture()->setColor(255, 255, 255);
|
sprite->getTexture()->setColor(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1);
|
sprite.back()->setSpriteClip(0, i, texture->getWidth(), 1);
|
||||||
if (i % 2 == 0)
|
if (i % 2 == 0)
|
||||||
{
|
{
|
||||||
sprite.at(i)->setPosX(256 + (i * 3));
|
sprite[i]->setPosX(256 + (i * 3));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite.at(i)->setPosX(-181 - (i * 3));
|
sprite[i]->setPosX(-181 - (i * 3));
|
||||||
}
|
}
|
||||||
sprite.at(i)->setPosY(83 + i);
|
sprite[i]->setPosY(83 + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
@@ -142,22 +142,22 @@ void Logo::updateJAILGAMES()
|
|||||||
{
|
{
|
||||||
const int speed = 8;
|
const int speed = 8;
|
||||||
const int dest = 37;
|
const int dest = 37;
|
||||||
if (sprite.at(i)->getPosX() != 37)
|
if (sprite[i]->getPosX() != 37)
|
||||||
{
|
{
|
||||||
if (i % 2 == 0)
|
if (i % 2 == 0)
|
||||||
{
|
{
|
||||||
sprite.at(i)->incPosX(-speed);
|
sprite[i]->incPosX(-speed);
|
||||||
if (sprite.at(i)->getPosX() < dest)
|
if (sprite[i]->getPosX() < dest)
|
||||||
{
|
{
|
||||||
sprite.at(i)->setPosX(dest);
|
sprite[i]->setPosX(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprite.at(i)->incPosX(speed);
|
sprite[i]->incPosX(speed);
|
||||||
if (sprite.at(i)->getPosX() > dest)
|
if (sprite[i]->getPosX() > dest)
|
||||||
{
|
{
|
||||||
sprite.at(i)->setPosX(dest);
|
sprite[i]->setPosX(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,72 +173,72 @@ void Logo::updateTextureColors()
|
|||||||
|
|
||||||
if (counter == ini + inc * 0)
|
if (counter == ini + inc * 0)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 1)
|
else if (counter == ini + inc * 1)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 2)
|
else if (counter == ini + inc * 2)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 3)
|
else if (counter == ini + inc * 3)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 4)
|
else if (counter == ini + inc * 4)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 5)
|
else if (counter == ini + inc * 5)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
}
|
}
|
||||||
else if (counter == ini + inc * 6)
|
else if (counter == ini + inc * 6)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == ini + inc * 7)
|
else if (counter == ini + inc * 7)
|
||||||
{
|
{
|
||||||
texture2->setColor(color.at(7).r, color.at(7).g, color.at(7).b);
|
texture2->setColor(color[7].r, color[7].g, color[7].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (counter == initFade + inc * 0)
|
else if (counter == initFade + inc * 0)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
texture->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
texture2->setColor(color.at(6).r, color.at(6).g, color.at(6).b);
|
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 1)
|
else if (counter == initFade + inc * 1)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
texture->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
texture2->setColor(color.at(5).r, color.at(5).g, color.at(5).b);
|
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 2)
|
else if (counter == initFade + inc * 2)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
texture->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
texture2->setColor(color.at(4).r, color.at(4).g, color.at(4).b);
|
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 3)
|
else if (counter == initFade + inc * 3)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
texture->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
texture2->setColor(color.at(3).r, color.at(3).g, color.at(3).b);
|
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 4)
|
else if (counter == initFade + inc * 4)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
texture->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
texture2->setColor(color.at(2).r, color.at(2).g, color.at(2).b);
|
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 5)
|
else if (counter == initFade + inc * 5)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
texture->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
texture2->setColor(color.at(1).r, color.at(1).g, color.at(1).b);
|
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||||
}
|
}
|
||||||
else if (counter == initFade + inc * 6)
|
else if (counter == initFade + inc * 6)
|
||||||
{
|
{
|
||||||
texture->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
texture->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
texture2->setColor(color.at(0).r, color.at(0).g, color.at(0).b);
|
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
102
source/room.cpp
102
source/room.cpp
@@ -548,13 +548,13 @@ void Room::fillMapTexture()
|
|||||||
// Al cargar el mapa en memoria, se resta uno, por tanto los tiles vacios son -1
|
// Al cargar el mapa en memoria, se resta uno, por tanto los tiles vacios son -1
|
||||||
// Tampoco hay que dibujar los tiles animados que estan en la fila 19 (indices)
|
// Tampoco hay que dibujar los tiles animados que estan en la fila 19 (indices)
|
||||||
const int index = (y * mapWidth) + x;
|
const int index = (y * mapWidth) + x;
|
||||||
const bool a = (tileMap.at(index) >= 18 * tileSetWidth) && (tileMap.at(index) < 19 * tileSetWidth);
|
const bool a = (tileMap[index] >= 18 * tileSetWidth) && (tileMap[index] < 19 * tileSetWidth);
|
||||||
const bool b = tileMap.at(index) > -1;
|
const bool b = tileMap[index] > -1;
|
||||||
|
|
||||||
if (b && !a)
|
if (b && !a)
|
||||||
{
|
{
|
||||||
clip.x = (tileMap.at(index) % tileSetWidth) * tileSize;
|
clip.x = (tileMap[index] % tileSetWidth) * tileSize;
|
||||||
clip.y = (tileMap.at(index) / tileSetWidth) * tileSize;
|
clip.y = (tileMap[index] / tileSetWidth) * tileSize;
|
||||||
texture->render(renderer, x * tileSize, y * tileSize, &clip);
|
texture->render(renderer, x * tileSize, y * tileSize, &clip);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -763,37 +763,37 @@ tile_e Room::getTile(int index)
|
|||||||
if (onRange)
|
if (onRange)
|
||||||
{
|
{
|
||||||
// Las filas 0-8 son de tiles t_wall
|
// Las filas 0-8 son de tiles t_wall
|
||||||
if ((tileMap.at(index) >= 0) && (tileMap.at(index) < 9 * tileSetWidth))
|
if ((tileMap[index] >= 0) && (tileMap[index] < 9 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_wall;
|
return t_wall;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Las filas 9-17 son de tiles t_passable
|
// Las filas 9-17 son de tiles t_passable
|
||||||
else if ((tileMap.at(index) >= 9 * tileSetWidth) && (tileMap.at(index) < 18 * tileSetWidth))
|
else if ((tileMap[index] >= 9 * tileSetWidth) && (tileMap[index] < 18 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_passable;
|
return t_passable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Las filas 18-20 es de tiles t_animated
|
// Las filas 18-20 es de tiles t_animated
|
||||||
else if ((tileMap.at(index) >= 18 * tileSetWidth) && (tileMap.at(index) < 21 * tileSetWidth))
|
else if ((tileMap[index] >= 18 * tileSetWidth) && (tileMap[index] < 21 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_animated;
|
return t_animated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La fila 21 es de tiles t_slope_r
|
// La fila 21 es de tiles t_slope_r
|
||||||
else if ((tileMap.at(index) >= 21 * tileSetWidth) && (tileMap.at(index) < 22 * tileSetWidth))
|
else if ((tileMap[index] >= 21 * tileSetWidth) && (tileMap[index] < 22 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_slope_r;
|
return t_slope_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La fila 22 es de tiles t_slope_l
|
// La fila 22 es de tiles t_slope_l
|
||||||
else if ((tileMap.at(index) >= 22 * tileSetWidth) && (tileMap.at(index) < 23 * tileSetWidth))
|
else if ((tileMap[index] >= 22 * tileSetWidth) && (tileMap[index] < 23 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_slope_l;
|
return t_slope_l;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La fila 23 es de tiles t_kill
|
// La fila 23 es de tiles t_kill
|
||||||
else if ((tileMap.at(index) >= 23 * tileSetWidth) && (tileMap.at(index) < 24 * tileSetWidth))
|
else if ((tileMap[index] >= 23 * tileSetWidth) && (tileMap[index] < 24 * tileSetWidth))
|
||||||
{
|
{
|
||||||
return t_kill;
|
return t_kill;
|
||||||
}
|
}
|
||||||
@@ -820,10 +820,10 @@ bool Room::itemCollision(SDL_Rect &rect)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < (int)items.size(); ++i)
|
for (int i = 0; i < (int)items.size(); ++i)
|
||||||
{
|
{
|
||||||
if (checkCollision(rect, items.at(i)->getCollider()))
|
if (checkCollision(rect, items[i]->getCollider()))
|
||||||
{
|
{
|
||||||
itemTracker->addItem(name, items.at(i)->getPos());
|
itemTracker->addItem(name, items[i]->getPos());
|
||||||
delete items.at(i);
|
delete items[i];
|
||||||
items.erase(items.begin() + i);
|
items.erase(items.begin() + i);
|
||||||
JA_PlaySound(itemSound);
|
JA_PlaySound(itemSound);
|
||||||
*itemsPicked = *itemsPicked + 1;
|
*itemsPicked = *itemsPicked + 1;
|
||||||
@@ -955,14 +955,14 @@ void Room::setBottomSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
h_line_t line;
|
h_line_t line;
|
||||||
line.x1 = (tile.at(i) % mapWidth) * tileSize;
|
line.x1 = (tile[i] % mapWidth) * tileSize;
|
||||||
line.y = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
|
line.y = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
while (tile.at(i) == tile.at(i - 1) + 1)
|
while (tile[i] == tile[i - 1] + 1)
|
||||||
{
|
{
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
@@ -973,11 +973,11 @@ void Room::setBottomSurfaces()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
|
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
bottomSurfaces.push_back(line);
|
bottomSurfaces.push_back(line);
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
if (tile.at(i) == -1)
|
if (tile[i] == -1)
|
||||||
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -1018,14 +1018,14 @@ void Room::setTopSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
h_line_t line;
|
h_line_t line;
|
||||||
line.x1 = (tile.at(i) % mapWidth) * tileSize;
|
line.x1 = (tile[i] % mapWidth) * tileSize;
|
||||||
line.y = (tile.at(i) / mapWidth) * tileSize;
|
line.y = (tile[i] / mapWidth) * tileSize;
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
while (tile.at(i) == tile.at(i - 1) + 1)
|
while (tile[i] == tile[i - 1] + 1)
|
||||||
{
|
{
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
@@ -1036,11 +1036,11 @@ void Room::setTopSurfaces()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
|
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
topSurfaces.push_back(line);
|
topSurfaces.push_back(line);
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
if (tile.at(i) == -1)
|
if (tile[i] == -1)
|
||||||
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -1080,9 +1080,9 @@ void Room::setLeftSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
v_line_t line;
|
v_line_t line;
|
||||||
line.x = (tile.at(i) % mapWidth) * tileSize;
|
line.x = (tile[i] % mapWidth) * tileSize;
|
||||||
line.y1 = ((tile.at(i) / mapWidth) * tileSize);
|
line.y1 = ((tile[i] / mapWidth) * tileSize);
|
||||||
while (tile.at(i) + mapWidth == tile.at(i + 1))
|
while (tile[i] + mapWidth == tile[i + 1])
|
||||||
{
|
{
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
@@ -1090,7 +1090,7 @@ void Room::setLeftSurfaces()
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
line.y2 = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
|
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||||
leftSurfaces.push_back(line);
|
leftSurfaces.push_back(line);
|
||||||
i++;
|
i++;
|
||||||
} while (i < (int)tile.size() - 1);
|
} while (i < (int)tile.size() - 1);
|
||||||
@@ -1128,9 +1128,9 @@ void Room::setRightSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
v_line_t line;
|
v_line_t line;
|
||||||
line.x = ((tile.at(i) % mapWidth) * tileSize) + tileSize - 1;
|
line.x = ((tile[i] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
line.y1 = ((tile.at(i) / mapWidth) * tileSize);
|
line.y1 = ((tile[i] / mapWidth) * tileSize);
|
||||||
while (tile.at(i) + mapWidth == tile.at(i + 1))
|
while (tile[i] + mapWidth == tile[i + 1])
|
||||||
{
|
{
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
@@ -1138,7 +1138,7 @@ void Room::setRightSurfaces()
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
line.y2 = ((tile.at(i) / mapWidth) * tileSize) + tileSize - 1;
|
line.y2 = ((tile[i] / mapWidth) * tileSize) + tileSize - 1;
|
||||||
rightSurfaces.push_back(line);
|
rightSurfaces.push_back(line);
|
||||||
i++;
|
i++;
|
||||||
} while (i < (int)tile.size() - 1);
|
} while (i < (int)tile.size() - 1);
|
||||||
@@ -1165,14 +1165,14 @@ void Room::setLeftSlopes()
|
|||||||
while (found.size() > 0)
|
while (found.size() > 0)
|
||||||
{
|
{
|
||||||
d_line_t line;
|
d_line_t line;
|
||||||
line.x1 = (found.at(0) % mapWidth) * tileSize;
|
line.x1 = (found[0] % mapWidth) * tileSize;
|
||||||
line.y1 = (found.at(0) / mapWidth) * tileSize;
|
line.y1 = (found[0] / mapWidth) * tileSize;
|
||||||
int lookingFor = found.at(0) + mapWidth + 1;
|
int lookingFor = found[0] + mapWidth + 1;
|
||||||
int lastOneFound = found.at(0);
|
int lastOneFound = found[0];
|
||||||
found.erase(found.begin());
|
found.erase(found.begin());
|
||||||
for (int i = 0; i < (int)found.size(); ++i)
|
for (int i = 0; i < (int)found.size(); ++i)
|
||||||
{
|
{
|
||||||
if (found.at(i) == lookingFor)
|
if (found[i] == lookingFor)
|
||||||
{
|
{
|
||||||
lastOneFound = lookingFor;
|
lastOneFound = lookingFor;
|
||||||
lookingFor += mapWidth + 1;
|
lookingFor += mapWidth + 1;
|
||||||
@@ -1206,14 +1206,14 @@ void Room::setRightSlopes()
|
|||||||
while (found.size() > 0)
|
while (found.size() > 0)
|
||||||
{
|
{
|
||||||
d_line_t line;
|
d_line_t line;
|
||||||
line.x1 = ((found.at(0) % mapWidth) * tileSize) + tileSize - 1;
|
line.x1 = ((found[0] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
line.y1 = (found.at(0) / mapWidth) * tileSize;
|
line.y1 = (found[0] / mapWidth) * tileSize;
|
||||||
int lookingFor = found.at(0) + mapWidth - 1;
|
int lookingFor = found[0] + mapWidth - 1;
|
||||||
int lastOneFound = found.at(0);
|
int lastOneFound = found[0];
|
||||||
found.erase(found.begin());
|
found.erase(found.begin());
|
||||||
for (int i = 0; i < (int)found.size(); ++i)
|
for (int i = 0; i < (int)found.size(); ++i)
|
||||||
{
|
{
|
||||||
if (found.at(i) == lookingFor)
|
if (found[i] == lookingFor)
|
||||||
{
|
{
|
||||||
lastOneFound = lookingFor;
|
lastOneFound = lookingFor;
|
||||||
lookingFor += mapWidth - 1;
|
lookingFor += mapWidth - 1;
|
||||||
@@ -1256,14 +1256,14 @@ void Room::setAutoSurfaces()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
h_line_t line;
|
h_line_t line;
|
||||||
line.x1 = (tile.at(i) % mapWidth) * tileSize;
|
line.x1 = (tile[i] % mapWidth) * tileSize;
|
||||||
line.y = (tile.at(i) / mapWidth) * tileSize;
|
line.y = (tile[i] / mapWidth) * tileSize;
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
while (tile.at(i) == tile.at(i - 1) + 1)
|
while (tile[i] == tile[i - 1] + 1)
|
||||||
{
|
{
|
||||||
lastOne = i;
|
lastOne = i;
|
||||||
if (i == (int)tile.size() - 1)
|
if (i == (int)tile.size() - 1)
|
||||||
@@ -1274,11 +1274,11 @@ void Room::setAutoSurfaces()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line.x2 = ((tile.at(lastOne) % mapWidth) * tileSize) + tileSize - 1;
|
line.x2 = ((tile[lastOne] % mapWidth) * tileSize) + tileSize - 1;
|
||||||
autoSurfaces.push_back(line);
|
autoSurfaces.push_back(line);
|
||||||
if (i <= (int)tile.size() - 1)
|
if (i <= (int)tile.size() - 1)
|
||||||
{
|
{
|
||||||
if (tile.at(i) == -1)
|
if (tile[i] == -1)
|
||||||
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
{ // Si el siguiente elemento es un separador, hay que saltarlo
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -1299,9 +1299,9 @@ void Room::setAnimatedTiles()
|
|||||||
const int x = (i % mapWidth) * tileSize;
|
const int x = (i % mapWidth) * tileSize;
|
||||||
const int y = (i / mapWidth) * tileSize;
|
const int y = (i / mapWidth) * tileSize;
|
||||||
|
|
||||||
// TileMap.at(i) es el tile a poner
|
// TileMap[i] es el tile a poner
|
||||||
const int xc = (tileMap.at(i) % tileSetWidth) * tileSize;
|
const int xc = (tileMap[i] % tileSetWidth) * tileSize;
|
||||||
const int yc = (tileMap.at(i) / tileSetWidth) * tileSize;
|
const int yc = (tileMap[i] / tileSetWidth) * tileSize;
|
||||||
|
|
||||||
aTile_t at;
|
aTile_t at;
|
||||||
at.sprite = new Sprite(x, y, 8, 8, texture, renderer);
|
at.sprite = new Sprite(x, y, 8, 8, texture, renderer);
|
||||||
@@ -1532,7 +1532,7 @@ void Room::openTheJail()
|
|||||||
// Abre las puertas
|
// Abre las puertas
|
||||||
const int tileA = 16 + (13 * 32);
|
const int tileA = 16 + (13 * 32);
|
||||||
const int tileB = 16 + (14 * 32);
|
const int tileB = 16 + (14 * 32);
|
||||||
tileMap.at(tileA) = -1;
|
tileMap[tileA] = -1;
|
||||||
tileMap.at(tileB) = -1;
|
tileMap[tileB] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user