Arreglos y limpieza de código
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#include "balloon.h"
|
#include "balloon.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, LTexture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
||||||
disable();
|
disable();
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/utils.h"
|
|
||||||
#include "common/animatedsprite.h"
|
#include "common/animatedsprite.h"
|
||||||
#include <vector>
|
#include "common/utils.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef BALLOON_H
|
#ifndef BALLOON_H
|
||||||
#define BALLOON_H
|
#define BALLOON_H
|
||||||
@@ -143,7 +143,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, LTexture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Balloon();
|
~Balloon();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *texture, SDL_Renderer *renderer)
|
Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
sprite = new Sprite({x, y, 10, 10}, texture, renderer);
|
sprite = new Sprite({x, y, 10, 10}, texture, renderer);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/utils.h"
|
|
||||||
#include "common/sprite.h"
|
#include "common/sprite.h"
|
||||||
|
#include "common/utils.h"
|
||||||
|
|
||||||
#ifndef BULLET_H
|
#ifndef BULLET_H
|
||||||
#define BULLET_H
|
#define BULLET_H
|
||||||
@@ -39,7 +39,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Bullet(int x, int y, int kind, bool poweredUp, int owner, LTexture *texture, SDL_Renderer *renderer);
|
Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Bullet();
|
~Bullet();
|
||||||
|
|||||||
15
source/common/Makefile
Normal file
15
source/common/Makefile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
executable = jaildoctors_dilemma
|
||||||
|
source = source/*.cpp source/common/*.cpp
|
||||||
|
|
||||||
|
windows:
|
||||||
|
@echo off
|
||||||
|
if not exist bin\ (mkdir bin)
|
||||||
|
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) -std=c++11 -Wall -O2 -lSDL2 -ffunction-sections -fdata-sections -o bin/$(executable)_macos
|
||||||
|
linux:
|
||||||
|
mkdir -p bin
|
||||||
|
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
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "animatedsprite.h"
|
#include "animatedsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
AnimatedSprite::AnimatedSprite(LTexture *texture, SDL_Renderer *renderer, std::string file, std::vector<std::string> *buffer)
|
AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, std::string file, std::vector<std::string> *buffer)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef ANIMATEDSPRITE_H
|
#ifndef ANIMATEDSPRITE_H
|
||||||
#define ANIMATEDSPRITE_H
|
#define ANIMATEDSPRITE_H
|
||||||
@@ -30,7 +30,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
AnimatedSprite(LTexture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, std::string file = "", std::vector<std::string> *buffer = nullptr);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~AnimatedSprite();
|
~AnimatedSprite();
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "../const.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <vector>
|
|
||||||
#include "sprite.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "asset.h"
|
#include "asset.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "jail_audio.h"
|
#include "jail_audio.h"
|
||||||
#include <sstream>
|
#include "sprite.h"
|
||||||
|
#include "text.h"
|
||||||
|
#include "utils.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifndef MENU_H
|
#ifndef MENU_H
|
||||||
#define MENU_H
|
#define MENU_H
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
#include "../const.h"
|
|
||||||
#include "movingsprite.h"
|
#include "movingsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, LTexture *texture, SDL_Renderer *renderer)
|
MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->texture = texture;
|
this->texture = texture;
|
||||||
@@ -51,11 +50,6 @@ MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vel
|
|||||||
currentFlip = SDL_FLIP_NONE;
|
currentFlip = SDL_FLIP_NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Destructor
|
|
||||||
MovingSprite::~MovingSprite()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reinicia todas las variables
|
// Reinicia todas las variables
|
||||||
void MovingSprite::clear()
|
void MovingSprite::clear()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,10 +35,7 @@ protected:
|
|||||||
|
|
||||||
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, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~MovingSprite();
|
|
||||||
|
|
||||||
// Mueve el sprite
|
// Mueve el sprite
|
||||||
void move();
|
void move();
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
#include "../const.h"
|
|
||||||
#include "smartsprite.h"
|
#include "smartsprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
SmartSprite::SmartSprite(LTexture *texture, SDL_Renderer *renderer)
|
SmartSprite::SmartSprite(Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
@@ -12,11 +11,6 @@ SmartSprite::SmartSprite(LTexture *texture, SDL_Renderer *renderer)
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
SmartSprite::~SmartSprite()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inicializa el objeto
|
// Inicializa el objeto
|
||||||
void SmartSprite::init()
|
void SmartSprite::init()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
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
|
||||||
@@ -28,10 +28,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
SmartSprite(LTexture *texture, SDL_Renderer *renderer);
|
SmartSprite(Texture *texture, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~SmartSprite();
|
|
||||||
|
|
||||||
// Inicializa el objeto
|
// Inicializa el objeto
|
||||||
void init();
|
void init();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Sprite::Sprite(int x, int y, int w, int h, LTexture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
this->x = x;
|
this->x = x;
|
||||||
@@ -24,7 +24,7 @@ Sprite::Sprite(int x, int y, int w, int h, LTexture *texture, SDL_Renderer *rend
|
|||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite::Sprite(SDL_Rect rect, LTexture *texture, SDL_Renderer *renderer)
|
Sprite::Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
// Establece la posición X,Y del sprite
|
// Establece la posición X,Y del sprite
|
||||||
x = rect.x;
|
x = rect.x;
|
||||||
@@ -137,13 +137,13 @@ void Sprite::setSpriteClip(int x, int y, int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
LTexture *Sprite::getTexture()
|
Texture *Sprite::getTexture()
|
||||||
{
|
{
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Sprite::setTexture(LTexture *texture)
|
void Sprite::setTexture(Texture *texture)
|
||||||
{
|
{
|
||||||
this->texture = texture;
|
this->texture = texture;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "ltexture.h"
|
#include "texture.h"
|
||||||
|
|
||||||
#ifndef SPRITE_H
|
#ifndef SPRITE_H
|
||||||
#define SPRITE_H
|
#define SPRITE_H
|
||||||
@@ -16,15 +16,15 @@ protected:
|
|||||||
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
|
Texture *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, Texture *texture = nullptr, SDL_Renderer *renderer = nullptr);
|
||||||
Sprite(SDL_Rect rect, LTexture *texture, SDL_Renderer *renderer);
|
Sprite(SDL_Rect rect, Texture *texture, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Sprite();
|
~Sprite();
|
||||||
@@ -69,10 +69,10 @@ public:
|
|||||||
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();
|
Texture *getTexture();
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setTexture(LTexture *texture);
|
void setTexture(Texture *texture);
|
||||||
|
|
||||||
// Obten el valor de la variable
|
// Obten el valor de la variable
|
||||||
SDL_Renderer *getRenderer();
|
SDL_Renderer *getRenderer();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Text::Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer)
|
|||||||
initOffsetFromFile(textFile);
|
initOffsetFromFile(textFile);
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
texture = new LTexture(renderer, bitmapFile);
|
texture = new Texture(renderer, bitmapFile);
|
||||||
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ private:
|
|||||||
|
|
||||||
// Objetos y punteros
|
// 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
|
Texture *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
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
#include "ltexture.h"
|
#include "texture.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)
|
Texture::Texture(SDL_Renderer *renderer, std::string path)
|
||||||
{
|
{
|
||||||
// Copia punteros
|
// Copia punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -23,14 +23,14 @@ LTexture::LTexture(SDL_Renderer *renderer, std::string path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
LTexture::~LTexture()
|
Texture::~Texture()
|
||||||
{
|
{
|
||||||
// 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 Texture::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;
|
||||||
@@ -98,7 +98,7 @@ bool LTexture::loadFromFile(std::string path, SDL_Renderer *renderer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea una textura en blanco
|
// Crea una textura en blanco
|
||||||
bool LTexture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_TextureAccess access)
|
bool Texture::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);
|
||||||
@@ -116,7 +116,7 @@ bool LTexture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_Te
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Libera la memoria de la textura
|
// Libera la memoria de la textura
|
||||||
void LTexture::unload()
|
void Texture::unload()
|
||||||
{
|
{
|
||||||
// Libera la textura si existe
|
// Libera la textura si existe
|
||||||
if (texture != nullptr)
|
if (texture != nullptr)
|
||||||
@@ -129,25 +129,25 @@ void LTexture::unload()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece el color para la modulacion
|
// Establece el color para la modulacion
|
||||||
void LTexture::setColor(Uint8 red, Uint8 green, Uint8 blue)
|
void Texture::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 Texture::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 Texture::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 Texture::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};
|
||||||
@@ -167,25 +167,25 @@ void LTexture::render(SDL_Renderer *renderer, int x, int y, SDL_Rect *clip, floa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece la textura como objetivo de renderizado
|
// Establece la textura como objetivo de renderizado
|
||||||
void LTexture::setAsRenderTarget(SDL_Renderer *renderer)
|
void Texture::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 Texture::getWidth()
|
||||||
{
|
{
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el alto de la imagen
|
// Obtiene el alto de la imagen
|
||||||
int LTexture::getHeight()
|
int Texture::getHeight()
|
||||||
{
|
{
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recarga la textura
|
// Recarga la textura
|
||||||
bool LTexture::reLoad()
|
bool Texture::reLoad()
|
||||||
{
|
{
|
||||||
return loadFromFile(path, renderer);
|
return loadFromFile(path, renderer);
|
||||||
}
|
}
|
||||||
@@ -4,25 +4,27 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifndef LTEXTURE_H
|
#ifndef TEXTURE_H
|
||||||
#define LTEXTURE_H
|
#define TEXTURE_H
|
||||||
|
|
||||||
// Clase LTexture
|
class Texture
|
||||||
class LTexture
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// Objetos y punteros
|
||||||
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 height; // Alto de la imagen
|
// Variables
|
||||||
std::string path; // Ruta de la imagen de 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:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
LTexture(SDL_Renderer *renderer, std::string path = "");
|
Texture(SDL_Renderer *renderer, std::string path = "");
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~LTexture();
|
~Texture();
|
||||||
|
|
||||||
// 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);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "ltexture.h"
|
#include "texture.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "../const.h"
|
|
||||||
#include "writer.h"
|
#include "writer.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -22,11 +21,6 @@ Writer::Writer(Text *text)
|
|||||||
finished = false;
|
finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
|
||||||
Writer::~Writer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void Writer::update()
|
void Writer::update()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,9 +32,6 @@ public:
|
|||||||
// Constructor
|
// Constructor
|
||||||
Writer(Text *text);
|
Writer(Text *text);
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Writer();
|
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/ltexture.h"
|
#include "common/texture.h"
|
||||||
|
|
||||||
#ifndef FADE_H
|
#ifndef FADE_H
|
||||||
#define FADE_H
|
#define FADE_H
|
||||||
|
|||||||
@@ -391,80 +391,80 @@ void Game::loadMedia()
|
|||||||
loadDemoFile();
|
loadDemoFile();
|
||||||
|
|
||||||
// Texturas
|
// Texturas
|
||||||
bulletTexture = new LTexture(renderer, asset->get("bullet.png"));
|
bulletTexture = new Texture(renderer, asset->get("bullet.png"));
|
||||||
gameBuildingsTexture = new LTexture(renderer, asset->get("game_buildings.png"));
|
gameBuildingsTexture = new Texture(renderer, asset->get("game_buildings.png"));
|
||||||
gameCloudsTexture = new LTexture(renderer, asset->get("game_clouds.png"));
|
gameCloudsTexture = new Texture(renderer, asset->get("game_clouds.png"));
|
||||||
gameGrassTexture = new LTexture(renderer, asset->get("game_grass.png"));
|
gameGrassTexture = new Texture(renderer, asset->get("game_grass.png"));
|
||||||
gamePowerMeterTexture = new LTexture(renderer, asset->get("game_power_meter.png"));
|
gamePowerMeterTexture = new Texture(renderer, asset->get("game_power_meter.png"));
|
||||||
gameSkyColorsTexture = new LTexture(renderer, asset->get("game_sky_colors.png"));
|
gameSkyColorsTexture = new Texture(renderer, asset->get("game_sky_colors.png"));
|
||||||
gameTextTexture = new LTexture(renderer, asset->get("game_text.png"));
|
gameTextTexture = new Texture(renderer, asset->get("game_text.png"));
|
||||||
gameOverTexture = new LTexture(renderer, asset->get("menu_game_over.png"));
|
gameOverTexture = new Texture(renderer, asset->get("menu_game_over.png"));
|
||||||
gameOverEndTexture = new LTexture(renderer, asset->get("menu_game_over_end.png"));
|
gameOverEndTexture = new Texture(renderer, asset->get("menu_game_over_end.png"));
|
||||||
|
|
||||||
// Texturas - Globos
|
// Texturas - Globos
|
||||||
LTexture *balloon1Texture = new LTexture(renderer, asset->get("balloon1.png"));
|
Texture *balloon1Texture = new Texture(renderer, asset->get("balloon1.png"));
|
||||||
balloonTextures.push_back(balloon1Texture);
|
balloonTextures.push_back(balloon1Texture);
|
||||||
|
|
||||||
LTexture *balloon2Texture = new LTexture(renderer, asset->get("balloon2.png"));
|
Texture *balloon2Texture = new Texture(renderer, asset->get("balloon2.png"));
|
||||||
balloonTextures.push_back(balloon2Texture);
|
balloonTextures.push_back(balloon2Texture);
|
||||||
|
|
||||||
LTexture *balloon3Texture = new LTexture(renderer, asset->get("balloon3.png"));
|
Texture *balloon3Texture = new Texture(renderer, asset->get("balloon3.png"));
|
||||||
balloonTextures.push_back(balloon3Texture);
|
balloonTextures.push_back(balloon3Texture);
|
||||||
|
|
||||||
LTexture *balloon4Texture = new LTexture(renderer, asset->get("balloon4.png"));
|
Texture *balloon4Texture = new Texture(renderer, asset->get("balloon4.png"));
|
||||||
balloonTextures.push_back(balloon4Texture);
|
balloonTextures.push_back(balloon4Texture);
|
||||||
|
|
||||||
// Texturas - Items
|
// Texturas - Items
|
||||||
LTexture *item1 = new LTexture(renderer, asset->get("item_points1_disk.png"));
|
Texture *item1 = new Texture(renderer, asset->get("item_points1_disk.png"));
|
||||||
itemTextures.push_back(item1);
|
itemTextures.push_back(item1);
|
||||||
|
|
||||||
LTexture *item2 = new LTexture(renderer, asset->get("item_points2_gavina.png"));
|
Texture *item2 = new Texture(renderer, asset->get("item_points2_gavina.png"));
|
||||||
itemTextures.push_back(item2);
|
itemTextures.push_back(item2);
|
||||||
|
|
||||||
LTexture *item3 = new LTexture(renderer, asset->get("item_points3_pacmar.png"));
|
Texture *item3 = new Texture(renderer, asset->get("item_points3_pacmar.png"));
|
||||||
itemTextures.push_back(item3);
|
itemTextures.push_back(item3);
|
||||||
|
|
||||||
LTexture *item4 = new LTexture(renderer, asset->get("item_clock.png"));
|
Texture *item4 = new Texture(renderer, asset->get("item_clock.png"));
|
||||||
itemTextures.push_back(item4);
|
itemTextures.push_back(item4);
|
||||||
|
|
||||||
LTexture *item5 = new LTexture(renderer, asset->get("item_coffee.png"));
|
Texture *item5 = new Texture(renderer, asset->get("item_coffee.png"));
|
||||||
itemTextures.push_back(item5);
|
itemTextures.push_back(item5);
|
||||||
|
|
||||||
LTexture *item6 = new LTexture(renderer, asset->get("item_coffee_machine.png"));
|
Texture *item6 = new Texture(renderer, asset->get("item_coffee_machine.png"));
|
||||||
itemTextures.push_back(item6);
|
itemTextures.push_back(item6);
|
||||||
|
|
||||||
// Texturas - Player1
|
// Texturas - Player1
|
||||||
LTexture *player1Head = new LTexture(renderer, asset->get("player_bal1_head.png"));
|
Texture *player1Head = new Texture(renderer, asset->get("player_bal1_head.png"));
|
||||||
player1Textures.push_back(player1Head);
|
player1Textures.push_back(player1Head);
|
||||||
|
|
||||||
LTexture *player1Body = new LTexture(renderer, asset->get("player_bal1_body.png"));
|
Texture *player1Body = new Texture(renderer, asset->get("player_bal1_body.png"));
|
||||||
player1Textures.push_back(player1Body);
|
player1Textures.push_back(player1Body);
|
||||||
|
|
||||||
LTexture *player1Legs = new LTexture(renderer, asset->get("player_bal1_legs.png"));
|
Texture *player1Legs = new Texture(renderer, asset->get("player_bal1_legs.png"));
|
||||||
player1Textures.push_back(player1Legs);
|
player1Textures.push_back(player1Legs);
|
||||||
|
|
||||||
LTexture *player1Death = new LTexture(renderer, asset->get("player_bal1_death.png"));
|
Texture *player1Death = new Texture(renderer, asset->get("player_bal1_death.png"));
|
||||||
player1Textures.push_back(player1Death);
|
player1Textures.push_back(player1Death);
|
||||||
|
|
||||||
LTexture *player1Fire = new LTexture(renderer, asset->get("player_bal1_fire.png"));
|
Texture *player1Fire = new Texture(renderer, asset->get("player_bal1_fire.png"));
|
||||||
player1Textures.push_back(player1Fire);
|
player1Textures.push_back(player1Fire);
|
||||||
|
|
||||||
playerTextures.push_back(player1Textures);
|
playerTextures.push_back(player1Textures);
|
||||||
|
|
||||||
// Texturas - Player2
|
// Texturas - Player2
|
||||||
LTexture *player2Head = new LTexture(renderer, asset->get("player_arounder_head.png"));
|
Texture *player2Head = new Texture(renderer, asset->get("player_arounder_head.png"));
|
||||||
player2Textures.push_back(player2Head);
|
player2Textures.push_back(player2Head);
|
||||||
|
|
||||||
LTexture *player2Body = new LTexture(renderer, asset->get("player_arounder_body.png"));
|
Texture *player2Body = new Texture(renderer, asset->get("player_arounder_body.png"));
|
||||||
player2Textures.push_back(player2Body);
|
player2Textures.push_back(player2Body);
|
||||||
|
|
||||||
LTexture *player2Legs = new LTexture(renderer, asset->get("player_arounder_legs.png"));
|
Texture *player2Legs = new Texture(renderer, asset->get("player_arounder_legs.png"));
|
||||||
player2Textures.push_back(player2Legs);
|
player2Textures.push_back(player2Legs);
|
||||||
|
|
||||||
LTexture *player2Death = new LTexture(renderer, asset->get("player_arounder_death.png"));
|
Texture *player2Death = new Texture(renderer, asset->get("player_arounder_death.png"));
|
||||||
player2Textures.push_back(player2Death);
|
player2Textures.push_back(player2Death);
|
||||||
|
|
||||||
LTexture *player2Fire = new LTexture(renderer, asset->get("player_arounder_fire.png"));
|
Texture *player2Fire = new Texture(renderer, asset->get("player_arounder_fire.png"));
|
||||||
player2Textures.push_back(player2Fire);
|
player2Textures.push_back(player2Fire);
|
||||||
|
|
||||||
playerTextures.push_back(player2Textures);
|
playerTextures.push_back(player2Textures);
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
|
||||||
#include "balloon.h"
|
#include "balloon.h"
|
||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
#include "const.h"
|
#include "common/asset.h"
|
||||||
#include "fade.h"
|
|
||||||
#include "common/input.h"
|
#include "common/input.h"
|
||||||
#include "item.h"
|
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/menu.h"
|
#include "common/menu.h"
|
||||||
#include "common/movingsprite.h"
|
#include "common/movingsprite.h"
|
||||||
#include "player.h"
|
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
#include "common/smartsprite.h"
|
#include "common/smartsprite.h"
|
||||||
#include "common/sprite.h"
|
#include "common/sprite.h"
|
||||||
#include "common/text.h"
|
#include "common/text.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
#include "common/writer.h"
|
#include "common/writer.h"
|
||||||
|
#include "const.h"
|
||||||
|
#include "fade.h"
|
||||||
|
#include "item.h"
|
||||||
|
#include "player.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifndef GAME_H
|
#ifndef GAME_H
|
||||||
@@ -127,21 +127,21 @@ private:
|
|||||||
std::vector<Item *> items; // Vector con los items
|
std::vector<Item *> items; // Vector con los items
|
||||||
std::vector<SmartSprite *> smartSprites; // Vector con los smartsprites
|
std::vector<SmartSprite *> smartSprites; // Vector con los smartsprites
|
||||||
|
|
||||||
LTexture *bulletTexture; // Textura para las balas
|
Texture *bulletTexture; // Textura para las balas
|
||||||
std::vector<LTexture *> itemTextures; // Vector con las texturas de los items
|
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
|
||||||
std::vector<LTexture *> balloonTextures; // Vector con las texturas de los globos
|
std::vector<Texture *> balloonTextures; // Vector con las texturas de los globos
|
||||||
std::vector<LTexture *> player1Textures; // Vector con las texturas del jugador
|
std::vector<Texture *> player1Textures; // Vector con las texturas del jugador
|
||||||
std::vector<LTexture *> player2Textures; // Vector con las texturas del jugador
|
std::vector<Texture *> player2Textures; // Vector con las texturas del jugador
|
||||||
std::vector<std::vector<LTexture *>> playerTextures; // Vector con todas las texturas de los jugadores;
|
std::vector<std::vector<Texture *>> playerTextures; // Vector con todas las texturas de los jugadores;
|
||||||
|
|
||||||
LTexture *gameBuildingsTexture; // Textura con los edificios de fondo
|
Texture *gameBuildingsTexture; // Textura con los edificios de fondo
|
||||||
LTexture *gameCloudsTexture; // Textura con las nubes de fondo
|
Texture *gameCloudsTexture; // Textura con las nubes de fondo
|
||||||
LTexture *gameGrassTexture; // Textura con la hierba del suelo
|
Texture *gameGrassTexture; // Textura con la hierba del suelo
|
||||||
LTexture *gamePowerMeterTexture; // Textura con el marcador de poder de la fase
|
Texture *gamePowerMeterTexture; // Textura con el marcador de poder de la fase
|
||||||
LTexture *gameSkyColorsTexture; // Textura con los diferentes colores de fondo del juego
|
Texture *gameSkyColorsTexture; // Textura con los diferentes colores de fondo del juego
|
||||||
LTexture *gameTextTexture; // Textura para los sprites con textos
|
Texture *gameTextTexture; // Textura para los sprites con textos
|
||||||
LTexture *gameOverTexture; // Textura para la pantalla de game over
|
Texture *gameOverTexture; // Textura para la pantalla de game over
|
||||||
LTexture *gameOverEndTexture; // Textura para la pantalla de game over de acabar el juego
|
Texture *gameOverEndTexture; // Textura para la pantalla de game over de acabar el juego
|
||||||
|
|
||||||
std::vector<std::vector<std::string> *> itemAnimations; // Vector con las animaciones de los items
|
std::vector<std::vector<std::string> *> itemAnimations; // Vector con las animaciones de los items
|
||||||
std::vector<std::vector<std::string> *> playerAnimations; // Vector con las animaciones del jugador
|
std::vector<std::vector<std::string> *> playerAnimations; // Vector con las animaciones del jugador
|
||||||
|
|||||||
@@ -12,22 +12,22 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset,
|
|||||||
this->lang = lang;
|
this->lang = lang;
|
||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
LTexture *item1 = new LTexture(renderer, asset->get("item_points1_disk.png"));
|
Texture *item1 = new Texture(renderer, asset->get("item_points1_disk.png"));
|
||||||
itemTextures.push_back(item1);
|
itemTextures.push_back(item1);
|
||||||
|
|
||||||
LTexture *item2 = new LTexture(renderer, asset->get("item_points2_gavina.png"));
|
Texture *item2 = new Texture(renderer, asset->get("item_points2_gavina.png"));
|
||||||
itemTextures.push_back(item2);
|
itemTextures.push_back(item2);
|
||||||
|
|
||||||
LTexture *item3 = new LTexture(renderer, asset->get("item_points3_pacmar.png"));
|
Texture *item3 = new Texture(renderer, asset->get("item_points3_pacmar.png"));
|
||||||
itemTextures.push_back(item3);
|
itemTextures.push_back(item3);
|
||||||
|
|
||||||
LTexture *item4 = new LTexture(renderer, asset->get("item_clock.png"));
|
Texture *item4 = new Texture(renderer, asset->get("item_clock.png"));
|
||||||
itemTextures.push_back(item4);
|
itemTextures.push_back(item4);
|
||||||
|
|
||||||
LTexture *item5 = new LTexture(renderer, asset->get("item_coffee.png"));
|
Texture *item5 = new Texture(renderer, asset->get("item_coffee.png"));
|
||||||
itemTextures.push_back(item5);
|
itemTextures.push_back(item5);
|
||||||
|
|
||||||
LTexture *item6 = new LTexture(renderer, asset->get("item_coffee_machine.png"));
|
Texture *item6 = new Texture(renderer, asset->get("item_coffee_machine.png"));
|
||||||
itemTextures.push_back(item6);
|
itemTextures.push_back(item6);
|
||||||
|
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
#include "const.h"
|
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
#include "common/sprite.h"
|
#include "common/sprite.h"
|
||||||
#include "common/text.h"
|
#include "common/text.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
#include "const.h"
|
||||||
|
|
||||||
#ifndef INSTRUCTIONS_H
|
#ifndef INSTRUCTIONS_H
|
||||||
#define INSTRUCTIONS_H
|
#define INSTRUCTIONS_H
|
||||||
@@ -25,7 +25,7 @@ private:
|
|||||||
// Objetos y punteros
|
// 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<Texture *> itemTextures; // Vector con las texturas de los items
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
||||||
Sprite *sprite; // Sprite con la textura de las instrucciones
|
Sprite *sprite; // Sprite con la textura de las instrucciones
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang)
|
|||||||
|
|
||||||
// Reserva memoria para los objetos
|
// Reserva memoria para los objetos
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
texture = new LTexture(renderer, asset->get("intro.png"));
|
texture = new Texture(renderer, asset->get("intro.png"));
|
||||||
text = new Text(asset->get("nokia.png"), asset->get("nokia.txt"), renderer);
|
text = new Text(asset->get("nokia.png"), asset->get("nokia.txt"), renderer);
|
||||||
|
|
||||||
// Carga los recursos
|
// Carga los recursos
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
#include "const.h"
|
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
#include "common/smartsprite.h"
|
#include "common/smartsprite.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
#include "common/writer.h"
|
#include "common/writer.h"
|
||||||
|
#include "const.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifndef INTRO_H
|
#ifndef INTRO_H
|
||||||
@@ -20,7 +20,7 @@ private:
|
|||||||
// Objetos y punteros
|
// 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
|
Texture *texture; // Textura con los graficos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||||
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Item::Item(Uint8 kind, float x, float y, LTexture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
Item::Item(Uint8 kind, float x, float y, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
sprite = new AnimatedSprite(texture, renderer, "", animation);
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
Uint16 timeToLive; // Temporizador con el tiempo que el objeto está presente
|
Uint16 timeToLive; // Temporizador con el tiempo que el objeto está presente
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Item(Uint8 kind, float x, float y, LTexture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
Item(Uint8 kind, float x, float y, Texture *texture, std::vector<std::string> *animation, SDL_Renderer *renderer);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Item();
|
~Item();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
|||||||
|
|
||||||
// Reserva memoria para los punteros
|
// Reserva memoria para los punteros
|
||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
texture = new LTexture(renderer, asset->get("logo.png"));
|
texture = new Texture(renderer, asset->get("logo.png"));
|
||||||
sprite = new Sprite(14, 75, 226, 44, texture, renderer);
|
sprite = new Sprite(14, 75, 226, 44, texture, renderer);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/asset.h"
|
#include "common/asset.h"
|
||||||
#include "const.h"
|
|
||||||
#include "common/jail_audio.h"
|
#include "common/jail_audio.h"
|
||||||
#include "common/screen.h"
|
#include "common/screen.h"
|
||||||
#include "common/sprite.h"
|
#include "common/sprite.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
#include "const.h"
|
||||||
|
|
||||||
#ifndef LOGO_H
|
#ifndef LOGO_H
|
||||||
#define LOGO_H
|
#define LOGO_H
|
||||||
@@ -19,7 +19,7 @@ private:
|
|||||||
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
|
||||||
LTexture *texture; // Textura con los graficos
|
Texture *texture; // Textura con los graficos
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
Sprite *sprite; // Sprite con la textura del logo
|
Sprite *sprite; // Sprite con la textura del logo
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<LTexture *> texture, std::vector<std::vector<std::string> *> animations)
|
Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations)
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
this->renderer = renderer;
|
this->renderer = renderer;
|
||||||
@@ -578,7 +578,7 @@ void Player::shiftColliders()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
||||||
LTexture *Player::getDeadTexture()
|
Texture *Player::getDeadTexture()
|
||||||
{
|
{
|
||||||
return deathSprite->getTexture();
|
return deathSprite->getTexture();
|
||||||
;
|
;
|
||||||
@@ -617,7 +617,7 @@ void Player::updatePowerUpHeadOffset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pone las texturas del jugador
|
// Pone las texturas del jugador
|
||||||
void Player::setPlayerTextures(std::vector<LTexture *> texture)
|
void Player::setPlayerTextures(std::vector<Texture *> texture)
|
||||||
{
|
{
|
||||||
headSprite->setTexture(texture.at(0));
|
headSprite->setTexture(texture.at(0));
|
||||||
bodySprite->setTexture(texture.at(1));
|
bodySprite->setTexture(texture.at(1));
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "common/utils.h"
|
|
||||||
#include "common/input.h"
|
|
||||||
#include "common/asset.h"
|
|
||||||
#include "common/ltexture.h"
|
|
||||||
#include "common/animatedsprite.h"
|
#include "common/animatedsprite.h"
|
||||||
|
#include "common/asset.h"
|
||||||
|
#include "common/input.h"
|
||||||
|
#include "common/texture.h"
|
||||||
|
#include "common/utils.h"
|
||||||
|
|
||||||
#ifndef PLAYER_H
|
#ifndef PLAYER_H
|
||||||
#define PLAYER_H
|
#define PLAYER_H
|
||||||
@@ -83,7 +83,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Player(float x, int y, SDL_Renderer *renderer, std::vector<LTexture *> texture, std::vector<std::vector<std::string> *> animations);
|
Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> texture, std::vector<std::vector<std::string> *> animations);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Player();
|
~Player();
|
||||||
@@ -98,7 +98,7 @@ public:
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
// Pone las texturas del jugador
|
// Pone las texturas del jugador
|
||||||
void setPlayerTextures(std::vector<LTexture *> texture);
|
void setPlayerTextures(std::vector<Texture *> texture);
|
||||||
|
|
||||||
// Actua en consecuencia de la entrada recibida
|
// Actua en consecuencia de la entrada recibida
|
||||||
void setInput(Uint8 input);
|
void setInput(Uint8 input);
|
||||||
@@ -212,7 +212,7 @@ public:
|
|||||||
circle_t &getCollider();
|
circle_t &getCollider();
|
||||||
|
|
||||||
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
// Obtiene el puntero a la textura con los gráficos de la animación de morir
|
||||||
LTexture *getDeadTexture();
|
Texture *getDeadTexture();
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
Uint16 getDeathCounter();
|
Uint16 getDeathCounter();
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
|||||||
eventHandler = new SDL_Event();
|
eventHandler = new SDL_Event();
|
||||||
fade = new Fade(renderer);
|
fade = new Fade(renderer);
|
||||||
|
|
||||||
dustTexture = new LTexture(renderer, asset->get("title_dust.png"));
|
dustTexture = new Texture(renderer, asset->get("title_dust.png"));
|
||||||
coffeeTexture = new LTexture(renderer, asset->get("title_coffee.png"));
|
coffeeTexture = new Texture(renderer, asset->get("title_coffee.png"));
|
||||||
crisisTexture = new LTexture(renderer, asset->get("title_crisis.png"));
|
crisisTexture = new Texture(renderer, asset->get("title_crisis.png"));
|
||||||
gradientTexture = new LTexture(renderer, asset->get("title_gradient.png"));
|
gradientTexture = new Texture(renderer, asset->get("title_gradient.png"));
|
||||||
|
|
||||||
coffeeBitmap = new SmartSprite(coffeeTexture, renderer);
|
coffeeBitmap = new SmartSprite(coffeeTexture, renderer);
|
||||||
crisisBitmap = new SmartSprite(crisisTexture, renderer);
|
crisisBitmap = new SmartSprite(crisisTexture, renderer);
|
||||||
@@ -1030,7 +1030,7 @@ void Title::createTiledBackground()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea los objetos para pintar en la textura de fondo
|
// Crea los objetos para pintar en la textura de fondo
|
||||||
LTexture *bgTileTexture = new LTexture(renderer, asset->get("title_bg_tile.png"));
|
Texture *bgTileTexture = new Texture(renderer, asset->get("title_bg_tile.png"));
|
||||||
Sprite *tile = new Sprite({0, 0, 64, 64}, bgTileTexture, renderer);
|
Sprite *tile = new Sprite({0, 0, 64, 64}, bgTileTexture, renderer);
|
||||||
|
|
||||||
// Prepara para dibujar sobre la textura
|
// Prepara para dibujar sobre la textura
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ private:
|
|||||||
Game *demoGame; // Objeto para lanzar la demo del juego
|
Game *demoGame; // Objeto para lanzar la demo del juego
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
|
|
||||||
LTexture *dustTexture; // Textura con los graficos del polvo
|
Texture *dustTexture; // Textura con los graficos del polvo
|
||||||
LTexture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
|
||||||
LTexture *crisisTexture; // Textura con los graficos de la plabra crisis
|
Texture *crisisTexture; // Textura con los graficos de la plabra crisis
|
||||||
LTexture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo
|
Texture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo
|
||||||
|
|
||||||
SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo
|
SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo
|
||||||
SDL_Texture *background; // Textura dibujar el fondo del titulo
|
SDL_Texture *background; // Textura dibujar el fondo del titulo
|
||||||
|
|||||||
Reference in New Issue
Block a user