Compare commits

...

2 Commits

Author SHA1 Message Date
336c3119ff retocat el timing de la seqüencia final 2025-03-16 13:36:57 +01:00
bfb334bef0 style: eliminats uns fprintf 2025-03-16 13:24:33 +01:00
6 changed files with 33 additions and 41 deletions

View File

@@ -144,19 +144,9 @@ void Credits::checkInput()
{
// Comprueba si se ha pulsado cualquier botón (de los usados para jugar)
if (Input::get()->checkAnyButtonPressed(INPUT_ALLOW_REPEAT))
{
if (mini_logo_on_position_)
{
// Si el mini_logo ha llegado a su posición final, al pulsar cualquier tecla se activa el fundido
fading_ = true;
want_to_pass_ = true;
}
else
{
// Si todavía estan los creditos en marcha, se pasan solos a toda pastilla
want_to_pass_ = true;
}
want_to_pass_ = true;
fading_ = mini_logo_on_position_;
}
else
{

View File

@@ -55,7 +55,7 @@ Director::Director(int argc, const char *argv[])
section::name = section::Name::GAME;
section::options = section::Options::GAME_PLAY_1P;
#elif DEBUG
section::name = section::Name::LOGO;
section::name = section::Name::GAME;
#else // NORMAL GAME
section::name = section::Name::LOGO;
section::options = section::Options::NONE;

View File

@@ -359,6 +359,9 @@ void Game::updateGameStateGameOver()
// Gestiona eventos para el estado del final del juego
void Game::updateGameStateCompleted()
{
constexpr int START_CELEBRATIONS = 400;
constexpr int END_CELEBRATIONS = START_CELEBRATIONS + 300;
updatePlayers();
updateScoreboard();
updateBackground();
@@ -383,7 +386,7 @@ void Game::updateGameStateCompleted()
// Comienza las celebraciones
// Muestra el mensaje de felicitación y da los puntos a los jugadores
if (game_completed_counter_ == 200)
if (game_completed_counter_ == START_CELEBRATIONS)
{
createMessage({paths_.at(4), paths_.at(5)}, Resource::get()->getTexture("game_text_congratulations"));
createMessage({paths_.at(6), paths_.at(7)}, Resource::get()->getTexture("game_text_1000000_points"));
@@ -403,7 +406,7 @@ void Game::updateGameStateCompleted()
}
// Termina las celebraciones
if (game_completed_counter_ == 500)
if (game_completed_counter_ == END_CELEBRATIONS)
{
for (auto &player : players_)
{

View File

@@ -1,8 +1,8 @@
#include "gif.h"
#include <cstdio> // for fprintf, stderr
#include <cstring> // for memcpy, size_t
#include <stdexcept> // for runtime_error
#include <string> // for allocator, char_traits, operator==, basic_string
#include <iostream> // Para std::cout
#include <cstring> // Para memcpy, size_t
#include <stdexcept> // Para runtime_error
#include <string> // Para allocator, char_traits, operator==, basic_string
namespace GIF
{
@@ -52,7 +52,7 @@ namespace GIF
{
if (input_length <= 0)
{
throw std::runtime_error("Unexpected end of input in uncompress");
throw std::runtime_error("Unexpected end of input in decompress");
}
bit = ((*input & mask) != 0) ? 1 : 0;
mask <<= 1;
@@ -89,7 +89,8 @@ namespace GIF
{
if (code > dictionary_ind)
{
std::fprintf(stderr, "code = %.02x, but dictionary_ind = %d\n", code, dictionary_ind);
std::cerr << "code = " << std::hex << code
<< ", but dictionary_ind = " << dictionary_ind << std::endl;
throw std::runtime_error("LZW error: code exceeds dictionary_ind.");
}
@@ -124,7 +125,8 @@ namespace GIF
// Verifica que 'code' sea un índice válido antes de usarlo.
if (code < 0 || static_cast<size_t>(code) >= dictionary.size())
{
std::fprintf(stderr, "Invalid LZW code %d, dictionary size %zu\n", code, dictionary.size());
std::cerr << "Invalid LZW code " << code
<< ", dictionary size " << dictionary.size() << std::endl;
throw std::runtime_error("LZW error: invalid code encountered");
}
@@ -136,8 +138,8 @@ namespace GIF
out[dictionary[curCode].len - 1] = dictionary[curCode].byte;
if (dictionary[curCode].prev == curCode)
{
std::fprintf(stderr, "Internal error; self-reference detected.\n");
throw std::runtime_error("Internal error in uncompress: self-reference");
std::cerr << "Internal error; self-reference detected." << std::endl;
throw std::runtime_error("Internal error in decompress: self-reference");
}
curCode = dictionary[curCode].prev;
}
@@ -226,9 +228,6 @@ namespace GIF
w = screen_descriptor.width;
h = screen_descriptor.height;
// Imprime para depuración
std::fprintf(stderr, "Screen Descriptor - Width: %d, Height: %d\n", w, h);
int color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1;
std::vector<RGB> global_color_table;
if (screen_descriptor.fields & 0x80)
@@ -300,7 +299,7 @@ namespace GIF
}
else
{
std::fprintf(stderr, "Unrecognized block type %.02x\n", block_type);
std::cerr << "Unrecognized block type " << std::hex << static_cast<int>(block_type) << std::endl;
return std::vector<uint8_t>{};
}
block_type = *buffer++;

View File

@@ -1,7 +1,7 @@
#pragma once
#include <cstdint> // for uint8_t, uint16_t, uint32_t
#include <vector> // for vector
#include <cstdint> // Para uint8_t, uint16_t, uint32_t
#include <vector> // Para vector
namespace GIF
{

View File

@@ -1,15 +1,15 @@
#include "texture.h"
#include <SDL2/SDL_error.h> // for SDL_GetError
#include <SDL2/SDL_surface.h> // for SDL_CreateRGBSurfaceWithFormatFrom
#include <stdint.h> // for uint32_t
#include <cstring> // for memcpy, size_t
#include <fstream> // for basic_ostream, operator<<, basic_ifstream
#include <iostream> // for cerr, cout
#include <stdexcept> // for runtime_error
#include <string> // for char_traits, operator<<, operator+
#include <vector> // for vector
#include "gif.h" // for Gif
#include "utils.h" // for getFileName, Color, printWithDots
#include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_surface.h> // Para SDL_CreateRGBSurfaceWithFormatFrom
#include <stdint.h> // Para uint32_t
#include <cstring> // Para memcpy, size_t
#include <fstream> // Para basic_ostream, operator<<, basic_ifstream
#include <iostream> // Para cerr, cout
#include <stdexcept> // Para runtime_error
#include <string> // Para char_traits, operator<<, operator+
#include <vector> // Para vector
#include "gif.h" // Para Gif
#include "utils.h" // Para getFileName, Color, printWithDots
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" // Para stbi_failure_reason, stbi_image_free