canvi de pc
This commit is contained in:
@@ -46,7 +46,7 @@ public:
|
||||
: MovingSprite(texture) {}
|
||||
|
||||
// Destructor
|
||||
virtual ~AnimatedSprite() = default;
|
||||
virtual ~AnimatedSprite() override = default;
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
void update() override;
|
||||
|
||||
@@ -118,7 +118,7 @@ void Balloon::render()
|
||||
if (!invulnerable_)
|
||||
{
|
||||
SDL_Point p = {24, 24};
|
||||
sprite_->setRotatingCenter(&p);
|
||||
sprite_->setRotatingCenter(p);
|
||||
sprite_->render();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
// Constructor
|
||||
EnterName::EnterName()
|
||||
: character_list_(" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()") {}
|
||||
: character_list_(" ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()"),
|
||||
character_index_{0} {}
|
||||
|
||||
// Inicializa el objeto
|
||||
void EnterName::init(const std::string &name)
|
||||
@@ -44,23 +45,21 @@ void EnterName::incPosition()
|
||||
position_ = MAX_NAME_LENGHT; // Mantenemos en el índice máximo válido.
|
||||
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.
|
||||
if (position_ > 0 && position_ < MAX_NAME_LENGHT)
|
||||
{
|
||||
character_index_[position_] = character_index_[position_ - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Si position_ es 0, inicializamos el carácter actual.
|
||||
character_index_[position_] = 0;
|
||||
}
|
||||
character_index_[position_] = character_index_[position_ - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Si position_ es 0, inicializamos el carácter actual.
|
||||
character_index_[position_] = 0;
|
||||
}
|
||||
|
||||
updateNameFromCharacterIndex();
|
||||
}
|
||||
|
||||
|
||||
// Decrementa la posición
|
||||
void EnterName::decPosition()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include "utils.h"
|
||||
|
||||
constexpr int MAX_NAME_LENGHT = 6;
|
||||
@@ -17,11 +18,11 @@ constexpr int MAX_NAME_LENGHT = 6;
|
||||
class EnterName
|
||||
{
|
||||
private:
|
||||
std::string character_list_; // Lista de todos los caracteres permitidos
|
||||
std::string name_; // Nombre introducido
|
||||
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
|
||||
int character_index_[MAX_NAME_LENGHT]; // Indice de la lista para cada uno de los caracteres que forman el nombre
|
||||
std::string character_list_; // Lista de todos los caracteres permitidos
|
||||
std::string name_; // Nombre introducido
|
||||
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
|
||||
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
|
||||
void updateNameFromCharacterIndex();
|
||||
|
||||
@@ -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;
|
||||
createItemText(X, game_text_textures_.at(6));
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case SDLK_8:
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ private:
|
||||
int lenght = 8; // Cantidad de desplazamientos a realizar
|
||||
int remaining = lenght; // Cantidad de desplazamientos pendientes a realizar
|
||||
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
|
||||
Shake() = default;
|
||||
@@ -61,9 +61,9 @@ private:
|
||||
std::unique_ptr<Sprite> arcade_edition_sprite_; // Sprite con los graficos de "Arcade Edition"
|
||||
|
||||
// Variables
|
||||
int x_; // Posición donde dibujar el logo
|
||||
int y_; // Posición donde dibujar el logo
|
||||
float zoom_; // Zoom aplicado al texto "ARCADE EDITION"
|
||||
int x_; // Posición donde dibujar el logo
|
||||
int y_; // Posición donde dibujar el logo
|
||||
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
|
||||
|
||||
Status coffee_crisis_status_ = Status::DISABLED; // Estado en el que se encuentra el texto "COFFEE CRISIS"
|
||||
|
||||
@@ -338,7 +338,6 @@ void Intro::initSprites()
|
||||
const int SHADOW_SPRITE_HEIGHT = SPRITE_HEIGHT + BORDER;
|
||||
const int S_X_DEST = X_DEST - BORDER / 2;
|
||||
const int S_Y_DEST = Y_DEST - BORDER / 2;
|
||||
;
|
||||
|
||||
// Crea las texturas para las sombras
|
||||
std::vector<std::shared_ptr<Texture>> shadow_textures;
|
||||
@@ -356,12 +355,10 @@ void Intro::initSprites()
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
SDL_Rect rect = {BORDER / 2, BORDER / 2, SPRITE_WIDTH, SPRITE_HEIGHT};
|
||||
auto texture = Resource::get()->getTexture(TEXTURE_LIST.at(i))->getSDLTexture();
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_MOD);
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), texture, nullptr, &rect);
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE);
|
||||
|
||||
// shadow_texture->setAlpha(160);
|
||||
auto inner_texture = Resource::get()->getTexture(TEXTURE_LIST.at(i))->getSDLTexture();
|
||||
SDL_SetTextureBlendMode(inner_texture, SDL_BLENDMODE_MOD);
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), inner_texture, nullptr, &rect);
|
||||
SDL_SetTextureBlendMode(inner_texture, SDL_BLENDMODE_NONE);
|
||||
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);
|
||||
shadow_textures.push_back(shadow_texture);
|
||||
|
||||
@@ -72,7 +72,7 @@ void MovingSprite::update()
|
||||
}
|
||||
|
||||
// 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
|
||||
void MovingSprite::rotate()
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <SDL2/SDL_render.h> // Para SDL_RendererFlip
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <algorithm>
|
||||
#include "sprite.h" // Para Sprite
|
||||
class Texture; // lines 8-8
|
||||
#include "sprite.h" // Para Sprite
|
||||
class Texture; // lines 8-8
|
||||
|
||||
// Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite
|
||||
class MovingSprite : public Sprite
|
||||
@@ -13,14 +13,14 @@ class MovingSprite : public Sprite
|
||||
public:
|
||||
struct Rotate
|
||||
{
|
||||
bool enabled; // Indica si ha de rotar
|
||||
int counter; // Contador
|
||||
int speed; // Velocidad de giro
|
||||
double angle; // Angulo para dibujarlo
|
||||
float amount; // Cantidad de grados a girar en cada iteración
|
||||
SDL_Point *center; // Centro de rotación
|
||||
bool enabled; // Indica si ha de rotar
|
||||
int counter; // Contador
|
||||
int speed; // Velocidad de giro
|
||||
double angle; // Angulo para dibujarlo
|
||||
float amount; // Cantidad de grados a girar en cada iteració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:
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
explicit MovingSprite(std::shared_ptr<Texture> texture);
|
||||
|
||||
// Destructor
|
||||
virtual ~MovingSprite() = default;
|
||||
virtual ~MovingSprite() override = default;
|
||||
|
||||
// Actualiza las variables internas del objeto
|
||||
virtual void update();
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
|
||||
// Establece el valor de la variable
|
||||
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
|
||||
void setRotate(bool enable);
|
||||
|
||||
@@ -294,9 +294,6 @@ void Notifier::show(std::vector<std::string> texts, int icon, const std::string
|
||||
notifications_.emplace_back(n);
|
||||
}
|
||||
|
||||
// Indica si hay notificaciones activas
|
||||
bool Notifier::isActive() { return !notifications_.empty(); }
|
||||
|
||||
// Finaliza y elimnina todas las notificaciones activas
|
||||
void Notifier::clearAllNotifications()
|
||||
{
|
||||
@@ -317,10 +314,4 @@ std::vector<std::string> Notifier::getCodes()
|
||||
codes.emplace_back(notification.code);
|
||||
}
|
||||
return codes;
|
||||
}
|
||||
|
||||
// Comprueba si hay alguna notificacion con un código
|
||||
bool Notifier::checkCode(std::string code)
|
||||
{
|
||||
return stringInVector(getCodes(), code);
|
||||
}
|
||||
@@ -96,11 +96,11 @@ public:
|
||||
void show(std::vector<std::string> texts, int icon = -1, const std::string &code = std::string());
|
||||
|
||||
// Indica si hay notificaciones activas
|
||||
bool isActive();
|
||||
bool isActive() { return !notifications_.empty(); }
|
||||
|
||||
// Obtiene los códigos de las notificaciones
|
||||
std::vector<std::string> getCodes();
|
||||
|
||||
// Comprueba si hay alguna notificacion con un código
|
||||
bool checkCode(std::string code);
|
||||
bool checkCode(const std::string &code) { return stringInVector(getCodes(), code); }
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
: Sprite(texture) {}
|
||||
|
||||
// Destructor
|
||||
~PathSprite() = default;
|
||||
~PathSprite() override = default;
|
||||
|
||||
// Actualiza la posición del sprite
|
||||
void update();
|
||||
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
int getScoreBoardPanel() const { return scoreboard_panel_; }
|
||||
int getWidth() const { return WIDTH_; }
|
||||
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 getEnterNamePositionOverflow() const { return enter_name_->getPositionOverflow(); }
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
: AnimatedSprite(texture) {}
|
||||
|
||||
// Destructor
|
||||
~SmartSprite() = default;
|
||||
~SmartSprite() override = default;
|
||||
|
||||
// Actualiza la posición y comprueba si ha llegado a su destino
|
||||
void update() override;
|
||||
|
||||
@@ -30,9 +30,9 @@ struct TabeTimer
|
||||
|
||||
// Constructor
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -80,20 +80,20 @@ private:
|
||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los graficos y animaciones
|
||||
|
||||
// Variables
|
||||
float x_ = 0; // Posición del objeto
|
||||
float y_ = 0; // Posición del objeto
|
||||
float speed_ = 0.0f; // Velocidad de movimiento del objeto
|
||||
float accel_ = 0.0f; // Aceleración del objeto
|
||||
int fly_distance_ = 0; // Distancia de vuelo
|
||||
int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto
|
||||
bool enabled_ = false; // Indica si el objeto está activo
|
||||
TabeDirection direction_; // Dirección del objeto
|
||||
TabeDirection destiny_; // Destino del objeto
|
||||
TabeState state_ = TabeState::FLY; // Estado
|
||||
int hit_counter_ = 0; // Contador para el estado HIT
|
||||
int number_of_hits_ = 0; // Cantidad de disparos que ha recibido
|
||||
bool has_bonus_ = true; // Indica si el Tabe aun tiene el bonus para soltar
|
||||
TabeTimer timer_; // Temporizador para gestionar la aparición del Tabe
|
||||
float x_ = 0; // Posición del objeto
|
||||
float y_ = 0; // Posición del objeto
|
||||
float speed_ = 0.0f; // Velocidad de movimiento del objeto
|
||||
float accel_ = 0.0f; // Aceleración del objeto
|
||||
int fly_distance_ = 0; // Distancia de vuelo
|
||||
int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto
|
||||
bool enabled_ = false; // Indica si el objeto está activo
|
||||
TabeDirection direction_ = TabeDirection::TO_THE_LEFT; // Dirección del objeto
|
||||
TabeDirection destiny_ = TabeDirection::TO_THE_LEFT; // Destino del objeto
|
||||
TabeState state_ = TabeState::FLY; // Estado
|
||||
int hit_counter_ = 0; // Contador para el estado HIT
|
||||
int number_of_hits_ = 0; // Cantidad de disparos que ha recibido
|
||||
bool has_bonus_ = true; // Indica si el Tabe aun tiene el bonus para soltar
|
||||
TabeTimer timer_; // Temporizador para gestionar la aparición del Tabe
|
||||
|
||||
// Mueve el objeto
|
||||
void move();
|
||||
|
||||
Reference in New Issue
Block a user