Au, a casa
This commit is contained in:
@@ -87,19 +87,15 @@ Game::Game(int player_id, int current_stage, bool demo)
|
||||
SDL_SetTextureBlendMode(canvas_, SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Crea los dos jugadores
|
||||
auto player1 = 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_);
|
||||
player1->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
||||
player1->setName(lang::getText(53));
|
||||
const auto controller1 = getController(player1->getId());
|
||||
player1->setController(controller1);
|
||||
players_.push_back(std::move(player1));
|
||||
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);
|
||||
players_.back()->setName(lang::getText(53));
|
||||
players_.back()->setController(getController(players_.back()->getId()));
|
||||
|
||||
auto player2 = 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_);
|
||||
player2->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
||||
player2->setName(lang::getText(54));
|
||||
const auto controller2 = getController(player2->getId());
|
||||
player2->setController(controller2);
|
||||
players_.push_back(std::move(player2));
|
||||
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_.back()->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
||||
players_.back()->setName(lang::getText(54));
|
||||
players_.back()->setController(getController(players_.back()->getId()));
|
||||
|
||||
// Activa el jugador que coincide con el "player_id"
|
||||
{
|
||||
@@ -141,15 +137,13 @@ Game::Game(int player_id, int current_stage, bool demo)
|
||||
|
||||
// Variables para el marcador
|
||||
scoreboard_->setPos({param.scoreboard.x, param.scoreboard.y, param.scoreboard.w, param.scoreboard.h});
|
||||
scoreboard_->setMode(SCOREBOARD_CENTER_PANEL, ScoreboardMode::STAGE_INFO);
|
||||
for (const auto &player : players_)
|
||||
{
|
||||
scoreboard_->setName(player->getScoreBoardPanel(), player->getName());
|
||||
if (player->isWaiting())
|
||||
{
|
||||
scoreboard_->setMode(player->getScoreBoardPanel(), ScoreboardMode::WAITING);
|
||||
}
|
||||
}
|
||||
scoreboard_->setMode(SCOREBOARD_CENTER_PANEL, ScoreboardMode::STAGE_INFO);
|
||||
|
||||
// Resto de variables
|
||||
ticks_ = 0;
|
||||
|
||||
@@ -35,10 +35,7 @@ void ManageHiScoreTable::add(HiScoreEntry entry)
|
||||
sort();
|
||||
|
||||
// Deja solo las 10 primeras entradas
|
||||
if (static_cast<int>(table_.size()) > 10)
|
||||
{
|
||||
table_.resize(10);
|
||||
}
|
||||
table_.resize(10);
|
||||
}
|
||||
|
||||
// Ordena la tabla
|
||||
@@ -47,9 +44,9 @@ void ManageHiScoreTable::sort()
|
||||
struct
|
||||
{
|
||||
bool operator()(const HiScoreEntry &a, const HiScoreEntry &b) const { return a.score > b.score; }
|
||||
} custom_less;
|
||||
} scoreDescendingComparator;
|
||||
|
||||
std::sort(table_.begin(), table_.end(), custom_less);
|
||||
std::sort(table_.begin(), table_.end(), scoreDescendingComparator);
|
||||
}
|
||||
|
||||
// Carga la tabla con los datos de un fichero
|
||||
|
||||
@@ -25,7 +25,7 @@ private:
|
||||
public:
|
||||
// Constructor
|
||||
explicit ManageHiScoreTable(std::vector<HiScoreEntry> &table)
|
||||
: table_(table) {} // Inicialización en el constructor
|
||||
: table_(table) {}
|
||||
|
||||
// Destructor
|
||||
~ManageHiScoreTable() = default;
|
||||
|
||||
@@ -11,20 +11,19 @@
|
||||
// Constructor
|
||||
TiledBG::TiledBG(SDL_Rect pos, TiledBGMode mode)
|
||||
: renderer_(Screen::get()->getRenderer()),
|
||||
// Crea la textura para el mosaico de fondo
|
||||
canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, pos_.w * 2, pos_.h * 2)),
|
||||
// Coloca la ventana que recorre el mosaico de fondo de manera que coincida
|
||||
// con el mosaico que hay pintado en el titulo al iniciar
|
||||
window_({128, 96, pos_.w, pos_.h}),
|
||||
pos_(pos),
|
||||
counter_(0),
|
||||
mode_(mode == TiledBGMode::RANDOM ? static_cast<TiledBGMode>(rand() % 2) : mode)
|
||||
{
|
||||
// Crea la textura para el mosaico de fondo
|
||||
canvas_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, pos_.w * 2, pos_.h * 2);
|
||||
|
||||
// Rellena la textura con el contenido
|
||||
fillTexture();
|
||||
|
||||
// Coloca la ventana que recorre el mosaico de fondo de manera que coincida
|
||||
// con el mosaico que hay pintado en el titulo al iniciar
|
||||
window_ = {128, 96, pos_.w, pos_.h};
|
||||
|
||||
// Inicializa los valores del vector con los valores del seno
|
||||
for (int i = 0; i < 360; ++i)
|
||||
{
|
||||
|
||||
@@ -29,11 +29,11 @@ private:
|
||||
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
SDL_Rect window_; // Ventana visible para la textura de fondo del titulo
|
||||
SDL_Texture *canvas_; // Textura donde dibujar el fondo formado por tiles
|
||||
|
||||
// Variables
|
||||
SDL_Rect pos_; // Posición y tamaño del mosaico
|
||||
SDL_Rect window_; // Ventana visible para la textura de fondo del titulo
|
||||
int counter_; // Contador
|
||||
TiledBGMode mode_; // Tipo de movimiento del mosaico
|
||||
double sin_[360]; // Vector con los valores del seno precalculados
|
||||
|
||||
@@ -46,16 +46,15 @@ private:
|
||||
static constexpr Uint32 TICKS_SPEED_ = 15; // Velocidad a la que se repiten los bucles del programa
|
||||
|
||||
// Objetos y punteros
|
||||
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<Fade> fade_; // Objeto para realizar fundidos 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<Fade> fade_; // Objeto para realizar fundidos en pantalla
|
||||
std::unique_ptr<TiledBG> tiled_bg_; // Objeto para dibujar el mosaico animado de fondo
|
||||
std::unique_ptr<GameLogo> game_logo_; // Objeto para dibujar el logo con el título del juego
|
||||
std::shared_ptr<Texture> mini_logo_texture_; // Textura con el logo de JailGames mini
|
||||
std::unique_ptr<Sprite> mini_logo_sprite_; // Sprite con el logo de JailGames mini
|
||||
std::unique_ptr<DefineButtons> define_buttons_; // Objeto para definir los botones del joystic
|
||||
|
||||
|
||||
// Variable
|
||||
int counter_; // Temporizador para la pantalla de titulo
|
||||
Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa
|
||||
|
||||
@@ -1,22 +1,6 @@
|
||||
#include "writer.h"
|
||||
#include "text.h" // for Text
|
||||
|
||||
// Constructor
|
||||
Writer::Writer(std::shared_ptr<Text> text)
|
||||
: text_(text),
|
||||
pos_x_(0),
|
||||
pos_y_(0),
|
||||
kerning_(0),
|
||||
caption_(std::string()),
|
||||
speed_(0),
|
||||
writing_counter_(0),
|
||||
index_(0),
|
||||
lenght_(0),
|
||||
completed_(false),
|
||||
enabled_(false),
|
||||
enabled_counter_(0),
|
||||
finished_(false) {}
|
||||
|
||||
// Actualiza el objeto
|
||||
void Writer::update()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for string
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for string
|
||||
class Text;
|
||||
|
||||
// Clase Writer. Pinta texto en pantalla letra a letra a partir de una cadena y un objeto Text
|
||||
@@ -17,17 +17,30 @@ private:
|
||||
int kerning_; // Kerning del texto, es decir, espaciado entre caracteres
|
||||
std::string caption_; // El texto para escribir
|
||||
int speed_; // Velocidad de escritura
|
||||
int writing_counter_; // Temporizador de escritura para cada caracter
|
||||
int writing_counter_; // Temporizador de escritura para cada caracter
|
||||
int index_; // Posición del texto que se está escribiendo
|
||||
int lenght_; // Longitud de la cadena a escribir
|
||||
bool completed_; // Indica si se ha escrito todo el texto
|
||||
bool enabled_; // Indica si el objeto está habilitado
|
||||
int enabled_counter_; // Temporizador para deshabilitar el objeto
|
||||
int enabled_counter_; // Temporizador para deshabilitar el objeto
|
||||
bool finished_; // Indica si ya ha terminado
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
explicit Writer(std::shared_ptr<Text> text);
|
||||
explicit Writer(std::shared_ptr<Text> text)
|
||||
: text_(text),
|
||||
pos_x_(0),
|
||||
pos_y_(0),
|
||||
kerning_(0),
|
||||
caption_(std::string()),
|
||||
speed_(0),
|
||||
writing_counter_(0),
|
||||
index_(0),
|
||||
lenght_(0),
|
||||
completed_(false),
|
||||
enabled_(false),
|
||||
enabled_counter_(0),
|
||||
finished_(false) {}
|
||||
|
||||
// Destructor
|
||||
~Writer() = default;
|
||||
|
||||
Reference in New Issue
Block a user