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