.
This commit is contained in:
@@ -28,34 +28,19 @@ Asset *Asset::get()
|
|||||||
return Asset::asset_;
|
return Asset::asset_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Asset::Asset(const std::string &executable_path)
|
|
||||||
: executable_path_(executable_path.substr(0, executable_path.find_last_of("\\/")))
|
|
||||||
{
|
|
||||||
longest_name_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute)
|
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute)
|
||||||
{
|
{
|
||||||
AssetItem ai;
|
file_list_.emplace_back(absolute ? file : executable_path_ + file, type, required);
|
||||||
ai.file = absolute ? file : executable_path_ + file;
|
longest_name_ = std::max(longest_name_, static_cast<int>(file_list_.back().file.size()));
|
||||||
ai.type = type;
|
|
||||||
ai.required = required;
|
|
||||||
file_list_.push_back(ai);
|
|
||||||
|
|
||||||
longest_name_ = SDL_max(longest_name_, getFileName(file).size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el fichero de un elemento de la lista a partir de una cadena
|
// Devuelve la ruta completa a un fichero a partir de una cadena
|
||||||
std::string Asset::get(const std::string &text) const
|
std::string Asset::get(const std::string &text) const
|
||||||
{
|
{
|
||||||
for (const auto &f : file_list_)
|
for (const auto &f : file_list_)
|
||||||
{
|
{
|
||||||
const size_t last_index = f.file.find_last_of("/") + 1;
|
if (getFileName(f.file) == text)
|
||||||
const std::string file = f.file.substr(last_index, std::string::npos);
|
|
||||||
|
|
||||||
if (file == text)
|
|
||||||
{
|
{
|
||||||
return f.file;
|
return f.file;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <string> // for string, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
enum class AssetType : int
|
enum class AssetType : int
|
||||||
{
|
{
|
||||||
@@ -27,14 +28,17 @@ private:
|
|||||||
// Estructura para definir un item
|
// Estructura para definir un item
|
||||||
struct AssetItem
|
struct AssetItem
|
||||||
{
|
{
|
||||||
std::string file; // Ruta del fichero desde la raiz del directorio
|
std::string file; // Ruta del fichero desde la raíz del directorio
|
||||||
enum AssetType type; // Indica el tipo de recurso
|
AssetType type; // Indica el tipo de recurso
|
||||||
bool required; // Indica si es un fichero que debe de existir
|
bool required; // Indica si es un fichero que debe de existir
|
||||||
// bool absolute; // Indica si la ruta que se ha proporcionado es una ruta absoluta
|
|
||||||
|
// Constructor
|
||||||
|
AssetItem(const std::string &filePath, AssetType assetType, bool isRequired)
|
||||||
|
: file(filePath), type(assetType), required(isRequired) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int longest_name_; // Contiene la longitud del nombre de fichero mas largo
|
int longest_name_ = 0; // Contiene la longitud del nombre de fichero mas largo
|
||||||
std::vector<AssetItem> file_list_; // Listado con todas las rutas a los ficheros
|
std::vector<AssetItem> file_list_; // Listado con todas las rutas a los ficheros
|
||||||
std::string executable_path_; // Ruta al ejecutable
|
std::string executable_path_; // Ruta al ejecutable
|
||||||
|
|
||||||
@@ -45,7 +49,8 @@ private:
|
|||||||
std::string getTypeName(AssetType type) const;
|
std::string getTypeName(AssetType type) const;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
explicit Asset(const std::string &executable_path);
|
explicit Asset(const std::string &executable_path)
|
||||||
|
: executable_path_(getPath(executable_path)) {}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Asset() = default;
|
~Asset() = default;
|
||||||
@@ -63,7 +68,7 @@ public:
|
|||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void add(const std::string &file, AssetType type, bool required = true, bool absolute = false);
|
void add(const std::string &file, AssetType type, bool required = true, bool absolute = false);
|
||||||
|
|
||||||
// Devuelve un elemento de la lista a partir de una cadena
|
// Devuelve la ruta completa a un fichero a partir de una cadena
|
||||||
std::string get(const std::string &text) const;
|
std::string get(const std::string &text) const;
|
||||||
|
|
||||||
// Comprueba que existen todos los elementos
|
// Comprueba que existen todos los elementos
|
||||||
|
|||||||
@@ -20,11 +20,6 @@ Background::Background()
|
|||||||
grass_texture_(Resource::get()->getTexture("game_grass.png")),
|
grass_texture_(Resource::get()->getTexture("game_grass.png")),
|
||||||
gradients_texture_(Resource::get()->getTexture("game_sky_colors.png")),
|
gradients_texture_(Resource::get()->getTexture("game_sky_colors.png")),
|
||||||
|
|
||||||
gradient_number_(0),
|
|
||||||
alpha_(0),
|
|
||||||
clouds_speed_(0),
|
|
||||||
transition_(0),
|
|
||||||
counter_(0),
|
|
||||||
rect_({0, 0, gradients_texture_->getWidth() / 2, gradients_texture_->getHeight() / 2}),
|
rect_({0, 0, gradients_texture_->getWidth() / 2, gradients_texture_->getHeight() / 2}),
|
||||||
src_rect_({0, 0, 320, 240}),
|
src_rect_({0, 0, 320, 240}),
|
||||||
dst_rect_({0, 0, 320, 240}),
|
dst_rect_({0, 0, 320, 240}),
|
||||||
|
|||||||
@@ -74,11 +74,11 @@ private:
|
|||||||
SDL_Rect gradient_rect_[4]; // Vector con las coordenadas de los 4 degradados para el cielo
|
SDL_Rect gradient_rect_[4]; // Vector con las coordenadas de los 4 degradados para el cielo
|
||||||
SDL_Rect top_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de arriba
|
SDL_Rect top_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de arriba
|
||||||
SDL_Rect bottom_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de abajo
|
SDL_Rect bottom_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de abajo
|
||||||
int gradient_number_; // Indica el número de degradado de fondo que se va a dibujar
|
int gradient_number_ = 0; // Indica el número de degradado de fondo que se va a dibujar
|
||||||
int alpha_; // Transparencia entre los dos degradados
|
int alpha_ = 0; // Transparencia entre los dos degradados
|
||||||
float clouds_speed_; // Velocidad a la que se desplazan las nubes
|
float clouds_speed_ = 0; // Velocidad a la que se desplazan las nubes
|
||||||
float transition_; // Nivel de transición del fondo 0..1
|
float transition_ = 0; // Nivel de transición del fondo 0..1
|
||||||
int counter_; // Contador interno
|
int counter_ = 0; // Contador interno
|
||||||
SDL_Rect rect_; // Tamaño del objeto fondo
|
SDL_Rect rect_; // Tamaño del objeto fondo
|
||||||
SDL_Rect src_rect_; // Parte del objeto fondo que se va a dibujará en pantalla
|
SDL_Rect src_rect_; // Parte del objeto fondo que se va a dibujará en pantalla
|
||||||
SDL_Rect dst_rect_; // Posición donde dibujar la parte del objeto fondo que se dibujará en pantalla
|
SDL_Rect dst_rect_; // Posición donde dibujar la parte del objeto fondo que se dibujará en pantalla
|
||||||
|
|||||||
@@ -13,17 +13,10 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
|
|||||||
pos_y_(y),
|
pos_y_(y),
|
||||||
vel_x_(vel_x),
|
vel_x_(vel_x),
|
||||||
being_created_(creation_timer > 0),
|
being_created_(creation_timer > 0),
|
||||||
blinking_(false),
|
|
||||||
enabled_(true),
|
|
||||||
invulnerable_(creation_timer > 0),
|
invulnerable_(creation_timer > 0),
|
||||||
stopped_(true),
|
|
||||||
visible_(true),
|
|
||||||
creation_counter_(creation_timer),
|
creation_counter_(creation_timer),
|
||||||
creation_counter_ini_(creation_timer),
|
creation_counter_ini_(creation_timer),
|
||||||
stopped_counter_(0),
|
|
||||||
kind_(kind),
|
kind_(kind),
|
||||||
counter_(0),
|
|
||||||
travel_y_(1.0f),
|
|
||||||
speed_(speed)
|
speed_(speed)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -227,23 +220,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valores para el efecto de rebote
|
|
||||||
bouncing_.enabled = false;
|
|
||||||
bouncing_.counter = 0;
|
|
||||||
bouncing_.speed = 2;
|
|
||||||
bouncing_.zoomW = 1.0f;
|
|
||||||
bouncing_.zoomH = 1.0f;
|
|
||||||
bouncing_.despX = 0.0f;
|
|
||||||
bouncing_.despY = 0.0f;
|
|
||||||
bouncing_.w = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f};
|
|
||||||
bouncing_.h = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f};
|
|
||||||
|
|
||||||
// Configura el sprite
|
// Configura el sprite
|
||||||
sprite_->setPos({static_cast<int>(pos_x_), static_cast<int>(pos_y_), width_, height_});
|
sprite_->setPos({static_cast<int>(pos_x_), static_cast<int>(pos_y_), width_, height_});
|
||||||
|
|
||||||
// Tamaño del circulo de colisión
|
|
||||||
collider_.r = width_ / 2;
|
|
||||||
|
|
||||||
// Alinea el circulo de colisión con el objeto
|
// Alinea el circulo de colisión con el objeto
|
||||||
updateColliders();
|
updateColliders();
|
||||||
}
|
}
|
||||||
@@ -726,8 +705,8 @@ Circle &Balloon::getCollider()
|
|||||||
// Alinea el circulo de colisión con la posición del objeto globo
|
// Alinea el circulo de colisión con la posición del objeto globo
|
||||||
void Balloon::updateColliders()
|
void Balloon::updateColliders()
|
||||||
{
|
{
|
||||||
collider_.x = Uint16(pos_x_ + collider_.r);
|
collider_.x = static_cast<int>(pos_x_ + collider_.r);
|
||||||
collider_.y = pos_y_ + collider_.r;
|
collider_.y = static_cast<int>(pos_y_ + collider_.r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene le valor de la variable
|
// Obtiene le valor de la variable
|
||||||
|
|||||||
@@ -74,49 +74,53 @@ private:
|
|||||||
// Estructura para las variables para el efecto de los rebotes
|
// Estructura para las variables para el efecto de los rebotes
|
||||||
struct Bouncing
|
struct Bouncing
|
||||||
{
|
{
|
||||||
bool enabled; // Si el efecto está activo
|
bool enabled = false; // Si el efecto está activo
|
||||||
Uint8 counter; // Countador para el efecto
|
Uint8 counter = 0; // Countador para el efecto
|
||||||
Uint8 speed; // Velocidad a la que transcurre el efecto
|
Uint8 speed = 2; // Velocidad a la que transcurre el efecto
|
||||||
float zoomW; // Zoom aplicado a la anchura
|
float zoomW = 1.0f; // Zoom aplicado a la anchura
|
||||||
float zoomH; // Zoom aplicado a la altura
|
float zoomH = 1.0f; // Zoom aplicado a la altura
|
||||||
float despX; // Desplazamiento de pixeles en el eje X antes de pintar el objeto con zoom
|
float despX = 0.0f; // Desplazamiento de pixeles en el eje X antes de pintar el objeto con zoom
|
||||||
float despY; // Desplazamiento de pixeles en el eje Y antes de pintar el objeto con zoom
|
float despY = 0.0f; // Desplazamiento de pixeles en el eje Y antes de pintar el objeto con zoom
|
||||||
std::vector<float> w; // Vector con los valores de zoom para el ancho del globo
|
|
||||||
std::vector<float> h; // Vector con los valores de zoom para el alto del globo
|
std::vector<float> w = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f}; // Vector con los valores de zoom para el ancho del globo
|
||||||
|
std::vector<float> h = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f}; // Vector con los valores de zoom para el alto del globo
|
||||||
|
|
||||||
|
// Constructor por defecto
|
||||||
|
Bouncing() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del objeto globo
|
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del objeto globo
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
float pos_x_; // Posición en el eje X
|
float pos_x_; // Posición en el eje X
|
||||||
float pos_y_; // Posición en el eje Y
|
float pos_y_; // Posición en el eje Y
|
||||||
Uint8 width_; // Ancho
|
Uint8 width_; // Ancho
|
||||||
Uint8 height_; // Alto
|
Uint8 height_; // Alto
|
||||||
float vel_x_; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
float vel_x_; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
|
||||||
float vel_y_; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
float vel_y_; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
|
||||||
float gravity_; // Aceleración en el eje Y. Modifica la velocidad
|
float gravity_; // Aceleración en el eje Y. Modifica la velocidad
|
||||||
float default_vel_y_; // Velocidad inicial que tienen al rebotar contra el suelo
|
float default_vel_y_; // Velocidad inicial que tienen al rebotar contra el suelo
|
||||||
float max_vel_y_; // Máxima velocidad que puede alcanzar el objeto en el eje Y
|
float max_vel_y_; // Máxima velocidad que puede alcanzar el objeto en el eje Y
|
||||||
bool being_created_; // Indica si el globo se está creando
|
bool being_created_; // Indica si el globo se está creando
|
||||||
bool blinking_; // Indica si el globo está intermitente
|
bool blinking_ = false; // Indica si el globo está intermitente
|
||||||
bool enabled_; // Indica si el globo esta activo
|
bool enabled_ = true; // Indica si el globo esta activo
|
||||||
bool invulnerable_; // Indica si el globo es invulnerable
|
bool invulnerable_; // Indica si el globo es invulnerable
|
||||||
bool stopped_; // Indica si el globo está parado
|
bool stopped_ = true; // Indica si el globo está parado
|
||||||
bool visible_; // Indica si el globo es visible
|
bool visible_ = true; // Indica si el globo es visible
|
||||||
Circle collider_; // Circulo de colisión del objeto
|
Circle collider_ = Circle(0, 0, width_ / 2); // Circulo de colisión del objeto
|
||||||
Uint16 creation_counter_; // Temporizador para controlar el estado "creandose"
|
Uint16 creation_counter_; // Temporizador para controlar el estado "creandose"
|
||||||
Uint16 creation_counter_ini_; // Valor inicial para el temporizador para controlar el estado "creandose"
|
Uint16 creation_counter_ini_; // Valor inicial para el temporizador para controlar el estado "creandose"
|
||||||
Uint16 score_; // Puntos que da el globo al ser destruido
|
Uint16 score_; // Puntos que da el globo al ser destruido
|
||||||
Uint16 stopped_counter_; // Contador para controlar el estado "parado"
|
Uint16 stopped_counter_ = 0; // Contador para controlar el estado "parado"
|
||||||
Uint8 kind_; // Tipo de globo
|
Uint8 kind_; // Tipo de globo
|
||||||
Uint8 menace_; // Cantidad de amenaza que genera el globo
|
Uint8 menace_; // Cantidad de amenaza que genera el globo
|
||||||
Uint32 counter_; // Contador interno
|
Uint32 counter_ = 0; // Contador interno
|
||||||
float travel_y_; // Distancia que ha de recorrer el globo en el eje Y antes de que se le aplique la gravedad
|
float travel_y_ = 1.0f; // Distancia que ha de recorrer el globo en el eje Y antes de que se le aplique la gravedad
|
||||||
float speed_; // Velocidad a la que se mueven los globos
|
float speed_; // Velocidad a la que se mueven los globos
|
||||||
Uint8 size_; // Tamaño del globo
|
Uint8 size_; // Tamaño del globo
|
||||||
Uint8 power_; // Cantidad de poder que alberga el globo
|
Uint8 power_; // Cantidad de poder que alberga el globo
|
||||||
Bouncing bouncing_; // Contiene las variables para el efecto de rebote
|
Bouncing bouncing_ = Bouncing(); // Contiene las variables para el efecto de rebote
|
||||||
|
|
||||||
// Alinea el circulo de colisión con la posición del objeto globo
|
// Alinea el circulo de colisión con la posición del objeto globo
|
||||||
void updateColliders();
|
void updateColliders();
|
||||||
|
|||||||
@@ -87,15 +87,18 @@ Game::Game(int player_id, int current_stage, bool demo)
|
|||||||
SDL_SetTextureBlendMode(canvas_, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(canvas_, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Crea los dos jugadores
|
// Crea los dos jugadores
|
||||||
players_.emplace_back(std::make_unique<Player>(1, (param.game.play_area.first_quarter_x * ((0 * 2) + 1)) - 11, param.game.play_area.rect.h - 30, demo_.enabled, ¶m.game.play_area.rect, player_textures_[0], player_animations_));
|
{
|
||||||
players_.back()->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
const int y = param.game.play_area.rect.h - 30;
|
||||||
players_.back()->setName(lang::getText(53));
|
players_.emplace_back(std::make_unique<Player>(1, param.game.play_area.first_quarter_x - 15, y, demo_.enabled, param.game.play_area.rect, player_textures_[0], player_animations_));
|
||||||
players_.back()->setController(getController(players_.back()->getId()));
|
players_.back()->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
||||||
|
players_.back()->setName(lang::getText(53));
|
||||||
|
players_.back()->setController(getController(players_.back()->getId()));
|
||||||
|
|
||||||
players_.emplace_back(std::make_unique<Player>(2, (param.game.play_area.first_quarter_x * ((1 * 2) + 1)) - 11, param.game.play_area.rect.h - 30, demo_.enabled, ¶m.game.play_area.rect, player_textures_[1], player_animations_));
|
players_.emplace_back(std::make_unique<Player>(2, param.game.play_area.third_quarter_x - 15, y, demo_.enabled, param.game.play_area.rect, player_textures_[1], player_animations_));
|
||||||
players_.back()->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
players_.back()->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
||||||
players_.back()->setName(lang::getText(54));
|
players_.back()->setName(lang::getText(54));
|
||||||
players_.back()->setController(getController(players_.back()->getId()));
|
players_.back()->setController(getController(players_.back()->getId()));
|
||||||
|
}
|
||||||
|
|
||||||
// Activa el jugador que coincide con el "player_id"
|
// Activa el jugador que coincide con el "player_id"
|
||||||
{
|
{
|
||||||
@@ -1132,7 +1135,7 @@ ItemType Game::dropItem()
|
|||||||
// Crea un objeto item
|
// Crea un objeto item
|
||||||
void Game::createItem(ItemType type, float x, float y)
|
void Game::createItem(ItemType type, float x, float y)
|
||||||
{
|
{
|
||||||
items_.emplace_back(std::make_unique<Item>(type, x, y, &(param.game.play_area.rect), item_textures_[static_cast<int>(type) - 1], item_animations_[static_cast<int>(type) - 1]));
|
items_.emplace_back(std::make_unique<Item>(type, x, y, param.game.play_area.rect, item_textures_[static_cast<int>(type) - 1], item_animations_[static_cast<int>(type) - 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vacia el vector de items
|
// Vacia el vector de items
|
||||||
@@ -1327,8 +1330,9 @@ void Game::updateBalloonDeployCounter()
|
|||||||
// Actualiza el juego
|
// Actualiza el juego
|
||||||
void Game::update()
|
void Game::update()
|
||||||
{
|
{
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
constexpr int TICKS_SPEED = 15;
|
||||||
if (SDL_GetTicks() - ticks_ > TICKS_SPEED_)
|
|
||||||
|
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks_ = SDL_GetTicks();
|
ticks_ = SDL_GetTicks();
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ private:
|
|||||||
static constexpr int GAME_COMPLETED_END_ = 700;
|
static constexpr int GAME_COMPLETED_END_ = 700;
|
||||||
static constexpr int GAME_OVER_COUNTER_ = 350;
|
static constexpr int GAME_OVER_COUNTER_ = 350;
|
||||||
static constexpr int TIME_STOPPED_COUNTER_ = 300;
|
static constexpr int TIME_STOPPED_COUNTER_ = 300;
|
||||||
static constexpr int TICKS_SPEED_ = 15;
|
|
||||||
|
|
||||||
// Porcentaje de aparición de los objetos
|
// Porcentaje de aparición de los objetos
|
||||||
static constexpr int ITEM_POINTS_1_DISK_ODDS_ = 10;
|
static constexpr int ITEM_POINTS_1_DISK_ODDS_ = 10;
|
||||||
|
|||||||
@@ -61,8 +61,9 @@ HiScoreTable::~HiScoreTable()
|
|||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void HiScoreTable::update()
|
void HiScoreTable::update()
|
||||||
{
|
{
|
||||||
// Actualiza las variables
|
constexpr int TICKS_SPEED = 15;
|
||||||
if (SDL_GetTicks() - ticks_ > TICKS_SPEED_)
|
|
||||||
|
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks_ = SDL_GetTicks();
|
ticks_ = SDL_GetTicks();
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class HiScoreTable
|
|||||||
private:
|
private:
|
||||||
// Constantes
|
// Constantes
|
||||||
static constexpr Uint16 COUNTER_END_ = 800; // Valor final para el contador
|
static constexpr Uint16 COUNTER_END_ = 800; // Valor final para el contador
|
||||||
static constexpr Uint32 TICKS_SPEED_ = 15; // Velocidad a la que se repiten los bucles del programa
|
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
|
|||||||
@@ -25,32 +25,22 @@ struct JA_Music_t; // lines 22-22
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Instructions::Instructions()
|
Instructions::Instructions()
|
||||||
|
: renderer_(Screen::get()->getRenderer()),
|
||||||
|
texture_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
|
||||||
|
backbuffer_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
|
||||||
|
text_(std::make_unique<Text>(Resource::get()->getTexture("smb2.gif"), Resource::get()->getTextFile("smb2.txt"))),
|
||||||
|
tiled_bg_(std::make_unique<TiledBG>((SDL_Rect){0, 0, param.game.width, param.game.height}, TiledBGMode::STATIC)),
|
||||||
|
fade_(std::make_unique<Fade>())
|
||||||
{
|
{
|
||||||
// Copia los punteros
|
|
||||||
renderer_ = Screen::get()->getRenderer();
|
|
||||||
|
|
||||||
// Crea objetos
|
|
||||||
text_ = std::make_unique<Text>(Resource::get()->getTexture("smb2.gif"), Resource::get()->getTextFile("smb2.txt"));
|
|
||||||
tiled_bg_ = std::make_unique<TiledBG>((SDL_Rect){0, 0, param.game.width, param.game.height}, TiledBGMode::STATIC);
|
|
||||||
fade_ = std::make_unique<Fade>();
|
|
||||||
|
|
||||||
// Crea un backbuffer para el renderizador
|
// Crea un backbuffer para el renderizador
|
||||||
backbuffer_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height);
|
|
||||||
SDL_SetTextureBlendMode(backbuffer_, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(backbuffer_, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Crea una textura para el texto fijo
|
// Crea una textura para el texto fijo
|
||||||
texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height);
|
|
||||||
SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
section::name = section::Name::INSTRUCTIONS;
|
section::name = section::Name::INSTRUCTIONS;
|
||||||
ticks_ = 0;
|
|
||||||
ticks_speed_ = 15;
|
|
||||||
counter_ = 0;
|
|
||||||
counter_end_ = 700;
|
|
||||||
view_ = {0, 0, param.game.width, param.game.height};
|
view_ = {0, 0, param.game.width, param.game.height};
|
||||||
sprite_pos_ = {0, 0};
|
|
||||||
item_space_ = 2;
|
|
||||||
|
|
||||||
// Inicializa objetos
|
// Inicializa objetos
|
||||||
fade_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
fade_->setColor(fade_color.r, fade_color.g, fade_color.b);
|
||||||
@@ -214,8 +204,9 @@ void Instructions::fillBackbuffer()
|
|||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void Instructions::update()
|
void Instructions::update()
|
||||||
{
|
{
|
||||||
// Actualiza las variables
|
constexpr int TICKS_SPEED = 15;
|
||||||
if (SDL_GetTicks() - ticks_ > ticks_speed_)
|
|
||||||
|
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks_ = SDL_GetTicks();
|
ticks_ = SDL_GetTicks();
|
||||||
|
|||||||
@@ -30,24 +30,23 @@ class Instructions
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
|
SDL_Texture *texture_; // Textura fija con el texto
|
||||||
|
SDL_Texture *backbuffer_; // Textura para usar como backbuffer
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Texture>> item_textures_; // Vector con las texturas de los items
|
std::vector<std::shared_ptr<Texture>> item_textures_; // Vector con las texturas de los items
|
||||||
std::vector<std::unique_ptr<Sprite>> sprites_; // Vector con los sprites de los items
|
std::vector<std::unique_ptr<Sprite>> sprites_; // Vector con los sprites de los items
|
||||||
std::unique_ptr<Text> text_; // Objeto para escribir texto
|
std::unique_ptr<Text> text_; // Objeto para escribir texto
|
||||||
std::unique_ptr<TiledBG> tiled_bg_; // Objeto para dibujar el mosaico animado de fondo
|
std::unique_ptr<TiledBG> tiled_bg_; // Objeto para dibujar el mosaico animado de fondo
|
||||||
std::unique_ptr<Fade> fade_; // Objeto para renderizar fades
|
std::unique_ptr<Fade> fade_; // Objeto para renderizar fades
|
||||||
|
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
|
||||||
SDL_Texture *texture_; // Textura fija con el texto
|
|
||||||
SDL_Texture *backbuffer_; // Textura para usar como backbuffer
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter_; // Contador
|
int counter_ = 0; // Contador
|
||||||
int counter_end_; // Valor final para el contador
|
int counter_end_ = 700; // Valor final para el contador
|
||||||
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint32 ticks_speed_; // Velocidad a la que se repiten los bucles del programa
|
SDL_Rect view_; // Vista del backbuffer que se va amostrar por pantalla
|
||||||
SDL_Rect view_; // Vista del backbuffer que se va amostrar por pantalla
|
SDL_Point sprite_pos_ = {0, 0}; // Posición del primer sprite
|
||||||
SDL_Point sprite_pos_; // Posición del primer sprite
|
int item_space_ = 2; // Espacio entre los items
|
||||||
int item_space_; // Espacio entre los items
|
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
@@ -21,17 +21,13 @@ struct JA_Music_t; // lines 19-19
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Intro::Intro()
|
Intro::Intro()
|
||||||
: texture_(Resource::get()->getTexture("intro.png"))
|
: texture_(Resource::get()->getTexture("intro.png")),
|
||||||
|
text_(std::make_shared<Text>(Resource::get()->getTexture("nokia.png"), Resource::get()->getTextFile("nokia.txt")))
|
||||||
{
|
{
|
||||||
// Reserva memoria para los objetos
|
|
||||||
text_ = std::make_shared<Text>(Resource::get()->getTexture("nokia.png"), Resource::get()->getTextFile("nokia.txt"));
|
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
section::name = section::Name::INTRO;
|
section::name = section::Name::INTRO;
|
||||||
section::options = section::Options::NONE;
|
section::options = section::Options::NONE;
|
||||||
ticks_ = 0;
|
|
||||||
ticks_speed_ = 15;
|
|
||||||
scene_ = 1;
|
|
||||||
|
|
||||||
// Inicializa los bitmaps de la intro
|
// Inicializa los bitmaps de la intro
|
||||||
constexpr int totalBitmaps = 6;
|
constexpr int totalBitmaps = 6;
|
||||||
@@ -372,7 +368,9 @@ void Intro::updateScenes()
|
|||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void Intro::update()
|
void Intro::update()
|
||||||
{
|
{
|
||||||
if (SDL_GetTicks() - ticks_ > ticks_speed_)
|
constexpr int TICKS_SPEED = 15;
|
||||||
|
|
||||||
|
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
ticks_ = SDL_GetTicks();
|
ticks_ = SDL_GetTicks();
|
||||||
|
|||||||
@@ -26,9 +26,8 @@ private:
|
|||||||
std::vector<std::unique_ptr<Writer>> texts_; // Textos de la intro
|
std::vector<std::unique_ptr<Writer>> texts_; // Textos de la intro
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
||||||
Uint8 ticks_speed_; // Velocidad a la que se repiten los bucles del programa
|
int scene_ = 1; // Indica que escena está activa
|
||||||
int scene_; // Indica que escena está activa
|
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
@@ -5,27 +5,26 @@
|
|||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Item::Item(ItemType type, float x, float y, SDL_Rect *play_area, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)
|
Item::Item(ItemType type, float x, float y, SDL_Rect &play_area, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)
|
||||||
: sprite_(std::make_unique<AnimatedSprite>(texture, animation)),
|
: sprite_(std::make_unique<AnimatedSprite>(texture, animation)),
|
||||||
accel_x_(0.0f),
|
|
||||||
floor_collision_(false),
|
|
||||||
type_(type),
|
type_(type),
|
||||||
enabled_(true),
|
play_area_(play_area)
|
||||||
play_area_(play_area),
|
|
||||||
time_to_live_(600)
|
|
||||||
{
|
{
|
||||||
if (type == ItemType::COFFEE_MACHINE)
|
switch (type)
|
||||||
|
{
|
||||||
|
case ItemType::COFFEE_MACHINE:
|
||||||
{
|
{
|
||||||
width_ = 28;
|
width_ = 28;
|
||||||
height_ = 37;
|
height_ = 37;
|
||||||
pos_x_ = (((int)x + (play_area->w / 2)) % (play_area->w - width_ - 5)) + 2;
|
pos_x_ = ((static_cast<int>(x) + (play_area.w / 2)) % (play_area.w - width_ - 5)) + 2;
|
||||||
pos_y_ = -height_;
|
pos_y_ = -height_;
|
||||||
vel_x_ = 0.0f;
|
vel_x_ = 0.0f;
|
||||||
vel_y_ = -0.1f;
|
vel_y_ = -0.1f;
|
||||||
accel_y_ = 0.1f;
|
accel_y_ = 0.1f;
|
||||||
collider_.r = 10;
|
collider_.r = 10;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
default:
|
||||||
{
|
{
|
||||||
width_ = 20;
|
width_ = 20;
|
||||||
height_ = 20;
|
height_ = 20;
|
||||||
@@ -35,6 +34,8 @@ Item::Item(ItemType type, float x, float y, SDL_Rect *play_area, std::shared_ptr
|
|||||||
vel_y_ = -4.0f;
|
vel_y_ = -4.0f;
|
||||||
accel_y_ = 0.2f;
|
accel_y_ = 0.2f;
|
||||||
collider_.r = width_ / 2;
|
collider_.r = width_ / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprite_->setPosX(pos_x_);
|
sprite_->setPosX(pos_x_);
|
||||||
@@ -45,20 +46,20 @@ Item::Item(ItemType type, float x, float y, SDL_Rect *play_area, std::shared_ptr
|
|||||||
// Centra el objeto en la posición X
|
// Centra el objeto en la posición X
|
||||||
void Item::allignTo(int x)
|
void Item::allignTo(int x)
|
||||||
{
|
{
|
||||||
pos_x_ = float(x - (width_ / 2));
|
pos_x_ = static_cast<float>(x - (width_ / 2));
|
||||||
|
|
||||||
if (pos_x_ < param.game.play_area.rect.x)
|
if (pos_x_ < param.game.play_area.rect.x)
|
||||||
{
|
{
|
||||||
pos_x_ = param.game.play_area.rect.x + 1;
|
pos_x_ = param.game.play_area.rect.x + 1;
|
||||||
}
|
}
|
||||||
else if ((pos_x_ + width_) > play_area_->w)
|
else if (pos_x_ + width_ > play_area_.w)
|
||||||
{
|
{
|
||||||
pos_x_ = float(play_area_->w - width_ - 1);
|
pos_x_ = static_cast<float>(play_area_.w - width_ - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Posición X,Y del sprite
|
// Posición X,Y del sprite
|
||||||
sprite_->setPosX(int(pos_x_));
|
sprite_->setPosX(pos_x_);
|
||||||
sprite_->setPosY(int(pos_y_));
|
sprite_->setPosY(pos_y_);
|
||||||
|
|
||||||
// Alinea el circulo de colisión con el objeto
|
// Alinea el circulo de colisión con el objeto
|
||||||
shiftColliders();
|
shiftColliders();
|
||||||
@@ -94,7 +95,7 @@ void Item::move()
|
|||||||
vel_y_ += accel_y_;
|
vel_y_ += accel_y_;
|
||||||
|
|
||||||
// Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido
|
// Si queda fuera de pantalla, corregimos su posición y cambiamos su sentido
|
||||||
if ((pos_x_ < param.game.play_area.rect.x) || (pos_x_ + width_ > play_area_->w))
|
if ((pos_x_ < param.game.play_area.rect.x) || (pos_x_ + width_ > play_area_.w))
|
||||||
{
|
{
|
||||||
// Corregir posición
|
// Corregir posición
|
||||||
pos_x_ -= vel_x_;
|
pos_x_ -= vel_x_;
|
||||||
@@ -114,14 +115,14 @@ void Item::move()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si el objeto se sale por la parte inferior
|
// Si el objeto se sale por la parte inferior
|
||||||
if (pos_y_ + height_ > play_area_->h)
|
if (pos_y_ + height_ > play_area_.h)
|
||||||
{
|
{
|
||||||
// Detiene el objeto
|
// Detiene el objeto
|
||||||
vel_y_ = 0;
|
vel_y_ = 0;
|
||||||
vel_x_ = 0;
|
vel_x_ = 0;
|
||||||
accel_x_ = 0;
|
accel_x_ = 0;
|
||||||
accel_y_ = 0;
|
accel_y_ = 0;
|
||||||
pos_y_ = play_area_->h - height_;
|
pos_y_ = play_area_.h - height_;
|
||||||
if (type_ == ItemType::COFFEE_MACHINE)
|
if (type_ == ItemType::COFFEE_MACHINE)
|
||||||
{
|
{
|
||||||
floor_collision_ = true;
|
floor_collision_ = true;
|
||||||
|
|||||||
@@ -29,20 +29,20 @@ private:
|
|||||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los graficos del objeto
|
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los graficos del objeto
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
float pos_x_; // Posición X del objeto
|
float pos_x_; // Posición X del objeto
|
||||||
float pos_y_; // Posición Y del objeto
|
float pos_y_; // Posición Y del objeto
|
||||||
int width_; // Ancho del objeto
|
int width_; // Ancho del objeto
|
||||||
int height_; // Alto del objeto
|
int height_; // Alto del objeto
|
||||||
float vel_x_; // Velocidad en el eje X
|
float vel_x_; // Velocidad en el eje X
|
||||||
float vel_y_; // Velocidad en el eje Y
|
float vel_y_; // Velocidad en el eje Y
|
||||||
float accel_x_; // Aceleración en el eje X
|
float accel_x_ = 0.0f; // Aceleración en el eje X
|
||||||
float accel_y_; // Aceleración en el eje Y
|
float accel_y_; // Aceleración en el eje Y
|
||||||
bool floor_collision_; // Indica si el objeto colisiona con el suelo
|
bool floor_collision_ = false; // Indica si el objeto colisiona con el suelo
|
||||||
ItemType type_; // Especifica el tipo de objeto que es
|
ItemType type_; // Especifica el tipo de objeto que es
|
||||||
bool enabled_; // Especifica si el objeto está habilitado
|
bool enabled_ = true; // Especifica si el objeto está habilitado
|
||||||
Circle collider_; // Circulo de colisión del objeto
|
Circle collider_; // Circulo de colisión del objeto
|
||||||
SDL_Rect *play_area_; // Rectangulo con la zona de juego
|
SDL_Rect play_area_; // Rectangulo con la zona de juego
|
||||||
Uint16 time_to_live_; // Temporizador con el tiempo que el objeto está presente
|
Uint16 time_to_live_ = 600; // Temporizador con el tiempo que el objeto está presente
|
||||||
|
|
||||||
// Alinea el circulo de colisión con la posición del objeto
|
// Alinea el circulo de colisión con la posición del objeto
|
||||||
void shiftColliders();
|
void shiftColliders();
|
||||||
@@ -58,7 +58,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Item(ItemType type, float x, float y, SDL_Rect *play_area, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation);
|
Item(ItemType type, float x, float y, SDL_Rect &play_area, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Item() = default;
|
~Item() = default;
|
||||||
|
|||||||
@@ -165,7 +165,8 @@ void Logo::updateTextureColors()
|
|||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void Logo::update()
|
void Logo::update()
|
||||||
{
|
{
|
||||||
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
|
constexpr int TICKS_SPEED = 15;
|
||||||
|
|
||||||
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
// Actualiza el contador de ticks
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class Logo
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Constantes
|
// Constantes
|
||||||
static constexpr Uint32 TICKS_SPEED = 15; // Velocidad a la que se repiten los bucles del programa
|
|
||||||
static constexpr int SHOW_SINCE_SPRITE_COUNTER_MARK = 70; // Tiempo del contador en el que empieza a verse el sprite de "SINCE 1998"
|
static constexpr int SHOW_SINCE_SPRITE_COUNTER_MARK = 70; // Tiempo del contador en el que empieza a verse el sprite de "SINCE 1998"
|
||||||
static constexpr int INIT_FADE_COUNTER_MARK = 300; // Tiempo del contador cuando inicia el fade a negro
|
static constexpr int INIT_FADE_COUNTER_MARK = 300; // Tiempo del contador cuando inicia el fade a negro
|
||||||
static constexpr int END_LOGO_COUNTER_MARK = 400; // Tiempo del contador para terminar el logo
|
static constexpr int END_LOGO_COUNTER_MARK = 400; // Tiempo del contador para terminar el logo
|
||||||
|
|||||||
@@ -11,26 +11,18 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Player::Player(int id, float x, int y, bool demo, SDL_Rect *play_area, std::vector<std::shared_ptr<Texture>> texture, const std::vector<std::vector<std::string>> &animations)
|
Player::Player(int id, float x, int y, bool demo, SDL_Rect &play_area, std::vector<std::shared_ptr<Texture>> texture, const std::vector<std::vector<std::string>> &animations)
|
||||||
: player_sprite_(std::make_unique<AnimatedSprite>(texture[0], animations[0])),
|
: player_sprite_(std::make_unique<AnimatedSprite>(texture[0], animations[0])),
|
||||||
power_sprite_(std::make_unique<AnimatedSprite>(texture[1], animations[1])),
|
power_sprite_(std::make_unique<AnimatedSprite>(texture[1], animations[1])),
|
||||||
enter_name_(std::make_unique<EnterName>()),
|
enter_name_(std::make_unique<EnterName>()),
|
||||||
play_area_(play_area),
|
|
||||||
id_(id),
|
id_(id),
|
||||||
pos_x_(x),
|
play_area_(play_area),
|
||||||
pos_y_(y),
|
|
||||||
default_pos_x_(x),
|
default_pos_x_(x),
|
||||||
default_pos_y_(y),
|
default_pos_y_(y),
|
||||||
status_playing_(PlayerStatus::WAITING),
|
|
||||||
scoreboard_panel_(0),
|
|
||||||
name_(std::string()),
|
|
||||||
controller_index_(0),
|
|
||||||
demo_(demo)
|
demo_(demo)
|
||||||
{
|
{
|
||||||
// Reserva memoria para los objetos
|
// Configura objetos
|
||||||
power_sprite_->getTexture()->setAlpha(224);
|
power_sprite_->getTexture()->setAlpha(224);
|
||||||
|
|
||||||
// Establece los offsets para el sprite de PowerUp
|
|
||||||
power_up_desp_x_ = (power_sprite_->getWidth() - player_sprite_->getWidth()) / 2;
|
power_up_desp_x_ = (power_sprite_->getWidth() - player_sprite_->getWidth()) / 2;
|
||||||
power_sprite_->setPosY(y - (power_sprite_->getHeight() - player_sprite_->getHeight()));
|
power_sprite_->setPosY(y - (power_sprite_->getHeight() - player_sprite_->getHeight()));
|
||||||
|
|
||||||
@@ -46,25 +38,21 @@ void Player::init()
|
|||||||
pos_x_ = default_pos_x_;
|
pos_x_ = default_pos_x_;
|
||||||
pos_y_ = default_pos_y_;
|
pos_y_ = default_pos_y_;
|
||||||
status_walking_ = PlayerStatus::WALKING_STOP;
|
status_walking_ = PlayerStatus::WALKING_STOP;
|
||||||
status_firing_ = PlayerStatus::FIRING_NO;
|
status_firing_ = PlayerStatus::FIRING_NONE;
|
||||||
|
status_playing_ = PlayerStatus::WAITING;
|
||||||
invulnerable_ = true;
|
invulnerable_ = true;
|
||||||
invulnerable_counter_ = PLAYER_INVULNERABLE_COUNTER;
|
invulnerable_counter_ = INVULNERABLE_COUNTER_;
|
||||||
power_up_ = false;
|
power_up_ = false;
|
||||||
power_up_counter_ = PLAYER_POWERUP_COUNTER;
|
power_up_counter_ = POWERUP_COUNTER_;
|
||||||
extra_hit_ = false;
|
extra_hit_ = false;
|
||||||
coffees_ = 0;
|
coffees_ = 0;
|
||||||
input_ = true;
|
|
||||||
continue_ticks_ = 0;
|
continue_ticks_ = 0;
|
||||||
continue_counter_ = 10;
|
continue_counter_ = 10;
|
||||||
enter_name_ticks_ = 0;
|
enter_name_ticks_ = 0;
|
||||||
enter_name_counter_ = param.game.enter_name_seconds;
|
enter_name_counter_ = param.game.enter_name_seconds;
|
||||||
width_ = 30;
|
|
||||||
height_ = 30;
|
|
||||||
collider_.r = 9;
|
|
||||||
shiftColliders();
|
shiftColliders();
|
||||||
vel_x_ = 0;
|
vel_x_ = 0;
|
||||||
vel_y_ = 0;
|
vel_y_ = 0;
|
||||||
base_speed_ = 1.5;
|
|
||||||
score_ = 0;
|
score_ = 0;
|
||||||
score_multiplier_ = 1.0f;
|
score_multiplier_ = 1.0f;
|
||||||
cooldown_ = 10;
|
cooldown_ = 10;
|
||||||
@@ -107,14 +95,14 @@ void Player::setInputPlaying(InputType input)
|
|||||||
{
|
{
|
||||||
case InputType::LEFT:
|
case InputType::LEFT:
|
||||||
{
|
{
|
||||||
vel_x_ = -base_speed_;
|
vel_x_ = -BASE_SPEED_;
|
||||||
setWalkingStatus(PlayerStatus::WALKING_LEFT);
|
setWalkingStatus(PlayerStatus::WALKING_LEFT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case InputType::RIGHT:
|
case InputType::RIGHT:
|
||||||
{
|
{
|
||||||
vel_x_ = base_speed_;
|
vel_x_ = BASE_SPEED_;
|
||||||
setWalkingStatus(PlayerStatus::WALKING_RIGHT);
|
setWalkingStatus(PlayerStatus::WALKING_RIGHT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -186,7 +174,7 @@ void Player::move()
|
|||||||
pos_x_ += vel_x_;
|
pos_x_ += vel_x_;
|
||||||
|
|
||||||
// Si el jugador abandona el area de juego por los laterales
|
// Si el jugador abandona el area de juego por los laterales
|
||||||
if ((pos_x_ < param.game.play_area.rect.x - 5) || (pos_x_ + width_ > play_area_->w + 5))
|
if ((pos_x_ < param.game.play_area.rect.x - 5) || (pos_x_ + WIDTH_ > play_area_.w + 5))
|
||||||
{
|
{
|
||||||
// Restaura su posición
|
// Restaura su posición
|
||||||
pos_x_ -= vel_x_;
|
pos_x_ -= vel_x_;
|
||||||
@@ -203,7 +191,7 @@ void Player::move()
|
|||||||
player_sprite_->update();
|
player_sprite_->update();
|
||||||
|
|
||||||
// Si el cadaver abandona el area de juego por los laterales
|
// Si el cadaver abandona el area de juego por los laterales
|
||||||
if ((player_sprite_->getPosX() < param.game.play_area.rect.x) || (player_sprite_->getPosX() + width_ > play_area_->w))
|
if ((player_sprite_->getPosX() < param.game.play_area.rect.x) || (player_sprite_->getPosX() + WIDTH_ > play_area_.w))
|
||||||
{
|
{
|
||||||
// Restaura su posición
|
// Restaura su posición
|
||||||
const float vx = player_sprite_->getVelX();
|
const float vx = player_sprite_->getVelX();
|
||||||
@@ -226,7 +214,7 @@ void Player::render()
|
|||||||
{
|
{
|
||||||
if (power_up_ && isPlaying())
|
if (power_up_ && isPlaying())
|
||||||
{
|
{
|
||||||
if (power_up_counter_ > (PLAYER_POWERUP_COUNTER / 4) || power_up_counter_ % 20 > 4)
|
if (power_up_counter_ > (POWERUP_COUNTER_ / 4) || power_up_counter_ % 20 > 4)
|
||||||
{
|
{
|
||||||
power_sprite_->render();
|
power_sprite_->render();
|
||||||
}
|
}
|
||||||
@@ -261,7 +249,7 @@ void Player::setAnimation()
|
|||||||
// Establece la animación a partir de las cadenas
|
// Establece la animación a partir de las cadenas
|
||||||
if (isPlaying())
|
if (isPlaying())
|
||||||
{
|
{
|
||||||
if (status_firing_ == PlayerStatus::FIRING_NO)
|
if (status_firing_ == PlayerStatus::FIRING_NONE)
|
||||||
{ // No esta disparando
|
{ // No esta disparando
|
||||||
player_sprite_->setCurrentAnimation(a_walking);
|
player_sprite_->setCurrentAnimation(a_walking);
|
||||||
player_sprite_->setFlip(flip_walk);
|
player_sprite_->setFlip(flip_walk);
|
||||||
@@ -301,13 +289,13 @@ int Player::getPosY() const
|
|||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getWidth() const
|
int Player::getWidth() const
|
||||||
{
|
{
|
||||||
return width_;
|
return WIDTH_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int Player::getHeight() const
|
int Player::getHeight() const
|
||||||
{
|
{
|
||||||
return height_;
|
return HEIGHT_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si el jugador puede disparar
|
// Indica si el jugador puede disparar
|
||||||
@@ -336,7 +324,7 @@ void Player::updateCooldown()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setFiringStatus(PlayerStatus::FIRING_NO);
|
setFiringStatus(PlayerStatus::FIRING_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,8 +447,8 @@ void Player::setStatusPlaying(PlayerStatus value)
|
|||||||
{
|
{
|
||||||
case PlayerStatus::PLAYING:
|
case PlayerStatus::PLAYING:
|
||||||
{
|
{
|
||||||
status_playing_ = PlayerStatus::PLAYING;
|
|
||||||
init();
|
init();
|
||||||
|
status_playing_ = PlayerStatus::PLAYING;
|
||||||
setScoreboardMode(ScoreboardMode::SCORE);
|
setScoreboardMode(ScoreboardMode::SCORE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -556,7 +544,7 @@ bool Player::isInvulnerable() const
|
|||||||
void Player::setInvulnerable(bool value)
|
void Player::setInvulnerable(bool value)
|
||||||
{
|
{
|
||||||
invulnerable_ = value;
|
invulnerable_ = value;
|
||||||
invulnerable_counter_ = invulnerable_ ? PLAYER_INVULNERABLE_COUNTER : 0;
|
invulnerable_counter_ = invulnerable_ ? INVULNERABLE_COUNTER_ : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
@@ -599,7 +587,7 @@ bool Player::isPowerUp() const
|
|||||||
void Player::setPowerUp()
|
void Player::setPowerUp()
|
||||||
{
|
{
|
||||||
power_up_ = true;
|
power_up_ = true;
|
||||||
power_up_counter_ = PLAYER_POWERUP_COUNTER;
|
power_up_counter_ = POWERUP_COUNTER_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
@@ -654,18 +642,6 @@ void Player::removeExtraHit()
|
|||||||
extra_hit_ = coffees_ == 0 ? false : true;
|
extra_hit_ = coffees_ == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Habilita la entrada de ordenes
|
|
||||||
void Player::enableInput()
|
|
||||||
{
|
|
||||||
input_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deshabilita la entrada de ordenes
|
|
||||||
void Player::disableInput()
|
|
||||||
{
|
|
||||||
input_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Devuelve el número de cafes actuales
|
// Devuelve el número de cafes actuales
|
||||||
int Player::getCoffees() const
|
int Player::getCoffees() const
|
||||||
{
|
{
|
||||||
@@ -681,8 +657,8 @@ Circle &Player::getCollider()
|
|||||||
// Actualiza el circulo de colisión a la posición del jugador
|
// Actualiza el circulo de colisión a la posición del jugador
|
||||||
void Player::shiftColliders()
|
void Player::shiftColliders()
|
||||||
{
|
{
|
||||||
collider_.x = int(pos_x_ + (width_ / 2));
|
collider_.x = static_cast<int>(pos_x_ + (WIDTH_ / 2));
|
||||||
collider_.y = int(pos_y_ + (height_ / 2));
|
collider_.y = static_cast<int>(pos_y_ + (HEIGHT_ / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone las texturas del jugador
|
// Pone las texturas del jugador
|
||||||
@@ -703,9 +679,8 @@ void Player::updateContinueCounter()
|
|||||||
{
|
{
|
||||||
if (status_playing_ == PlayerStatus::CONTINUE)
|
if (status_playing_ == PlayerStatus::CONTINUE)
|
||||||
{
|
{
|
||||||
constexpr Uint32 ticks_speed = 1000;
|
constexpr int TICKS_SPEED = 1000;
|
||||||
|
if (SDL_GetTicks() - continue_ticks_ > TICKS_SPEED)
|
||||||
if (SDL_GetTicks() - continue_ticks_ > ticks_speed)
|
|
||||||
{
|
{
|
||||||
decContinueCounter();
|
decContinueCounter();
|
||||||
}
|
}
|
||||||
@@ -717,9 +692,8 @@ void Player::updateEnterNameCounter()
|
|||||||
{
|
{
|
||||||
if (status_playing_ == PlayerStatus::ENTERING_NAME)
|
if (status_playing_ == PlayerStatus::ENTERING_NAME)
|
||||||
{
|
{
|
||||||
constexpr Uint32 ticks_speed = 1000;
|
constexpr int TICKS_SPEED = 1000;
|
||||||
|
if (SDL_GetTicks() - enter_name_ticks_ > TICKS_SPEED)
|
||||||
if (SDL_GetTicks() - enter_name_ticks_ > ticks_speed)
|
|
||||||
{
|
{
|
||||||
decEnterNameCounter();
|
decEnterNameCounter();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ enum class PlayerStatus
|
|||||||
FIRING_UP,
|
FIRING_UP,
|
||||||
FIRING_LEFT,
|
FIRING_LEFT,
|
||||||
FIRING_RIGHT,
|
FIRING_RIGHT,
|
||||||
FIRING_NO,
|
FIRING_NONE,
|
||||||
|
|
||||||
PLAYING,
|
PLAYING,
|
||||||
CONTINUE,
|
CONTINUE,
|
||||||
@@ -35,54 +35,55 @@ enum class PlayerStatus
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Variables del jugador
|
// Variables del jugador
|
||||||
constexpr int PLAYER_INVULNERABLE_COUNTER = 200;
|
|
||||||
constexpr int PLAYER_POWERUP_COUNTER = 1500;
|
|
||||||
|
|
||||||
// Clase Player
|
// Clase Player
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// Constantes
|
||||||
|
static constexpr int POWERUP_COUNTER_ = 1500; // Duración del estado PowerUp
|
||||||
|
static constexpr int INVULNERABLE_COUNTER_ = 200; // Duración del estado invulnerable
|
||||||
|
static constexpr int WIDTH_ = 30; // Anchura
|
||||||
|
static constexpr int HEIGHT_ = 30; // Altura
|
||||||
|
static constexpr float BASE_SPEED_ = 1.5f; // Velocidad base del jugador
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
std::unique_ptr<AnimatedSprite> player_sprite_; // Sprite para dibujar el jugador
|
std::unique_ptr<AnimatedSprite> player_sprite_; // Sprite para dibujar el jugador
|
||||||
std::unique_ptr<AnimatedSprite> power_sprite_; // Sprite para dibujar el aura del jugador con el poder a tope
|
std::unique_ptr<AnimatedSprite> power_sprite_; // Sprite para dibujar el aura del jugador con el poder a tope
|
||||||
std::unique_ptr<EnterName> enter_name_; // Clase utilizada para introducir el nombre
|
std::unique_ptr<EnterName> enter_name_; // Clase utilizada para introducir el nombre
|
||||||
SDL_Rect *play_area_; // Rectangulo con la zona de juego
|
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int id_; // Numero de identificación para el jugador. Player1 = 1, Player2 = 2
|
int id_; // Numero de identificación para el jugador. Player1 = 1, Player2 = 2
|
||||||
float pos_x_; // Posicion en el eje X
|
SDL_Rect play_area_; // Rectangulo con la zona de juego
|
||||||
int pos_y_; // Posicion en el eje Y
|
float pos_x_ = 0.0f; // Posicion en el eje X
|
||||||
float default_pos_x_; // Posición inicial para el jugador
|
int pos_y_ = 0; // Posicion en el eje Y
|
||||||
int default_pos_y_; // Posición inicial para el jugador
|
float default_pos_x_; // Posición inicial para el jugador
|
||||||
int width_; // Anchura
|
int default_pos_y_; // Posición inicial para el jugador
|
||||||
int height_; // Altura
|
float vel_x_ = 0.0f; // Cantidad de pixeles a desplazarse en el eje X
|
||||||
float vel_x_; // Cantidad de pixeles a desplazarse en el eje X
|
int vel_y_ = 0.0f; // Cantidad de pixeles a desplazarse en el eje Y
|
||||||
int vel_y_; // Cantidad de pixeles a desplazarse en el eje Y
|
int cooldown_ = 10; // Contador durante el cual no puede disparar
|
||||||
float base_speed_; // Velocidad base del jugador
|
int score_ = 0; // Puntos del jugador
|
||||||
int cooldown_; // Contador durante el cual no puede disparar
|
float score_multiplier_ = 1.0f; // Multiplicador de puntos
|
||||||
int score_; // Puntos del jugador
|
PlayerStatus status_walking_ = PlayerStatus::WALKING_STOP; // Estado del jugador al moverse
|
||||||
float score_multiplier_; // Multiplicador de puntos
|
PlayerStatus status_firing_ = PlayerStatus::FIRING_NONE; // Estado del jugador al disparar
|
||||||
PlayerStatus status_walking_; // Estado del jugador al moverse
|
PlayerStatus status_playing_ = PlayerStatus::WAITING; // Estado del jugador en el juego
|
||||||
PlayerStatus status_firing_; // Estado del jugador al disparar
|
bool invulnerable_ = true; // Indica si el jugador es invulnerable
|
||||||
PlayerStatus status_playing_; // Estado del jugador en el juego
|
int invulnerable_counter_ = INVULNERABLE_COUNTER_; // Contador para la invulnerabilidad
|
||||||
bool invulnerable_; // Indica si el jugador es invulnerable
|
bool extra_hit_ = false; // Indica si el jugador tiene un toque extra
|
||||||
int invulnerable_counter_; // Contador para la invulnerabilidad
|
int coffees_ = 0; // Indica cuantos cafes lleva acumulados
|
||||||
bool extra_hit_; // Indica si el jugador tiene un toque extra
|
bool power_up_ = false; // Indica si el jugador tiene activo el modo PowerUp
|
||||||
int coffees_; // Indica cuantos cafes lleva acumulados
|
int power_up_counter_ = POWERUP_COUNTER_; // Temporizador para el modo PowerUp
|
||||||
bool power_up_; // Indica si el jugador tiene activo el modo PowerUp
|
int power_up_desp_x_ = 0; // Desplazamiento del sprite de PowerUp respecto al sprite del jugador
|
||||||
int power_up_counter_; // Temporizador para el modo PowerUp
|
Circle collider_ = Circle(0, 0, 9); // Circulo de colisión del jugador
|
||||||
int power_up_desp_x_; // Desplazamiento del sprite de PowerUp respecto al sprite del jugador
|
int continue_counter_ = 10; // Contador para poder continuar
|
||||||
bool input_; // Indica si puede recibir ordenes de entrada
|
Uint32 continue_ticks_ = 0; // Variable para poder cambiar el contador de continue en función del tiempo
|
||||||
Circle collider_; // Circulo de colisión del jugador
|
int scoreboard_panel_ = 0; // Panel del marcador asociado al jugador
|
||||||
int continue_counter_; // Contador para poder continuar
|
std::string name_; // Nombre del jugador
|
||||||
Uint32 continue_ticks_; // Variable para poder cambiar el contador de continue en función del tiempo
|
std::string record_name_; // Nombre del jugador para la tabla de mejores puntuaciones
|
||||||
int scoreboard_panel_; // Panel del marcador asociado al jugador
|
int controller_index_ = 0; // Indice del array de mandos que utilizará para moverse
|
||||||
std::string name_; // Nombre del jugador
|
bool demo_; // Para que el jugador sepa si está en el modo demostración
|
||||||
std::string record_name_; // Nombre del jugador para la tabla de mejores puntuaciones
|
int enter_name_counter_; // Contador para poner nombre
|
||||||
int controller_index_; // Indice del array de mandos que utilizará para moverse
|
Uint32 enter_name_ticks_ = 0; // Variable para poder cambiar el contador de poner nombre en función del tiempo
|
||||||
bool demo_; // Para que el jugador sepa si está en el modo demostración
|
|
||||||
int enter_name_counter_; // Contador para poner nombre
|
|
||||||
Uint32 enter_name_ticks_; // Variable para poder cambiar el contador de poner nombre en función del tiempo
|
|
||||||
|
|
||||||
// Actualiza el circulo de colisión a la posición del jugador
|
// Actualiza el circulo de colisión a la posición del jugador
|
||||||
void shiftColliders();
|
void shiftColliders();
|
||||||
@@ -113,7 +114,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Player(int id, float x, int y, bool demo, SDL_Rect *play_area, std::vector<std::shared_ptr<Texture>> texture, const std::vector<std::vector<std::string>> &animations);
|
Player(int id, float x, int y, bool demo, SDL_Rect &play_area, std::vector<std::shared_ptr<Texture>> texture, const std::vector<std::vector<std::string>> &animations);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Player() = default;
|
~Player() = default;
|
||||||
@@ -256,12 +257,6 @@ public:
|
|||||||
// Quita el toque extra al jugador
|
// Quita el toque extra al jugador
|
||||||
void removeExtraHit();
|
void removeExtraHit();
|
||||||
|
|
||||||
// Habilita la entrada de ordenes
|
|
||||||
void enableInput();
|
|
||||||
|
|
||||||
// Deshabilita la entrada de ordenes
|
|
||||||
void disableInput();
|
|
||||||
|
|
||||||
// Devuelve el número de cafes actuales
|
// Devuelve el número de cafes actuales
|
||||||
int getCoffees() const;
|
int getCoffees() const;
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,9 @@ std::string Scoreboard::updateScoreText(int num)
|
|||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
void Scoreboard::updateCounter()
|
void Scoreboard::updateCounter()
|
||||||
{
|
{
|
||||||
if (SDL_GetTicks() - ticks_ > SCOREBOARD_TICK_SPEED_)
|
constexpr int TICKS_SPEED = 100;
|
||||||
|
|
||||||
|
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
||||||
{
|
{
|
||||||
ticks_ = SDL_GetTicks();
|
ticks_ = SDL_GetTicks();
|
||||||
counter_++;
|
counter_++;
|
||||||
|
|||||||
@@ -42,9 +42,6 @@ struct Panel
|
|||||||
class Scoreboard
|
class Scoreboard
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Constantes
|
|
||||||
static constexpr int SCOREBOARD_TICK_SPEED_ = 100;
|
|
||||||
|
|
||||||
// [SINGLETON] Objeto scoreboard privado para Don Melitón
|
// [SINGLETON] Objeto scoreboard privado para Don Melitón
|
||||||
static Scoreboard *scoreboard_;
|
static Scoreboard *scoreboard_;
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,9 @@ Title::~Title()
|
|||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
void Title::update()
|
void Title::update()
|
||||||
{
|
{
|
||||||
// Calcula la lógica de los objetos
|
constexpr int TICKS_SPEED = 15;
|
||||||
if (SDL_GetTicks() - ticks_ > TICKS_SPEED_)
|
|
||||||
|
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks_
|
// Actualiza el contador de ticks_
|
||||||
ticks_ = SDL_GetTicks();
|
ticks_ = SDL_GetTicks();
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ constexpr bool ALLOW_TITLE_ANIMATION_SKIP = true;
|
|||||||
class Title
|
class Title
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Constantes
|
|
||||||
static constexpr Uint32 TICKS_SPEED_ = 15; // Velocidad a la que se repiten los bucles del programa
|
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
std::unique_ptr<Text> text1_; // Objeto de texto para poder escribir textos en pantalla
|
std::unique_ptr<Text> text1_; // Objeto de texto para poder escribir textos en pantalla
|
||||||
std::unique_ptr<Text> text2_; // Objeto de texto para poder escribir textos en pantalla
|
std::unique_ptr<Text> text2_; // Objeto de texto para poder escribir textos en pantalla
|
||||||
|
|||||||
@@ -274,8 +274,15 @@ bool saveDemoFile(const std::string &file_path, const DemoData &dd)
|
|||||||
}
|
}
|
||||||
#endif // RECORDING
|
#endif // RECORDING
|
||||||
|
|
||||||
// Obtiene el nombre de un fichero a partir de una ruta
|
// Obtiene el nombre de un fichero a partir de una ruta completa
|
||||||
std::string getFileName(const std::string &path)
|
std::string getFileName(const std::string &path)
|
||||||
{
|
{
|
||||||
return std::filesystem::path(path).filename().string();
|
return std::filesystem::path(path).filename().string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtiene la ruta eliminando el nombre del fichero
|
||||||
|
std::string getPath(const std::string &full_path)
|
||||||
|
{
|
||||||
|
std::filesystem::path path(full_path);
|
||||||
|
return path.parent_path().string();
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,13 @@ extern Overrides overrides;
|
|||||||
struct Circle
|
struct Circle
|
||||||
{
|
{
|
||||||
int x, y, r;
|
int x, y, r;
|
||||||
|
|
||||||
|
// Constructor por defecto
|
||||||
|
Circle() : x(0), y(0), r(0) {}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Circle(int xCoord, int yCoord, int radius)
|
||||||
|
: x(xCoord), y(yCoord), r(radius) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para definir un color
|
// Estructura para definir un color
|
||||||
@@ -319,6 +326,9 @@ bool saveDemoFile(const std::string &file_path, const DemoData &dd);
|
|||||||
// Obtiene el nombre de un fichero a partir de una ruta
|
// Obtiene el nombre de un fichero a partir de una ruta
|
||||||
std::string getFileName(const std::string &path);
|
std::string getFileName(const std::string &path);
|
||||||
|
|
||||||
|
// Obtiene la ruta eliminando el nombre del fichero
|
||||||
|
std::string getPath(const std::string &full_path);
|
||||||
|
|
||||||
// Colores
|
// Colores
|
||||||
extern const Color bg_color;
|
extern const Color bg_color;
|
||||||
extern const Color no_color;
|
extern const Color no_color;
|
||||||
|
|||||||
Reference in New Issue
Block a user