canvi de pc

This commit is contained in:
2025-03-14 23:04:09 +01:00
parent 3670bad36a
commit 4343cbae69
15 changed files with 59 additions and 72 deletions

View File

@@ -46,7 +46,7 @@ public:
: MovingSprite(texture) {} : MovingSprite(texture) {}
// Destructor // Destructor
virtual ~AnimatedSprite() = default; virtual ~AnimatedSprite() override = default;
// Actualiza las variables del objeto // Actualiza las variables del objeto
void update() override; void update() override;

View File

@@ -118,7 +118,7 @@ void Balloon::render()
if (!invulnerable_) if (!invulnerable_)
{ {
SDL_Point p = {24, 24}; SDL_Point p = {24, 24};
sprite_->setRotatingCenter(&p); sprite_->setRotatingCenter(p);
sprite_->render(); sprite_->render();
} }

View File

@@ -4,7 +4,8 @@
// Constructor // Constructor
EnterName::EnterName() EnterName::EnterName()
: character_list_(" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()") {} : character_list_(" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()"),
character_index_{0} {}
// Inicializa el objeto // Inicializa el objeto
void EnterName::init(const std::string &name) void EnterName::init(const std::string &name)
@@ -44,11 +45,9 @@ void EnterName::incPosition()
position_ = MAX_NAME_LENGHT; // Mantenemos en el índice máximo válido. position_ = MAX_NAME_LENGHT; // Mantenemos en el índice máximo válido.
position_overflow_ = true; // Activamos el flag de overflow. position_overflow_ = true; // Activamos el flag de overflow.
} }
else else if (position_ > 0) // No es necesario verificar position_ < MAX_NAME_LENGHT
{ {
// Copiamos el índice del carácter anterior si es posible. // Copiamos el índice del carácter anterior si es posible.
if (position_ > 0 && position_ < MAX_NAME_LENGHT)
{
character_index_[position_] = character_index_[position_ - 1]; character_index_[position_] = character_index_[position_ - 1];
} }
else else
@@ -56,11 +55,11 @@ void EnterName::incPosition()
// Si position_ es 0, inicializamos el carácter actual. // Si position_ es 0, inicializamos el carácter actual.
character_index_[position_] = 0; character_index_[position_] = 0;
} }
}
updateNameFromCharacterIndex(); updateNameFromCharacterIndex();
} }
// Decrementa la posición // Decrementa la posición
void EnterName::decPosition() void EnterName::decPosition()
{ {

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <array>
#include "utils.h" #include "utils.h"
constexpr int MAX_NAME_LENGHT = 6; constexpr int MAX_NAME_LENGHT = 6;
@@ -21,7 +22,7 @@ private:
std::string name_; // Nombre introducido std::string name_; // Nombre introducido
int position_ = 0; // Posición a editar del nombre int position_ = 0; // Posición a editar del nombre
bool position_overflow_ = false; // Indica si hemos incrementado la posición más allá del límite bool position_overflow_ = false; // Indica si hemos incrementado la posición más allá del límite
int character_index_[MAX_NAME_LENGHT]; // Indice de la lista para cada uno de los caracteres que forman el nombre std::array<int, MAX_NAME_LENGHT> character_index_; // Indice de la lista para cada uno de los caracteres que forman el nombre
// Actualiza el nombre a partir de la lista de índices // Actualiza el nombre a partir de la lista de índices
void updateNameFromCharacterIndex(); void updateNameFromCharacterIndex();

View File

@@ -2023,7 +2023,6 @@ void Game::checkDebugEvents(const SDL_Event &event)
const int X = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2; const int X = players_.at(0)->getPosX() + (players_.at(0)->getWidth() - game_text_textures_[3]->getWidth()) / 2;
createItemText(X, game_text_textures_.at(6)); createItemText(X, game_text_textures_.at(6));
break; break;
break;
} }
case SDLK_8: case SDLK_8:
{ {

View File

@@ -25,7 +25,7 @@ private:
int lenght = 8; // Cantidad de desplazamientos a realizar int lenght = 8; // Cantidad de desplazamientos a realizar
int remaining = lenght; // Cantidad de desplazamientos pendientes a realizar int remaining = lenght; // Cantidad de desplazamientos pendientes a realizar
int counter = delay; // Contador para el retraso int counter = delay; // Contador para el retraso
int origin; // Valor inicial de la pantalla para dejarla igual tras el desplazamiento int origin = 0; // Valor inicial de la pantalla para dejarla igual tras el desplazamiento
// Constructor por defect // Constructor por defect
Shake() = default; Shake() = default;
@@ -63,7 +63,7 @@ private:
// Variables // Variables
int x_; // Posición donde dibujar el logo int x_; // Posición donde dibujar el logo
int y_; // Posición donde dibujar el logo int y_; // Posición donde dibujar el logo
float zoom_; // Zoom aplicado al texto "ARCADE EDITION" float zoom_ = 1.0f; // Zoom aplicado al texto "ARCADE EDITION"
int post_finished_counter_ = 1; // Contador final una vez terminada las animaciones de los logos int post_finished_counter_ = 1; // Contador final una vez terminada las animaciones de los logos
Status coffee_crisis_status_ = Status::DISABLED; // Estado en el que se encuentra el texto "COFFEE CRISIS" Status coffee_crisis_status_ = Status::DISABLED; // Estado en el que se encuentra el texto "COFFEE CRISIS"

View File

@@ -338,7 +338,6 @@ void Intro::initSprites()
const int SHADOW_SPRITE_HEIGHT = SPRITE_HEIGHT + BORDER; const int SHADOW_SPRITE_HEIGHT = SPRITE_HEIGHT + BORDER;
const int S_X_DEST = X_DEST - BORDER / 2; const int S_X_DEST = X_DEST - BORDER / 2;
const int S_Y_DEST = Y_DEST - BORDER / 2; const int S_Y_DEST = Y_DEST - BORDER / 2;
;
// Crea las texturas para las sombras // Crea las texturas para las sombras
std::vector<std::shared_ptr<Texture>> shadow_textures; std::vector<std::shared_ptr<Texture>> shadow_textures;
@@ -356,12 +355,10 @@ void Intro::initSprites()
SDL_RenderClear(Screen::get()->getRenderer()); SDL_RenderClear(Screen::get()->getRenderer());
SDL_Rect rect = {BORDER / 2, BORDER / 2, SPRITE_WIDTH, SPRITE_HEIGHT}; SDL_Rect rect = {BORDER / 2, BORDER / 2, SPRITE_WIDTH, SPRITE_HEIGHT};
auto texture = Resource::get()->getTexture(TEXTURE_LIST.at(i))->getSDLTexture(); auto inner_texture = Resource::get()->getTexture(TEXTURE_LIST.at(i))->getSDLTexture();
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_MOD); SDL_SetTextureBlendMode(inner_texture, SDL_BLENDMODE_MOD);
SDL_RenderCopy(Screen::get()->getRenderer(), texture, nullptr, &rect); SDL_RenderCopy(Screen::get()->getRenderer(), inner_texture, nullptr, &rect);
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE); SDL_SetTextureBlendMode(inner_texture, SDL_BLENDMODE_NONE);
// shadow_texture->setAlpha(160);
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp); SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);
shadow_textures.push_back(shadow_texture); shadow_textures.push_back(shadow_texture);

View File

@@ -72,7 +72,7 @@ void MovingSprite::update()
} }
// Muestra el sprite por pantalla // Muestra el sprite por pantalla
void MovingSprite::render() { texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, rotate_.center, flip_); } void MovingSprite::render() { texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, &rotate_.center, flip_); }
// Establece la rotacion // Establece la rotacion
void MovingSprite::rotate() void MovingSprite::rotate()

View File

@@ -18,9 +18,9 @@ public:
int speed; // Velocidad de giro int speed; // Velocidad de giro
double angle; // Angulo para dibujarlo double angle; // Angulo para dibujarlo
float amount; // Cantidad de grados a girar en cada iteración float amount; // Cantidad de grados a girar en cada iteración
SDL_Point *center; // Centro de rotación SDL_Point center; // Centro de rotación
Rotate() : enabled(false), counter(0), speed(1), angle(0.0), amount(0.0f), center(nullptr) {} Rotate() : enabled(false), counter(0), speed(1), angle(0.0), amount(0.0f), center({0, 0}) {}
}; };
protected: protected:
@@ -54,7 +54,7 @@ public:
explicit MovingSprite(std::shared_ptr<Texture> texture); explicit MovingSprite(std::shared_ptr<Texture> texture);
// Destructor // Destructor
virtual ~MovingSprite() = default; virtual ~MovingSprite() override = default;
// Actualiza las variables internas del objeto // Actualiza las variables internas del objeto
virtual void update(); virtual void update();
@@ -88,7 +88,7 @@ public:
// Establece el valor de la variable // Establece el valor de la variable
void setAngle(double value) { rotate_.angle = value; } void setAngle(double value) { rotate_.angle = value; }
void setRotatingCenter(SDL_Point *point) { rotate_.center = point; } void setRotatingCenter(SDL_Point point) { rotate_.center = point; }
// Activa o desactiva el efecto de rotación // Activa o desactiva el efecto de rotación
void setRotate(bool enable); void setRotate(bool enable);

View File

@@ -294,9 +294,6 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string
notifications_.emplace_back(n); notifications_.emplace_back(n);
} }
// Indica si hay notificaciones activas
bool Notifier::isActive() { return !notifications_.empty(); }
// Finaliza y elimnina todas las notificaciones activas // Finaliza y elimnina todas las notificaciones activas
void Notifier::clearAllNotifications() void Notifier::clearAllNotifications()
{ {
@@ -318,9 +315,3 @@ std::vector<std::string> Notifier::getCodes()
} }
return codes; return codes;
} }
// Comprueba si hay alguna notificacion con un código
bool Notifier::checkCode(std::string code)
{
return stringInVector(getCodes(), code);
}

View File

@@ -96,11 +96,11 @@ public:
void show(std::vector<std::string> texts, int icon = -1, const std::string &code = std::string()); void show(std::vector<std::string> texts, int icon = -1, const std::string &code = std::string());
// Indica si hay notificaciones activas // Indica si hay notificaciones activas
bool isActive(); bool isActive() { return !notifications_.empty(); }
// Obtiene los códigos de las notificaciones // Obtiene los códigos de las notificaciones
std::vector<std::string> getCodes(); std::vector<std::string> getCodes();
// Comprueba si hay alguna notificacion con un código // Comprueba si hay alguna notificacion con un código
bool checkCode(std::string code); bool checkCode(const std::string &code) { return stringInVector(getCodes(), code); }
}; };

View File

@@ -59,7 +59,7 @@ public:
: Sprite(texture) {} : Sprite(texture) {}
// Destructor // Destructor
~PathSprite() = default; ~PathSprite() override = default;
// Actualiza la posición del sprite // Actualiza la posición del sprite
void update(); void update();

View File

@@ -238,7 +238,7 @@ public:
int getScoreBoardPanel() const { return scoreboard_panel_; } int getScoreBoardPanel() const { return scoreboard_panel_; }
int getWidth() const { return WIDTH_; } int getWidth() const { return WIDTH_; }
PlayerState getPlayingState() const { return playing_state_; } PlayerState getPlayingState() const { return playing_state_; }
std::string getName() const { return name_; } const std::string& getName() const { return name_; }
bool get1CC() const { return game_completed_ && credits_used_ == 1; } bool get1CC() const { return game_completed_ && credits_used_ == 1; }
bool getEnterNamePositionOverflow() const { return enter_name_->getPositionOverflow(); } bool getEnterNamePositionOverflow() const { return enter_name_->getPositionOverflow(); }

View File

@@ -28,7 +28,7 @@ public:
: AnimatedSprite(texture) {} : AnimatedSprite(texture) {}
// Destructor // Destructor
~SmartSprite() = default; ~SmartSprite() override = default;
// Actualiza la posición y comprueba si ha llegado a su destino // Actualiza la posición y comprueba si ha llegado a su destino
void update() override; void update() override;

View File

@@ -30,9 +30,9 @@ struct TabeTimer
// Constructor // Constructor
TabeTimer(float minTime, float maxTime) TabeTimer(float minTime, float maxTime)
: min_spawn_time(minTime * 60000), max_spawn_time(maxTime * 60000) : min_spawn_time(minTime * 60000), max_spawn_time(maxTime * 60000),
current_time(SDL_GetTicks())
{ {
current_time = SDL_GetTicks();
reset(); reset();
} }
@@ -87,8 +87,8 @@ private:
int fly_distance_ = 0; // Distancia de vuelo int fly_distance_ = 0; // Distancia de vuelo
int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto
bool enabled_ = false; // Indica si el objeto está activo bool enabled_ = false; // Indica si el objeto está activo
TabeDirection direction_; // Dirección del objeto TabeDirection direction_ = TabeDirection::TO_THE_LEFT; // Dirección del objeto
TabeDirection destiny_; // Destino del objeto TabeDirection destiny_ = TabeDirection::TO_THE_LEFT; // Destino del objeto
TabeState state_ = TabeState::FLY; // Estado TabeState state_ = TabeState::FLY; // Estado
int hit_counter_ = 0; // Contador para el estado HIT int hit_counter_ = 0; // Contador para el estado HIT
int number_of_hits_ = 0; // Cantidad de disparos que ha recibido int number_of_hits_ = 0; // Cantidad de disparos que ha recibido