Movidos los archivos de clases comunes a la carpeta common
This commit is contained in:
7
Makefile
7
Makefile
@@ -1,16 +1,17 @@
|
||||
executable = coffee_crisis
|
||||
source = source/*.cpp source/common/*.cpp
|
||||
|
||||
windows:
|
||||
@echo off
|
||||
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++ -Wl,-subsystem,windows -o bin/$(executable).exe
|
||||
g++ $(source) -std=c++11 -Wall -O2 -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
|
||||
macos:
|
||||
mkdir -p bin
|
||||
g++ source/*.cpp -std=c++11 -Wall -O2 -lSDL2 -ffunction-sections -fdata-sections -o bin/$(executable)_macos
|
||||
g++ $(source) -std=c++11 -Wall -O2 -lSDL2 -ffunction-sections -fdata-sections -o bin/$(executable)_macos
|
||||
linux:
|
||||
mkdir -p bin
|
||||
g++ source/*.cpp -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o bin/$(executable)_linux
|
||||
g++ $(source) -std=c++11 -Wall -Os -lSDL2 -ffunction-sections -fdata-sections -Wl,--gc-sections -o bin/$(executable)_linux
|
||||
strip -s -R .comment -R .gnu.version bin/$(executable)_linux --strip-unneeded
|
||||
opendingux:
|
||||
mkdir -p bin
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "utils.h"
|
||||
#include "animatedsprite.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/animatedsprite.h"
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
std::vector<float> h; // Vector con los valores de zoom para el alto del globo
|
||||
};
|
||||
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
AnimatedSprite *sprite; // Sprite del objeto globo
|
||||
|
||||
// Variables
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "utils.h"
|
||||
#include "sprite.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/sprite.h"
|
||||
|
||||
#ifndef BULLET_H
|
||||
#define BULLET_H
|
||||
@@ -20,7 +20,7 @@
|
||||
class Bullet
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
Sprite *sprite; // Sprite con los graficos y métodos de pintado
|
||||
|
||||
// Variables
|
||||
|
||||
@@ -1,92 +1,92 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "movingsprite.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef ANIMATEDSPRITE_H
|
||||
#define ANIMATEDSPRITE_H
|
||||
|
||||
// Clase AnimatedSprite
|
||||
class AnimatedSprite : public MovingSprite
|
||||
{
|
||||
private:
|
||||
struct t_animation
|
||||
{
|
||||
std::string name; // Nombre de la animacion
|
||||
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
|
||||
int speed; // Velocidad de la animación
|
||||
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
|
||||
bool completed; // Indica si ha finalizado la animación
|
||||
int currentFrame; // Frame actual
|
||||
int counter; // Contador para las animaciones
|
||||
};
|
||||
std::vector<t_animation> animation; // Vector con las diferentes animaciones
|
||||
int currentAnimation; // Animacion activa
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
AnimatedSprite(LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
||||
|
||||
// Destructor
|
||||
~AnimatedSprite();
|
||||
|
||||
// Calcula el frame correspondiente a la animación actual
|
||||
void animate();
|
||||
|
||||
// Establece el frame actual de la animación
|
||||
void setCurrentFrame(int num);
|
||||
|
||||
// Establece el valor del contador
|
||||
void setAnimationCounter(std::string name, int num);
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void setAnimationSpeed(std::string name, int speed);
|
||||
void setAnimationSpeed(int index, int speed);
|
||||
|
||||
// Establece el frame al que vuelve la animación al finalizar
|
||||
void setAnimationLoop(std::string name, int loop);
|
||||
void setAnimationLoop(int index, int loop);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAnimationCompleted(std::string name, bool value);
|
||||
void setAnimationCompleted(int index, bool value);
|
||||
|
||||
// Comprueba si ha terminado la animación
|
||||
bool animationIsCompleted();
|
||||
|
||||
// Devuelve el rectangulo de una animación y frame concreto
|
||||
SDL_Rect getAnimationClip(std::string name, Uint8 index);
|
||||
SDL_Rect getAnimationClip(int indexA, Uint8 indexF);
|
||||
|
||||
// Obtiene el indice de la animación a partir del nombre
|
||||
int getIndex(std::string name);
|
||||
|
||||
// Carga la animación desde un fichero
|
||||
bool loadFromFile(std::string filePath);
|
||||
|
||||
// Carga la animación desde un vector
|
||||
bool loadFromVector(std::vector<std::string> *source);
|
||||
|
||||
// Establece la animacion actual
|
||||
void setCurrentAnimation(std::string name = "default");
|
||||
void setCurrentAnimation(int index = 0);
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void update();
|
||||
|
||||
// OLD - Establece el rectangulo para un frame de una animación
|
||||
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void setAnimationCounter(int value);
|
||||
|
||||
// Reinicia la animación
|
||||
void resetAnimation();
|
||||
};
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "movingsprite.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#ifndef ANIMATEDSPRITE_H
|
||||
#define ANIMATEDSPRITE_H
|
||||
|
||||
// Clase AnimatedSprite
|
||||
class AnimatedSprite : public MovingSprite
|
||||
{
|
||||
private:
|
||||
struct t_animation
|
||||
{
|
||||
std::string name; // Nombre de la animacion
|
||||
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
|
||||
int speed; // Velocidad de la animación
|
||||
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
|
||||
bool completed; // Indica si ha finalizado la animación
|
||||
int currentFrame; // Frame actual
|
||||
int counter; // Contador para las animaciones
|
||||
};
|
||||
std::vector<t_animation> animation; // Vector con las diferentes animaciones
|
||||
int currentAnimation; // Animacion activa
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
AnimatedSprite(LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
||||
|
||||
// Destructor
|
||||
~AnimatedSprite();
|
||||
|
||||
// Calcula el frame correspondiente a la animación actual
|
||||
void animate();
|
||||
|
||||
// Establece el frame actual de la animación
|
||||
void setCurrentFrame(int num);
|
||||
|
||||
// Establece el valor del contador
|
||||
void setAnimationCounter(std::string name, int num);
|
||||
|
||||
// Establece la velocidad de una animación
|
||||
void setAnimationSpeed(std::string name, int speed);
|
||||
void setAnimationSpeed(int index, int speed);
|
||||
|
||||
// Establece el frame al que vuelve la animación al finalizar
|
||||
void setAnimationLoop(std::string name, int loop);
|
||||
void setAnimationLoop(int index, int loop);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAnimationCompleted(std::string name, bool value);
|
||||
void setAnimationCompleted(int index, bool value);
|
||||
|
||||
// Comprueba si ha terminado la animación
|
||||
bool animationIsCompleted();
|
||||
|
||||
// Devuelve el rectangulo de una animación y frame concreto
|
||||
SDL_Rect getAnimationClip(std::string name, Uint8 index);
|
||||
SDL_Rect getAnimationClip(int indexA, Uint8 indexF);
|
||||
|
||||
// Obtiene el indice de la animación a partir del nombre
|
||||
int getIndex(std::string name);
|
||||
|
||||
// Carga la animación desde un fichero
|
||||
bool loadFromFile(std::string filePath);
|
||||
|
||||
// Carga la animación desde un vector
|
||||
bool loadFromVector(std::vector<std::string> *source);
|
||||
|
||||
// Establece la animacion actual
|
||||
void setCurrentAnimation(std::string name = "default");
|
||||
void setCurrentAnimation(int index = 0);
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void update();
|
||||
|
||||
// OLD - Establece el rectangulo para un frame de una animación
|
||||
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
|
||||
|
||||
// OLD - Establece el contador para todas las animaciones
|
||||
void setAnimationCounter(int value);
|
||||
|
||||
// Reinicia la animación
|
||||
void resetAnimation();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,90 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#define INPUT_NULL 0
|
||||
#define INPUT_UP 1
|
||||
#define INPUT_DOWN 2
|
||||
#define INPUT_LEFT 3
|
||||
#define INPUT_RIGHT 4
|
||||
#define INPUT_ACCEPT 5
|
||||
#define INPUT_CANCEL 6
|
||||
#define INPUT_BUTTON_1 7
|
||||
#define INPUT_BUTTON_2 8
|
||||
#define INPUT_BUTTON_3 9
|
||||
#define INPUT_BUTTON_4 10
|
||||
#define INPUT_BUTTON_5 11
|
||||
#define INPUT_BUTTON_6 12
|
||||
#define INPUT_BUTTON_7 13
|
||||
#define INPUT_BUTTON_8 14
|
||||
#define INPUT_BUTTON_PAUSE 15
|
||||
#define INPUT_BUTTON_ESCAPE 16
|
||||
|
||||
#define REPEAT_TRUE true
|
||||
#define REPEAT_FALSE false
|
||||
|
||||
#define INPUT_USE_KEYBOARD 0
|
||||
#define INPUT_USE_GAMECONTROLLER 1
|
||||
#define INPUT_USE_ANY 2
|
||||
|
||||
// Clase Input
|
||||
class Input
|
||||
{
|
||||
private:
|
||||
struct keyBindings_t
|
||||
{
|
||||
Uint8 scancode; // Scancode asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
|
||||
struct GameControllerBindings_t
|
||||
{
|
||||
SDL_GameControllerButton button; // GameControllerButton asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
|
||||
std::vector<keyBindings_t> keyBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
std::vector<GameControllerBindings_t> gameControllerBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos conectados
|
||||
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
|
||||
bool discoverGameController();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
|
||||
// Destructor
|
||||
~Input();
|
||||
|
||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||
void bindKey(Uint8 input, SDL_Scancode code);
|
||||
|
||||
// Asigna uno de los posibles inputs a un botón del mando
|
||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
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
|
||||
bool gameControllerFound();
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
int getNumControllers();
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string getControllerName(int index);
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
#define INPUT_NULL 0
|
||||
#define INPUT_UP 1
|
||||
#define INPUT_DOWN 2
|
||||
#define INPUT_LEFT 3
|
||||
#define INPUT_RIGHT 4
|
||||
#define INPUT_ACCEPT 5
|
||||
#define INPUT_CANCEL 6
|
||||
#define INPUT_BUTTON_1 7
|
||||
#define INPUT_BUTTON_2 8
|
||||
#define INPUT_BUTTON_3 9
|
||||
#define INPUT_BUTTON_4 10
|
||||
#define INPUT_BUTTON_5 11
|
||||
#define INPUT_BUTTON_6 12
|
||||
#define INPUT_BUTTON_7 13
|
||||
#define INPUT_BUTTON_8 14
|
||||
#define INPUT_BUTTON_PAUSE 15
|
||||
#define INPUT_BUTTON_ESCAPE 16
|
||||
|
||||
#define REPEAT_TRUE true
|
||||
#define REPEAT_FALSE false
|
||||
|
||||
#define INPUT_USE_KEYBOARD 0
|
||||
#define INPUT_USE_GAMECONTROLLER 1
|
||||
#define INPUT_USE_ANY 2
|
||||
|
||||
// Clase Input
|
||||
class Input
|
||||
{
|
||||
private:
|
||||
struct keyBindings_t
|
||||
{
|
||||
Uint8 scancode; // Scancode asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
|
||||
struct GameControllerBindings_t
|
||||
{
|
||||
SDL_GameControllerButton button; // GameControllerButton asociado
|
||||
bool active; // Indica si está activo
|
||||
};
|
||||
|
||||
std::vector<keyBindings_t> keyBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
std::vector<GameControllerBindings_t> gameControllerBindings; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
std::vector<SDL_GameController *> connectedControllers; // Vector con todos los mandos conectados
|
||||
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
|
||||
bool discoverGameController();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Input(std::string file);
|
||||
|
||||
// Destructor
|
||||
~Input();
|
||||
|
||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||
void bindKey(Uint8 input, SDL_Scancode code);
|
||||
|
||||
// Asigna uno de los posibles inputs a un botón del mando
|
||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
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
|
||||
bool gameControllerFound();
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
int getNumControllers();
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string getControllerName(int index);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,191 +1,191 @@
|
||||
|
||||
#include "ltexture.h"
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
// Constructor
|
||||
LTexture::LTexture(SDL_Renderer *renderer, std::string path)
|
||||
{
|
||||
// Copia punteros
|
||||
this->renderer = renderer;
|
||||
this->path = path;
|
||||
|
||||
// Inicializa
|
||||
texture = nullptr;
|
||||
width = 0;
|
||||
height = 0;
|
||||
|
||||
// Carga el fichero en la textura
|
||||
if (path != "")
|
||||
{
|
||||
loadFromFile(path, renderer);
|
||||
}
|
||||
}
|
||||
|
||||
// Destructor
|
||||
LTexture::~LTexture()
|
||||
{
|
||||
// Libera memoria
|
||||
unload();
|
||||
}
|
||||
|
||||
// Carga una imagen desde un fichero
|
||||
bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
|
||||
{
|
||||
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
||||
int req_format = STBI_rgb_alpha;
|
||||
int width, height, orig_format;
|
||||
unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format);
|
||||
if (data == nullptr)
|
||||
{
|
||||
SDL_Log("Loading image failed: %s", stbi_failure_reason());
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Image loaded: %s\n", filename.c_str());
|
||||
}
|
||||
|
||||
int depth, pitch;
|
||||
Uint32 pixel_format;
|
||||
if (req_format == STBI_rgb)
|
||||
{
|
||||
depth = 24;
|
||||
pitch = 3 * width; // 3 bytes por pixel * pixels per linea
|
||||
pixel_format = SDL_PIXELFORMAT_RGB24;
|
||||
}
|
||||
else
|
||||
{ // STBI_rgb_alpha (RGBA)
|
||||
depth = 32;
|
||||
pitch = 4 * width;
|
||||
pixel_format = SDL_PIXELFORMAT_RGBA32;
|
||||
}
|
||||
|
||||
// Limpia
|
||||
unload();
|
||||
|
||||
// La textura final
|
||||
SDL_Texture *newTexture = nullptr;
|
||||
|
||||
// Carga la imagen desde una ruta específica
|
||||
SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format);
|
||||
if (loadedSurface == nullptr)
|
||||
{
|
||||
printf("Unable to load image %s!\n", path.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Crea la textura desde los pixels de la surface
|
||||
newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
|
||||
if (newTexture == nullptr)
|
||||
{
|
||||
printf("Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Obtiene las dimensiones de la imagen
|
||||
this->width = loadedSurface->w;
|
||||
this->height = loadedSurface->h;
|
||||
}
|
||||
|
||||
// Elimina la textura cargada
|
||||
SDL_FreeSurface(loadedSurface);
|
||||
}
|
||||
|
||||
// Return success
|
||||
texture = newTexture;
|
||||
return texture != nullptr;
|
||||
}
|
||||
|
||||
// Crea una textura en blanco
|
||||
bool LTexture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess access)
|
||||
{
|
||||
// Crea una textura sin inicializar
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
|
||||
if (texture == nullptr)
|
||||
{
|
||||
printf("Unable to create blank texture! SDL Error: %s\n", SDL_GetError());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
return texture != nullptr;
|
||||
}
|
||||
|
||||
// Libera la memoria de la textura
|
||||
void LTexture::unload()
|
||||
{
|
||||
// Libera la textura si existe
|
||||
if (texture != nullptr)
|
||||
{
|
||||
SDL_DestroyTexture(texture);
|
||||
texture = nullptr;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el color para la modulacion
|
||||
void LTexture::setColor(Uint8 red, Uint8 green, Uint8 blue)
|
||||
{
|
||||
SDL_SetTextureColorMod(texture, red, green, blue);
|
||||
}
|
||||
|
||||
// Establece el blending
|
||||
void LTexture::setBlendMode(SDL_BlendMode blending)
|
||||
{
|
||||
SDL_SetTextureBlendMode(texture, blending);
|
||||
}
|
||||
|
||||
// Establece el alpha para la modulación
|
||||
void LTexture::setAlpha(Uint8 alpha)
|
||||
{
|
||||
SDL_SetTextureAlphaMod(texture, alpha);
|
||||
}
|
||||
|
||||
// Renderiza la textura en un punto específico
|
||||
void LTexture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, float zoomW, float zoomH, double angle, SDL_Point *center, SDL_RendererFlip flip)
|
||||
{
|
||||
// Establece el destino de renderizado en la pantalla
|
||||
SDL_Rect renderQuad = {x, y, width, height};
|
||||
|
||||
// Obtiene las dimesiones del clip de renderizado
|
||||
if (clip != nullptr)
|
||||
{
|
||||
renderQuad.w = clip->w;
|
||||
renderQuad.h = clip->h;
|
||||
}
|
||||
|
||||
renderQuad.w = renderQuad.w * zoomW;
|
||||
renderQuad.h = renderQuad.h * zoomH;
|
||||
|
||||
// Renderiza a pantalla
|
||||
SDL_RenderCopyEx(renderer, texture, clip, &renderQuad, angle, center, flip);
|
||||
}
|
||||
|
||||
// Establece la textura como objetivo de renderizado
|
||||
void LTexture::setAsRenderTarget(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_SetRenderTarget(renderer, texture);
|
||||
}
|
||||
|
||||
// Obtiene el ancho de la imagen
|
||||
int LTexture::getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
// Obtiene el alto de la imagen
|
||||
int LTexture::getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
// Recarga la textura
|
||||
bool LTexture::reLoad()
|
||||
{
|
||||
return loadFromFile(path, renderer);
|
||||
|
||||
#include "ltexture.h"
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
// Constructor
|
||||
LTexture::LTexture(SDL_Renderer *renderer, std::string path)
|
||||
{
|
||||
// Copia punteros
|
||||
this->renderer = renderer;
|
||||
this->path = path;
|
||||
|
||||
// Inicializa
|
||||
texture = nullptr;
|
||||
width = 0;
|
||||
height = 0;
|
||||
|
||||
// Carga el fichero en la textura
|
||||
if (path != "")
|
||||
{
|
||||
loadFromFile(path, renderer);
|
||||
}
|
||||
}
|
||||
|
||||
// Destructor
|
||||
LTexture::~LTexture()
|
||||
{
|
||||
// Libera memoria
|
||||
unload();
|
||||
}
|
||||
|
||||
// Carga una imagen desde un fichero
|
||||
bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
|
||||
{
|
||||
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
||||
int req_format = STBI_rgb_alpha;
|
||||
int width, height, orig_format;
|
||||
unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format);
|
||||
if (data == nullptr)
|
||||
{
|
||||
SDL_Log("Loading image failed: %s", stbi_failure_reason());
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Image loaded: %s\n", filename.c_str());
|
||||
}
|
||||
|
||||
int depth, pitch;
|
||||
Uint32 pixel_format;
|
||||
if (req_format == STBI_rgb)
|
||||
{
|
||||
depth = 24;
|
||||
pitch = 3 * width; // 3 bytes por pixel * pixels per linea
|
||||
pixel_format = SDL_PIXELFORMAT_RGB24;
|
||||
}
|
||||
else
|
||||
{ // STBI_rgb_alpha (RGBA)
|
||||
depth = 32;
|
||||
pitch = 4 * width;
|
||||
pixel_format = SDL_PIXELFORMAT_RGBA32;
|
||||
}
|
||||
|
||||
// Limpia
|
||||
unload();
|
||||
|
||||
// La textura final
|
||||
SDL_Texture *newTexture = nullptr;
|
||||
|
||||
// Carga la imagen desde una ruta específica
|
||||
SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format);
|
||||
if (loadedSurface == nullptr)
|
||||
{
|
||||
printf("Unable to load image %s!\n", path.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Crea la textura desde los pixels de la surface
|
||||
newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
|
||||
if (newTexture == nullptr)
|
||||
{
|
||||
printf("Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Obtiene las dimensiones de la imagen
|
||||
this->width = loadedSurface->w;
|
||||
this->height = loadedSurface->h;
|
||||
}
|
||||
|
||||
// Elimina la textura cargada
|
||||
SDL_FreeSurface(loadedSurface);
|
||||
}
|
||||
|
||||
// Return success
|
||||
texture = newTexture;
|
||||
return texture != nullptr;
|
||||
}
|
||||
|
||||
// Crea una textura en blanco
|
||||
bool LTexture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess access)
|
||||
{
|
||||
// Crea una textura sin inicializar
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, access, width, height);
|
||||
if (texture == nullptr)
|
||||
{
|
||||
printf("Unable to create blank texture! SDL Error: %s\n", SDL_GetError());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
return texture != nullptr;
|
||||
}
|
||||
|
||||
// Libera la memoria de la textura
|
||||
void LTexture::unload()
|
||||
{
|
||||
// Libera la textura si existe
|
||||
if (texture != nullptr)
|
||||
{
|
||||
SDL_DestroyTexture(texture);
|
||||
texture = nullptr;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Establece el color para la modulacion
|
||||
void LTexture::setColor(Uint8 red, Uint8 green, Uint8 blue)
|
||||
{
|
||||
SDL_SetTextureColorMod(texture, red, green, blue);
|
||||
}
|
||||
|
||||
// Establece el blending
|
||||
void LTexture::setBlendMode(SDL_BlendMode blending)
|
||||
{
|
||||
SDL_SetTextureBlendMode(texture, blending);
|
||||
}
|
||||
|
||||
// Establece el alpha para la modulación
|
||||
void LTexture::setAlpha(Uint8 alpha)
|
||||
{
|
||||
SDL_SetTextureAlphaMod(texture, alpha);
|
||||
}
|
||||
|
||||
// Renderiza la textura en un punto específico
|
||||
void LTexture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, float zoomW, float zoomH, double angle, SDL_Point *center, SDL_RendererFlip flip)
|
||||
{
|
||||
// Establece el destino de renderizado en la pantalla
|
||||
SDL_Rect renderQuad = {x, y, width, height};
|
||||
|
||||
// Obtiene las dimesiones del clip de renderizado
|
||||
if (clip != nullptr)
|
||||
{
|
||||
renderQuad.w = clip->w;
|
||||
renderQuad.h = clip->h;
|
||||
}
|
||||
|
||||
renderQuad.w = renderQuad.w * zoomW;
|
||||
renderQuad.h = renderQuad.h * zoomH;
|
||||
|
||||
// Renderiza a pantalla
|
||||
SDL_RenderCopyEx(renderer, texture, clip, &renderQuad, angle, center, flip);
|
||||
}
|
||||
|
||||
// Establece la textura como objetivo de renderizado
|
||||
void LTexture::setAsRenderTarget(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_SetRenderTarget(renderer, texture);
|
||||
}
|
||||
|
||||
// Obtiene el ancho de la imagen
|
||||
int LTexture::getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
// Obtiene el alto de la imagen
|
||||
int LTexture::getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
// Recarga la textura
|
||||
bool LTexture::reLoad()
|
||||
{
|
||||
return loadFromFile(path, renderer);
|
||||
}
|
||||
@@ -1,61 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#ifndef LTEXTURE_H
|
||||
#define LTEXTURE_H
|
||||
|
||||
// Clase LTexture
|
||||
class LTexture
|
||||
{
|
||||
private:
|
||||
SDL_Texture *texture; // La textura
|
||||
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
|
||||
int width; // Ancho de la imagen
|
||||
int height; // Alto de la imagen
|
||||
std::string path; // Ruta de la imagen de la textura
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
LTexture(SDL_Renderer *renderer, std::string path = "");
|
||||
|
||||
// Destructor
|
||||
~LTexture();
|
||||
|
||||
// Carga una imagen desde un fichero
|
||||
bool loadFromFile(std::string path, SDL_Renderer *renderer);
|
||||
|
||||
// Crea una textura en blanco
|
||||
bool createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess = SDL_TEXTUREACCESS_STREAMING);
|
||||
|
||||
// Libera la memoria de la textura
|
||||
void unload();
|
||||
|
||||
// Establece el color para la modulacion
|
||||
void setColor(Uint8 red, Uint8 green, Uint8 blue);
|
||||
|
||||
// Establece el blending
|
||||
void setBlendMode(SDL_BlendMode blending);
|
||||
|
||||
// Establece el alpha para la modulación
|
||||
void setAlpha(Uint8 alpha);
|
||||
|
||||
// Renderiza la textura en un punto específico
|
||||
void render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip = nullptr, float zoomW = 1, float zoomH = 1, double angle = 0.0, SDL_Point *center = nullptr, SDL_RendererFlip flip = SDL_FLIP_NONE);
|
||||
|
||||
// Establece la textura como objetivo de renderizado
|
||||
void setAsRenderTarget(SDL_Renderer *renderer);
|
||||
|
||||
// Obtiene el ancho de la imagen
|
||||
int getWidth();
|
||||
|
||||
// Obtiene el alto de la imagen
|
||||
int getHeight();
|
||||
|
||||
// Recarga la textura
|
||||
bool reLoad();
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#ifndef LTEXTURE_H
|
||||
#define LTEXTURE_H
|
||||
|
||||
// Clase LTexture
|
||||
class LTexture
|
||||
{
|
||||
private:
|
||||
SDL_Texture *texture; // La textura
|
||||
SDL_Renderer *renderer; // Renderizador donde dibujar la textura
|
||||
int width; // Ancho de la imagen
|
||||
int height; // Alto de la imagen
|
||||
std::string path; // Ruta de la imagen de la textura
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
LTexture(SDL_Renderer *renderer, std::string path = "");
|
||||
|
||||
// Destructor
|
||||
~LTexture();
|
||||
|
||||
// Carga una imagen desde un fichero
|
||||
bool loadFromFile(std::string path, SDL_Renderer *renderer);
|
||||
|
||||
// Crea una textura en blanco
|
||||
bool createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess = SDL_TEXTUREACCESS_STREAMING);
|
||||
|
||||
// Libera la memoria de la textura
|
||||
void unload();
|
||||
|
||||
// Establece el color para la modulacion
|
||||
void setColor(Uint8 red, Uint8 green, Uint8 blue);
|
||||
|
||||
// Establece el blending
|
||||
void setBlendMode(SDL_BlendMode blending);
|
||||
|
||||
// Establece el alpha para la modulación
|
||||
void setAlpha(Uint8 alpha);
|
||||
|
||||
// Renderiza la textura en un punto específico
|
||||
void render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip = nullptr, float zoomW = 1, float zoomH = 1, double angle = 0.0, SDL_Point *center = nullptr, SDL_RendererFlip flip = SDL_FLIP_NONE);
|
||||
|
||||
// Establece la textura como objetivo de renderizado
|
||||
void setAsRenderTarget(SDL_Renderer *renderer);
|
||||
|
||||
// Obtiene el ancho de la imagen
|
||||
int getWidth();
|
||||
|
||||
// Obtiene el alto de la imagen
|
||||
int getHeight();
|
||||
|
||||
// Recarga la textura
|
||||
bool reLoad();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "const.h"
|
||||
#include "../const.h"
|
||||
#include "menu.h"
|
||||
|
||||
// Constructor
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
int a; // Cantidad de transparencia para el rectangulo del selector
|
||||
};
|
||||
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
||||
Text *text; // Texto para poder escribir los items del menu
|
||||
Input *input; // Gestor de eventos de entrada de teclado o gamepad
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "const.h"
|
||||
#include "../const.h"
|
||||
#include "movingsprite.h"
|
||||
|
||||
// Constructor
|
||||
@@ -1,170 +1,170 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "sprite.h"
|
||||
|
||||
#ifndef MOVINGSPRITE_H
|
||||
#define MOVINGSPRITE_H
|
||||
|
||||
// Clase MovingSprite. Añade posicion y velocidad en punto flotante
|
||||
class MovingSprite : public Sprite
|
||||
{
|
||||
protected:
|
||||
float x; // Posición en el eje X
|
||||
float y; // Posición en el eje Y
|
||||
|
||||
float xPrev; // Posición anterior en el eje X
|
||||
float yPrev; // Posición anterior en el eje Y
|
||||
|
||||
float vx; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||
float vy; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||
|
||||
float ax; // Aceleración en el eje X. Variación de la velocidad
|
||||
float ay; // Aceleración en el eje Y. Variación de la velocidad
|
||||
|
||||
float zoomW; // Zoom aplicado a la anchura
|
||||
float zoomH; // Zoom aplicado a la altura
|
||||
|
||||
double angle; // Angulo para dibujarlo
|
||||
bool rotateEnabled; // Indica si ha de rotar
|
||||
int rotateSpeed; // Velocidad de giro
|
||||
double rotateAmount; // Cantidad de grados a girar en cada iteración
|
||||
int counter; // Contador interno
|
||||
SDL_Point *center; // Centro de rotación
|
||||
SDL_RendererFlip currentFlip; // Indica como se voltea el sprite
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||
|
||||
// Destructor
|
||||
~MovingSprite();
|
||||
|
||||
// Mueve el sprite
|
||||
void move();
|
||||
|
||||
// Rota el sprite
|
||||
void rotate();
|
||||
|
||||
// Actualiza las variables internas del objeto
|
||||
void update();
|
||||
|
||||
// Reinicia todas las variables
|
||||
void clear();
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void render();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getPosX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getPosY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getVelX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getVelY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getAccelX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getAccelY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getZoomW();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getZoomH();
|
||||
|
||||
// Obten el valor de la variable
|
||||
double getAngle();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool getRotate();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getRotateSpeed();
|
||||
|
||||
// Establece la posición y el tamaño del objeto
|
||||
void setRect(SDL_Rect rect);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAccelX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAccelY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setZoomW(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setZoomH(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAngle(double vaue);
|
||||
|
||||
// Incrementa el valor de la variable
|
||||
void incAngle(double value);
|
||||
|
||||
// Decrementa el valor de la variable
|
||||
void decAngle(double value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotate(bool value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotateSpeed(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotateAmount(double value);
|
||||
|
||||
// Quita el efecto de rotación y deja el sprite en su angulo inicial.
|
||||
void disableRotate();
|
||||
|
||||
// Cambia el sentido de la rotación
|
||||
void switchRotate();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setFlip(SDL_RendererFlip flip);
|
||||
|
||||
// Gira el sprite horizontalmente
|
||||
void flip();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
SDL_RendererFlip getFlip();
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect getRect();
|
||||
|
||||
// Deshace el último movimiento
|
||||
void undoMove();
|
||||
|
||||
// Deshace el último movimiento en el eje X
|
||||
void undoMoveX();
|
||||
|
||||
// Deshace el último movimiento en el eje Y
|
||||
void undoMoveY();
|
||||
|
||||
// Pone a cero las velocidades de desplacamiento
|
||||
void clearVel();
|
||||
|
||||
// Devuelve el incremento en el eje X en pixels
|
||||
int getIncX();
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "sprite.h"
|
||||
|
||||
#ifndef MOVINGSPRITE_H
|
||||
#define MOVINGSPRITE_H
|
||||
|
||||
// Clase MovingSprite. Añade posicion y velocidad en punto flotante
|
||||
class MovingSprite : public Sprite
|
||||
{
|
||||
protected:
|
||||
float x; // Posición en el eje X
|
||||
float y; // Posición en el eje Y
|
||||
|
||||
float xPrev; // Posición anterior en el eje X
|
||||
float yPrev; // Posición anterior en el eje Y
|
||||
|
||||
float vx; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||
float vy; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||
|
||||
float ax; // Aceleración en el eje X. Variación de la velocidad
|
||||
float ay; // Aceleración en el eje Y. Variación de la velocidad
|
||||
|
||||
float zoomW; // Zoom aplicado a la anchura
|
||||
float zoomH; // Zoom aplicado a la altura
|
||||
|
||||
double angle; // Angulo para dibujarlo
|
||||
bool rotateEnabled; // Indica si ha de rotar
|
||||
int rotateSpeed; // Velocidad de giro
|
||||
double rotateAmount; // Cantidad de grados a girar en cada iteración
|
||||
int counter; // Contador interno
|
||||
SDL_Point *center; // Centro de rotación
|
||||
SDL_RendererFlip currentFlip; // Indica como se voltea el sprite
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
MovingSprite(float x = 0, float y = 0, int w = 0, int h = 0, float velx = 0, float vely = 0, float accelx = 0, float accely = 0, LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||
|
||||
// Destructor
|
||||
~MovingSprite();
|
||||
|
||||
// Mueve el sprite
|
||||
void move();
|
||||
|
||||
// Rota el sprite
|
||||
void rotate();
|
||||
|
||||
// Actualiza las variables internas del objeto
|
||||
void update();
|
||||
|
||||
// Reinicia todas las variables
|
||||
void clear();
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void render();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getPosX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getPosY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getVelX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getVelY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getAccelX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getAccelY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getZoomW();
|
||||
|
||||
// Obten el valor de la variable
|
||||
float getZoomH();
|
||||
|
||||
// Obten el valor de la variable
|
||||
double getAngle();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool getRotate();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
Uint16 getRotateSpeed();
|
||||
|
||||
// Establece la posición y el tamaño del objeto
|
||||
void setRect(SDL_Rect rect);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setVelY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAccelX(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAccelY(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setZoomW(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setZoomH(float value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setAngle(double vaue);
|
||||
|
||||
// Incrementa el valor de la variable
|
||||
void incAngle(double value);
|
||||
|
||||
// Decrementa el valor de la variable
|
||||
void decAngle(double value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotate(bool value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotateSpeed(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRotateAmount(double value);
|
||||
|
||||
// Quita el efecto de rotación y deja el sprite en su angulo inicial.
|
||||
void disableRotate();
|
||||
|
||||
// Cambia el sentido de la rotación
|
||||
void switchRotate();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setFlip(SDL_RendererFlip flip);
|
||||
|
||||
// Gira el sprite horizontalmente
|
||||
void flip();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
SDL_RendererFlip getFlip();
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect getRect();
|
||||
|
||||
// Deshace el último movimiento
|
||||
void undoMove();
|
||||
|
||||
// Deshace el último movimiento en el eje X
|
||||
void undoMoveX();
|
||||
|
||||
// Deshace el último movimiento en el eje Y
|
||||
void undoMoveY();
|
||||
|
||||
// Pone a cero las velocidades de desplacamiento
|
||||
void clearVel();
|
||||
|
||||
// Devuelve el incremento en el eje X en pixels
|
||||
int getIncX();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "const.h"
|
||||
#include "../const.h"
|
||||
#include "smartsprite.h"
|
||||
|
||||
// Constructor
|
||||
@@ -1,76 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "animatedsprite.h"
|
||||
#include "utils.h"
|
||||
#include <vector>
|
||||
|
||||
#ifndef SMARTSPRITE_H
|
||||
#define SMARTSPRITE_H
|
||||
|
||||
// Clase SmartSprite
|
||||
class SmartSprite : public AnimatedSprite
|
||||
{
|
||||
private:
|
||||
// VAriables
|
||||
bool enabled; // Indica si esta habilitado
|
||||
bool onDestination; // Indica si está en el destino
|
||||
int destX; // Posicion de destino en el eje X
|
||||
int destY; // Posicion de destino en el eje Y
|
||||
int enabledCounter; // Contador para deshabilitarlo
|
||||
bool finished; // Indica si ya ha terminado
|
||||
|
||||
// Comprueba el movimiento
|
||||
void checkMove();
|
||||
|
||||
// Comprueba si ha terminado
|
||||
void checkFinished();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
SmartSprite(LTexture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~SmartSprite();
|
||||
|
||||
// Inicializa el objeto
|
||||
void init();
|
||||
|
||||
// Actualiza la posición y comprueba si ha llegado a su destino
|
||||
void update();
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
void render();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isEnabled();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getEnabledCounter();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabledCounter(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setDestX(int x);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setDestY(int y);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getDestX();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getDestY();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isOnDestination();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool hasFinished();
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "animatedsprite.h"
|
||||
#include "utils.h"
|
||||
#include <vector>
|
||||
|
||||
#ifndef SMARTSPRITE_H
|
||||
#define SMARTSPRITE_H
|
||||
|
||||
// Clase SmartSprite
|
||||
class SmartSprite : public AnimatedSprite
|
||||
{
|
||||
private:
|
||||
// VAriables
|
||||
bool enabled; // Indica si esta habilitado
|
||||
bool onDestination; // Indica si está en el destino
|
||||
int destX; // Posicion de destino en el eje X
|
||||
int destY; // Posicion de destino en el eje Y
|
||||
int enabledCounter; // Contador para deshabilitarlo
|
||||
bool finished; // Indica si ya ha terminado
|
||||
|
||||
// Comprueba el movimiento
|
||||
void checkMove();
|
||||
|
||||
// Comprueba si ha terminado
|
||||
void checkFinished();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
SmartSprite(LTexture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~SmartSprite();
|
||||
|
||||
// Inicializa el objeto
|
||||
void init();
|
||||
|
||||
// Actualiza la posición y comprueba si ha llegado a su destino
|
||||
void update();
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
void render();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isEnabled();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getEnabledCounter();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabledCounter(int value);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setDestX(int x);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setDestY(int y);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getDestX();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getDestY();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool isOnDestination();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
bool hasFinished();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,96 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "ltexture.h"
|
||||
|
||||
#ifndef SPRITE_H
|
||||
#define SPRITE_H
|
||||
|
||||
// Clase sprite
|
||||
class Sprite
|
||||
{
|
||||
protected:
|
||||
int x; // Posición en el eje X donde dibujar el sprite
|
||||
int y; // Posición en el eje Y donde dibujar el sprite
|
||||
int w; // Ancho del sprite
|
||||
int h; // Alto del sprite
|
||||
|
||||
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
||||
LTexture *texture; // Textura donde estan todos los dibujos del sprite
|
||||
SDL_Rect spriteClip; // Rectangulo de origen de la textura que se dibujará en pantalla
|
||||
|
||||
bool enabled; // Indica si el sprite esta habilitado
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||
Sprite(SDL_Rect rect, LTexture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Sprite();
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void render();
|
||||
|
||||
// Obten el valor de la variable
|
||||
int getPosX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
int getPosY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
int getWidth();
|
||||
|
||||
// Obten el valor de la variable
|
||||
int getHeight();
|
||||
|
||||
// Establece la posición del objeto
|
||||
void setPos(SDL_Rect rect);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(int x);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosY(int y);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setWidth(int w);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setHeight(int h);
|
||||
|
||||
// Obten el valor de la variable
|
||||
SDL_Rect getSpriteClip();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setSpriteClip(SDL_Rect rect);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setSpriteClip(int x, int y, int w, int h);
|
||||
|
||||
// Obten el valor de la variable
|
||||
LTexture *getTexture();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setTexture(LTexture *texture);
|
||||
|
||||
// Obten el valor de la variable
|
||||
SDL_Renderer *getRenderer();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRenderer(SDL_Renderer *renderer);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabled(bool value);
|
||||
|
||||
// Comprueba si el objeto está habilitado
|
||||
bool isEnabled();
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect getRect();
|
||||
|
||||
// Establece los valores de posición y tamaño del sprite
|
||||
void setRect(SDL_Rect rect);
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "ltexture.h"
|
||||
|
||||
#ifndef SPRITE_H
|
||||
#define SPRITE_H
|
||||
|
||||
// Clase sprite
|
||||
class Sprite
|
||||
{
|
||||
protected:
|
||||
int x; // Posición en el eje X donde dibujar el sprite
|
||||
int y; // Posición en el eje Y donde dibujar el sprite
|
||||
int w; // Ancho del sprite
|
||||
int h; // Alto del sprite
|
||||
|
||||
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
||||
LTexture *texture; // Textura donde estan todos los dibujos del sprite
|
||||
SDL_Rect spriteClip; // Rectangulo de origen de la textura que se dibujará en pantalla
|
||||
|
||||
bool enabled; // Indica si el sprite esta habilitado
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Sprite(int x = 0, int y = 0, int w = 0, int h = 0, LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||
Sprite(SDL_Rect rect, LTexture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Sprite();
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void render();
|
||||
|
||||
// Obten el valor de la variable
|
||||
int getPosX();
|
||||
|
||||
// Obten el valor de la variable
|
||||
int getPosY();
|
||||
|
||||
// Obten el valor de la variable
|
||||
int getWidth();
|
||||
|
||||
// Obten el valor de la variable
|
||||
int getHeight();
|
||||
|
||||
// Establece la posición del objeto
|
||||
void setPos(SDL_Rect rect);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(int x);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosY(int y);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setWidth(int w);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setHeight(int h);
|
||||
|
||||
// Obten el valor de la variable
|
||||
SDL_Rect getSpriteClip();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setSpriteClip(SDL_Rect rect);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setSpriteClip(int x, int y, int w, int h);
|
||||
|
||||
// Obten el valor de la variable
|
||||
LTexture *getTexture();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setTexture(LTexture *texture);
|
||||
|
||||
// Obten el valor de la variable
|
||||
SDL_Renderer *getRenderer();
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setRenderer(SDL_Renderer *renderer);
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setEnabled(bool value);
|
||||
|
||||
// Comprueba si el objeto está habilitado
|
||||
bool isEnabled();
|
||||
|
||||
// Devuelve el rectangulo donde está el sprite
|
||||
SDL_Rect getRect();
|
||||
|
||||
// Establece los valores de posición y tamaño del sprite
|
||||
void setRect(SDL_Rect rect);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,69 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include "sprite.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef TEXT_H
|
||||
#define TEXT_H
|
||||
|
||||
#define TXT_COLOR 1
|
||||
#define TXT_SHADOW 2
|
||||
#define TXT_CENTER 4
|
||||
#define TXT_STROKE 8
|
||||
|
||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
||||
class Text
|
||||
{
|
||||
private:
|
||||
struct offset_t
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
};
|
||||
|
||||
// Objetos
|
||||
Sprite *sprite; // Objeto con los graficos para el texto
|
||||
LTexture *texture; // Textura con los bitmaps del texto
|
||||
|
||||
// Variables
|
||||
int boxWidth; // Anchura de la caja de cada caracter en el png
|
||||
int boxHeight; // Altura de la caja de cada caracter en el png
|
||||
offset_t offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
|
||||
// Inicializa el vector de offsets desde un fichero
|
||||
void initOffsetFromFile(std::string file);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Text();
|
||||
|
||||
// Escribe el texto en pantalla
|
||||
void write(int x, int y, std::string text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, std::string text, color_t color, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void writeShadowed(int x, int y, std::string text, color_t color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto centrado en un punto x
|
||||
void writeCentered(int x, int y, std::string text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe texto con extras
|
||||
void writeDX(Uint8 flags, int x, int y, std::string text, int kerning = 1, color_t textColor = {255, 255, 255}, Uint8 shadowDistance = 1, color_t shadowColor = {0, 0, 0}, int lenght = -1);
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
int lenght(std::string text, int kerning = 1);
|
||||
|
||||
// Devuelve el valor de la variable
|
||||
int getCharacterSize();
|
||||
|
||||
// Recarga la textura
|
||||
void reLoadTexture();
|
||||
};
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include "sprite.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef TEXT_H
|
||||
#define TEXT_H
|
||||
|
||||
#define TXT_COLOR 1
|
||||
#define TXT_SHADOW 2
|
||||
#define TXT_CENTER 4
|
||||
#define TXT_STROKE 8
|
||||
|
||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap
|
||||
class Text
|
||||
{
|
||||
private:
|
||||
struct offset_t
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
};
|
||||
|
||||
// Objetos y punteros
|
||||
Sprite *sprite; // Objeto con los graficos para el texto
|
||||
LTexture *texture; // Textura con los bitmaps del texto
|
||||
|
||||
// Variables
|
||||
int boxWidth; // Anchura de la caja de cada caracter en el png
|
||||
int boxHeight; // Altura de la caja de cada caracter en el png
|
||||
offset_t offset[128]; // Vector con las posiciones y ancho de cada letra
|
||||
|
||||
// Inicializa el vector de offsets desde un fichero
|
||||
void initOffsetFromFile(std::string file);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Text();
|
||||
|
||||
// Escribe el texto en pantalla
|
||||
void write(int x, int y, std::string text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con colores
|
||||
void writeColored(int x, int y, std::string text, color_t color, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void writeShadowed(int x, int y, std::string text, color_t color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe el texto centrado en un punto x
|
||||
void writeCentered(int x, int y, std::string text, int kerning = 1, int lenght = -1);
|
||||
|
||||
// Escribe texto con extras
|
||||
void writeDX(Uint8 flags, int x, int y, std::string text, int kerning = 1, color_t textColor = {255, 255, 255}, Uint8 shadowDistance = 1, color_t shadowColor = {0, 0, 0}, int lenght = -1);
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena
|
||||
int lenght(std::string text, int kerning = 1);
|
||||
|
||||
// Devuelve el valor de la variable
|
||||
int getCharacterSize();
|
||||
|
||||
// Recarga la textura
|
||||
void reLoadTexture();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "const.h"
|
||||
#include "../const.h"
|
||||
#include "writer.h"
|
||||
|
||||
// Constructor
|
||||
@@ -11,7 +11,7 @@
|
||||
class Writer
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
Text *text; // Objeto encargado de escribir el texto
|
||||
|
||||
// Variables
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "utils.h"
|
||||
#include "common/utils.h"
|
||||
#include "lang.h"
|
||||
|
||||
#ifndef CONST_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "const.h"
|
||||
#include "director.h"
|
||||
#include "utils.h"
|
||||
#include "common/utils.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "asset.h"
|
||||
#include "balloon.h"
|
||||
#include "bullet.h"
|
||||
#include "common/asset.h"
|
||||
#include "common/input.h"
|
||||
#include "common/jail_audio.h"
|
||||
#include "common/menu.h"
|
||||
#include "common/movingsprite.h"
|
||||
#include "common/screen.h"
|
||||
#include "common/smartsprite.h"
|
||||
#include "common/sprite.h"
|
||||
#include "common/text.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/writer.h"
|
||||
#include "const.h"
|
||||
#include "fade.h"
|
||||
#include "game.h"
|
||||
#include "input.h"
|
||||
#include "intro.h"
|
||||
#include "item.h"
|
||||
#include "jail_audio.h"
|
||||
#include "logo.h"
|
||||
#include "menu.h"
|
||||
#include "movingsprite.h"
|
||||
#include "player.h"
|
||||
#include "screen.h"
|
||||
#include "smartsprite.h"
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
#include "title.h"
|
||||
#include "utils.h"
|
||||
#include "writer.h"
|
||||
|
||||
#ifndef DIRECTOR_H
|
||||
#define DIRECTOR_H
|
||||
@@ -29,11 +29,10 @@
|
||||
// Textos
|
||||
#define WINDOW_CAPTION "Coffee Crisis"
|
||||
|
||||
// Clase Director
|
||||
class Director
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
SDL_Window *window; // La ventana donde dibujamos
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "ltexture.h"
|
||||
#include "common/ltexture.h"
|
||||
|
||||
#ifndef FADE_H
|
||||
#define FADE_H
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "asset.h"
|
||||
#include "common/asset.h"
|
||||
#include "balloon.h"
|
||||
#include "bullet.h"
|
||||
#include "const.h"
|
||||
#include "fade.h"
|
||||
#include "input.h"
|
||||
#include "common/input.h"
|
||||
#include "item.h"
|
||||
#include "jail_audio.h"
|
||||
#include "menu.h"
|
||||
#include "movingsprite.h"
|
||||
#include "common/jail_audio.h"
|
||||
#include "common/menu.h"
|
||||
#include "common/movingsprite.h"
|
||||
#include "player.h"
|
||||
#include "screen.h"
|
||||
#include "smartsprite.h"
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
#include "utils.h"
|
||||
#include "writer.h"
|
||||
#include "common/screen.h"
|
||||
#include "common/smartsprite.h"
|
||||
#include "common/sprite.h"
|
||||
#include "common/text.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/writer.h"
|
||||
#include <iostream>
|
||||
|
||||
#ifndef GAME_H
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
demoKeys_t dataFile[TOTAL_DEMO_DATA]; // Datos del fichero con los movimientos para la demo
|
||||
};
|
||||
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "asset.h"
|
||||
#include "common/asset.h"
|
||||
#include "const.h"
|
||||
#include "jail_audio.h"
|
||||
#include "screen.h"
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
#include "utils.h"
|
||||
#include "common/jail_audio.h"
|
||||
#include "common/screen.h"
|
||||
#include "common/sprite.h"
|
||||
#include "common/text.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
#ifndef INSTRUCTIONS_H
|
||||
#define INSTRUCTIONS_H
|
||||
@@ -22,7 +22,7 @@ enum mode_e
|
||||
class Instructions
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
std::vector<LTexture *> itemTextures; // Vector con las texturas de los items
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "asset.h"
|
||||
#include "common/asset.h"
|
||||
#include "const.h"
|
||||
#include "jail_audio.h"
|
||||
#include "screen.h"
|
||||
#include "smartsprite.h"
|
||||
#include "utils.h"
|
||||
#include "writer.h"
|
||||
#include "common/jail_audio.h"
|
||||
#include "common/screen.h"
|
||||
#include "common/smartsprite.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/writer.h"
|
||||
#include <vector>
|
||||
|
||||
#ifndef INTRO_H
|
||||
@@ -17,7 +17,7 @@
|
||||
class Intro
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
LTexture *texture; // Textura con los graficos
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "animatedsprite.h"
|
||||
#include "utils.h"
|
||||
#include "common/animatedsprite.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
#ifndef ITEM_H
|
||||
#define ITEM_H
|
||||
@@ -19,7 +19,7 @@
|
||||
class Item
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
AnimatedSprite *sprite; // Sprite con los graficos del objeto
|
||||
|
||||
// Variables
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "asset.h"
|
||||
#include "common/asset.h"
|
||||
#include <string>
|
||||
|
||||
#ifndef LANG_H
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "asset.h"
|
||||
#include "common/asset.h"
|
||||
#include "const.h"
|
||||
#include "jail_audio.h"
|
||||
#include "screen.h"
|
||||
#include "sprite.h"
|
||||
#include "utils.h"
|
||||
#include "common/jail_audio.h"
|
||||
#include "common/screen.h"
|
||||
#include "common/sprite.h"
|
||||
#include "common/utils.h"
|
||||
|
||||
#ifndef LOGO_H
|
||||
#define LOGO_H
|
||||
@@ -15,7 +15,7 @@
|
||||
class Logo
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "utils.h"
|
||||
#include "input.h"
|
||||
#include "asset.h"
|
||||
#include "ltexture.h"
|
||||
#include "animatedsprite.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/input.h"
|
||||
#include "common/asset.h"
|
||||
#include "common/ltexture.h"
|
||||
#include "common/animatedsprite.h"
|
||||
|
||||
#ifndef PLAYER_H
|
||||
#define PLAYER_H
|
||||
@@ -31,7 +31,7 @@
|
||||
class Player
|
||||
{
|
||||
private:
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
AnimatedSprite *headSprite; // Sprite para dibujar la cabeza
|
||||
AnimatedSprite *bodySprite; // Sprite para dibujar el cuerpo
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include "asset.h"
|
||||
#include "common/asset.h"
|
||||
#include "common/input.h"
|
||||
#include "common/jail_audio.h"
|
||||
#include "common/menu.h"
|
||||
#include "common/movingsprite.h"
|
||||
#include "common/screen.h"
|
||||
#include "common/smartsprite.h"
|
||||
#include "common/sprite.h"
|
||||
#include "common/text.h"
|
||||
#include "common/utils.h"
|
||||
#include "const.h"
|
||||
#include "fade.h"
|
||||
#include "game.h"
|
||||
#include "input.h"
|
||||
#include "instructions.h"
|
||||
#include "item.h"
|
||||
#include "jail_audio.h"
|
||||
#include "menu.h"
|
||||
#include "movingsprite.h"
|
||||
#include "screen.h"
|
||||
#include "smartsprite.h"
|
||||
#include "sprite.h"
|
||||
#include "text.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifndef TITLE_H
|
||||
#define TITLE_H
|
||||
@@ -29,7 +29,6 @@
|
||||
// Cantidad de eventos de la pantalla de titulo
|
||||
#define TITLE_TOTAL_EVENTS 2
|
||||
|
||||
// Clase Title
|
||||
class Title
|
||||
{
|
||||
private:
|
||||
@@ -42,7 +41,7 @@ private:
|
||||
bool keyPressed; // Variable para evitar la repetición de teclas en los menus
|
||||
};
|
||||
|
||||
// Objetos
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
|
||||
Reference in New Issue
Block a user