canvi de pc
This commit is contained in:
BIN
data/gfx/logo/logo_retroweekend.png
Normal file
BIN
data/gfx/logo/logo_retroweekend.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
@@ -56,13 +56,13 @@ private:
|
||||
~Asset() = default;
|
||||
|
||||
public:
|
||||
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
||||
static void init(const std::string &executable_path);
|
||||
|
||||
// [SINGLETON] Destruiremos el objeto screen con esta función estática
|
||||
// [SINGLETON] Destruiremos el objeto con esta función estática
|
||||
static void destroy();
|
||||
|
||||
// [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él
|
||||
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
|
||||
static Asset *get();
|
||||
|
||||
// Añade un elemento a la lista
|
||||
|
||||
@@ -484,6 +484,7 @@ void Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames_mini.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/logo/logo_since_1998.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/gfx/logo/logo_retroweekend.png", AssetType::BITMAP);
|
||||
}
|
||||
|
||||
{ // Items
|
||||
|
||||
133
source/logo.cpp
133
source/logo.cpp
@@ -3,6 +3,7 @@
|
||||
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
||||
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
|
||||
#include <utility> // Para move
|
||||
#include <iostream>
|
||||
#include "global_inputs.h" // Para check
|
||||
#include "input.h" // Para Input
|
||||
#include "jail_audio.h" // Para JA_StopMusic
|
||||
@@ -52,6 +53,9 @@ Logo::Logo()
|
||||
color_.push_back(Color(0x00, 0xd8, 0xd8)); // Cyan
|
||||
color_.push_back(Color(0xd8, 0xd8, 0x00)); // Yellow
|
||||
color_.push_back(Color(0xFF, 0xFF, 0xFF)); // Bright white
|
||||
|
||||
mi_textura = copyTextureToTarget(Screen::get()->getRenderer(), Resource::get()->getTexture("logo_retroweekend.png")->getSDLTexture());
|
||||
pixels_ = extractPixels(mi_textura);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -60,6 +64,7 @@ Logo::~Logo()
|
||||
jail_texture_->setColor(255, 255, 255);
|
||||
since_texture_->setColor(255, 255, 255);
|
||||
JA_StopChannel(-1);
|
||||
SDL_DestroyTexture(mi_textura);
|
||||
}
|
||||
|
||||
// Recarga todas las texturas
|
||||
@@ -146,11 +151,22 @@ void Logo::updateJAILGAMES()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado el logo
|
||||
if (counter_ == END_LOGO_COUNTER_MARK + POST_LOGO_DURATION)
|
||||
{
|
||||
state_ = LogoState::RETROWEEKEND;
|
||||
ticks_start_ = SDL_GetTicks();
|
||||
}
|
||||
}
|
||||
|
||||
// Gestiona el logo de RETROWEEKEND
|
||||
void Logo::updateRETROWEEKEND()
|
||||
{
|
||||
if (SDL_GetTicks() >= ticks_start_ + 5000)
|
||||
{
|
||||
section::name = section::Name::INTRO;
|
||||
}
|
||||
}
|
||||
|
||||
// Gestiona el color de las texturas
|
||||
@@ -209,15 +225,9 @@ void Logo::update()
|
||||
break;
|
||||
}
|
||||
|
||||
// Gestiona el contador y sus eventos
|
||||
// Gestiona el contador
|
||||
counter_++;
|
||||
|
||||
// Comprueba si ha terminado el logo
|
||||
if (counter_ == END_LOGO_COUNTER_MARK + POST_LOGO_DURATION)
|
||||
{
|
||||
section::name = section::Name::INTRO;
|
||||
}
|
||||
|
||||
// Actualiza las variables de globalInputs
|
||||
globalInputs::update();
|
||||
}
|
||||
@@ -279,4 +289,113 @@ void Logo::renderJAILGAMES()
|
||||
// Renderiza el logo de RETROWEEKEND
|
||||
void Logo::renderRETROWEEKEND()
|
||||
{
|
||||
// SDL_RenderCopy(Screen::get()->getRenderer(), mi_textura, nullptr, nullptr);
|
||||
|
||||
// SDL_RenderCopy(Screen::get()->getRenderer(), Resource::get()->getTexture("logo_retroweekend.png")->getSDLTexture(), nullptr, nullptr);
|
||||
// Dibujar y evaporar los píxeles
|
||||
renderAndEvaporate(Screen::get()->getRenderer(), pixels_);
|
||||
}
|
||||
|
||||
std::vector<Pixel> Logo::extractPixels(SDL_Texture *texture)
|
||||
{
|
||||
std::vector<Pixel> pixels;
|
||||
|
||||
// Obtener el formato y tamaño de la textura
|
||||
Uint32 format;
|
||||
int access, width, height;
|
||||
SDL_QueryTexture(texture, &format, &access, &width, &height);
|
||||
|
||||
// Imprimir el nombre del formato de la textura
|
||||
std::cout << "Texture format: " << SDL_GetPixelFormatName(format) << std::endl;
|
||||
|
||||
// Crear una superficie temporal para leer los píxeles
|
||||
SDL_Surface *temp_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, format);
|
||||
if (!temp_surface)
|
||||
{
|
||||
std::cout << "Error: SDL_CreateRGBSurfaceWithFormat failed - " << SDL_GetError() << std::endl;
|
||||
return pixels;
|
||||
}
|
||||
|
||||
SDL_Renderer *renderer = Screen::get()->getRenderer();
|
||||
SDL_SetRenderTarget(renderer, nullptr); // Dibujar en pantalla principal
|
||||
SDL_RenderClear(renderer); // Limpiar pantalla
|
||||
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
|
||||
SDL_RenderPresent(renderer); // Mostrar en pantalla
|
||||
|
||||
std::cout << "Se ha dibujado la textura en pantalla." << std::endl;
|
||||
|
||||
if (SDL_RenderReadPixels(Screen::get()->getRenderer(), nullptr, format, temp_surface->pixels, temp_surface->pitch) != 0)
|
||||
{
|
||||
std::cout << "Error: SDL_RenderReadPixels failed - " << SDL_GetError() << std::endl;
|
||||
SDL_FreeSurface(temp_surface);
|
||||
return pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "SDL_RenderReadPixels se ejecutó correctamente." << std::endl;
|
||||
}
|
||||
|
||||
// Leer los píxeles de la textura
|
||||
if (SDL_RenderReadPixels(Screen::get()->getRenderer(), nullptr, format, temp_surface->pixels, temp_surface->pitch) != 0)
|
||||
{
|
||||
std::cout << "Error: SDL_RenderReadPixels failed - " << SDL_GetError() << std::endl;
|
||||
SDL_FreeSurface(temp_surface);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
// Extraer los píxeles y almacenarlos en el vector
|
||||
SDL_PixelFormat *pixel_format = SDL_AllocFormat(format);
|
||||
Uint8 r, g, b, a;
|
||||
/*for (int y = 0; y < height; ++y)
|
||||
{
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
Uint32 pixel_value = ((Uint32 *)temp_surface->pixels)[y * (temp_surface->pitch / 4) + x];
|
||||
SDL_GetRGBA(pixel_value, pixel_format, &r, &g, &b, &a);
|
||||
if (a > 0)
|
||||
{
|
||||
pixels.push_back({x, y, r, g, b, a});
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
Uint32 pixel_value = ((Uint32 *)temp_surface->pixels)[y * (temp_surface->pitch / 4) + x];
|
||||
SDL_GetRGBA(pixel_value, pixel_format, &r, &g, &b, &a);
|
||||
|
||||
// Imprimir algunos píxeles para depuración
|
||||
if (x < 5 && y < 5)
|
||||
{
|
||||
std::cout << "Pixel (" << x << "," << y << ") - RGBA("
|
||||
<< (int)r << "," << (int)g << "," << (int)b << "," << (int)a << ")" << std::endl;
|
||||
}
|
||||
|
||||
// No filtrar por alfa por ahora
|
||||
pixels.push_back({x, y, r, g, b, a});
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Cantidad de píxeles a renderizar: " << pixels.size() << std::endl;
|
||||
|
||||
// Liberar recursos
|
||||
SDL_FreeFormat(pixel_format);
|
||||
SDL_FreeSurface(temp_surface);
|
||||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
void Logo::renderAndEvaporate(SDL_Renderer *renderer, std::vector<Pixel> &pixels)
|
||||
{
|
||||
for (auto &pixel : pixels)
|
||||
{
|
||||
// Establecer el color para el píxel actual
|
||||
SDL_SetRenderDrawColor(renderer, pixel.r, pixel.g, pixel.b, pixel.a);
|
||||
// Dibujar el píxel
|
||||
SDL_RenderDrawPoint(renderer, pixel.x, pixel.y);
|
||||
// Evaporar el píxel
|
||||
// pixel.evaporate();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <SDL2/SDL_rect.h> // Para SDL_Point
|
||||
#include <SDL2/SDL_stdinc.h> // Para Uint32
|
||||
#include <SDL2/SDL.h>
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <vector> // Para vector
|
||||
class Sprite;
|
||||
@@ -16,6 +17,21 @@ struct Color;
|
||||
ZX Spectrum
|
||||
*/
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
int x, y; // Coordenadas del píxel
|
||||
Uint8 r, g, b, a; // Color del píxel
|
||||
|
||||
// Método para ascender y desvanecerse
|
||||
void evaporate()
|
||||
{
|
||||
y -= 1; // Asciende hacia arriba
|
||||
a = (a > 5) ? a - 5 : 0; // Desvanece el alfa (transparencia)
|
||||
// Añadir movimiento zig-zag aleatorio
|
||||
x += (rand() % 3 - 1); // Movimiento horizontal aleatorio (-1, 0, 1)
|
||||
}
|
||||
};
|
||||
|
||||
// Clase Logo
|
||||
class Logo
|
||||
{
|
||||
@@ -45,6 +61,9 @@ private:
|
||||
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
|
||||
SDL_Point dest_; // Posición X donde dibujar el logo
|
||||
LogoState state_ = LogoState::JAILGAMES; // El estado indica qué logo se está procesando
|
||||
Uint32 ticks_start_ = 0; // Almacena el valor actual de los ticks de SDL
|
||||
std::vector<Pixel> pixels_; // Vector con los pixels que forman el logo de "RETROWEEKEND"
|
||||
SDL_Texture *mi_textura;
|
||||
|
||||
// Actualiza las variables
|
||||
void update();
|
||||
@@ -76,6 +95,10 @@ private:
|
||||
// Recarga todas las texturas
|
||||
void reloadTextures();
|
||||
|
||||
std::vector<Pixel> extractPixels(SDL_Texture *texture);
|
||||
|
||||
void renderAndEvaporate(SDL_Renderer *renderer, std::vector<Pixel> &pixels);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Logo();
|
||||
|
||||
Reference in New Issue
Block a user