Arreglats alguns colorets que havia per ahi rebolicats
fix: Credits no estava ben portat a surfaces
This commit is contained in:
@@ -162,47 +162,31 @@ void Credits::fillTexture()
|
|||||||
const int TEXT_LENGHT = text->lenght(texts_[22].label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
const int TEXT_LENGHT = text->lenght(texts_[22].label, 1) - text->lenght(" ", 1); // Se resta el ultimo caracter que es un espacio
|
||||||
const int POS_X = ((PLAY_AREA_WIDTH - TEXT_LENGHT) / 2) + TEXT_LENGHT;
|
const int POS_X = ((PLAY_AREA_WIDTH - TEXT_LENGHT) / 2) + TEXT_LENGHT;
|
||||||
text->writeColored(POS_X, 176, "}", static_cast<Uint8>(PaletteColor::BRIGHT_RED));
|
text->writeColored(POS_X, 176, "}", static_cast<Uint8>(PaletteColor::BRIGHT_RED));
|
||||||
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
|
|
||||||
// Recoloca el sprite del brillo
|
// Recoloca el sprite del brillo
|
||||||
shining_sprite_->setPosX(POS_X + 2);
|
shining_sprite_->setPosX(POS_X + 2);
|
||||||
|
|
||||||
// Rellena la textura que cubre el texto con color transparente
|
// Rellena la textura que cubre el texto con color transparente
|
||||||
text_surface_->clear(static_cast<Uint8>(PaletteColor::TRANSPARENT));
|
cover_surface_->clear(static_cast<Uint8>(PaletteColor::TRANSPARENT));
|
||||||
|
|
||||||
// Los primeros 8 pixels crea una malla
|
// Los primeros 8 pixels crea una malla
|
||||||
auto surface = Screen::get()->getRendererSurface();
|
|
||||||
auto color = static_cast<Uint8>(PaletteColor::BLACK);
|
auto color = static_cast<Uint8>(PaletteColor::BLACK);
|
||||||
for (int i = 0; i < 256; i += 2)
|
for (int i = 0; i < 256; i += 2)
|
||||||
{
|
{
|
||||||
surface->putPixel(i, 0, color);
|
cover_surface_->putPixel(i, 0, color);
|
||||||
surface->putPixel(i, 2, color);
|
cover_surface_->putPixel(i, 2, color);
|
||||||
surface->putPixel(i, 4, color);
|
cover_surface_->putPixel(i, 4, color);
|
||||||
surface->putPixel(i, 6, color);
|
cover_surface_->putPixel(i, 6, color);
|
||||||
|
|
||||||
surface->putPixel(i + 1, 5, color);
|
cover_surface_->putPixel(i + 1, 5, color);
|
||||||
surface->putPixel(i + 1, 7, color);
|
cover_surface_->putPixel(i + 1, 7, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// El resto se rellena de color sólido
|
// El resto se rellena de color sólido
|
||||||
SDL_Rect rect = {0, 8, 256, 192};
|
SDL_Rect rect = {0, 8, 256, 192};
|
||||||
surface->fillRect(&rect, color);
|
cover_surface_->fillRect(&rect, color);
|
||||||
|
|
||||||
for (int i = 0; i < 256; i += 2)
|
|
||||||
{
|
|
||||||
surface->putPixel(i, 0, color);
|
|
||||||
surface->putPixel(i, 2, color);
|
|
||||||
surface->putPixel(i, 4, color);
|
|
||||||
surface->putPixel(i, 6, color);
|
|
||||||
|
|
||||||
surface->putPixel(i + 1, 5, color);
|
|
||||||
surface->putPixel(i + 1, 7, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// El resto se rellena de color sólido
|
|
||||||
rect = {0, 8, 256, 192};
|
|
||||||
surface->fillRect(&rect, color);
|
|
||||||
|
|
||||||
Screen::get()->setRendererSurface(previuos_renderer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
@@ -266,7 +250,7 @@ void Credits::render()
|
|||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
Screen::get()->clearSurface(1);
|
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
if (counter_ < 1150)
|
if (counter_ < 1150)
|
||||||
{
|
{
|
||||||
@@ -279,7 +263,7 @@ void Credits::render()
|
|||||||
cover_surface_->render(0, offset * 2, &srcRect);
|
cover_surface_->render(0, offset * 2, &srcRect);
|
||||||
|
|
||||||
// Dibuja el sprite con el brillo
|
// Dibuja el sprite con el brillo
|
||||||
shining_sprite_->render();
|
shining_sprite_->render(1, static_cast<Uint8>(PaletteColor::BRIGHT_WHITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ Logo::Logo()
|
|||||||
since_1998_sprite_(std::make_shared<SSprite>(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight()))
|
since_1998_sprite_(std::make_shared<SSprite>(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight()))
|
||||||
{
|
{
|
||||||
since_1998_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight());
|
since_1998_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight());
|
||||||
since_1998_color_ = static_cast<Uint8>(PaletteColor::BRIGHT_BLACK);
|
since_1998_color_ = static_cast<Uint8>(PaletteColor::BLACK);
|
||||||
jailgames_color_ = static_cast<Uint8>(PaletteColor::WHITE);
|
jailgames_color_ = static_cast<Uint8>(PaletteColor::WHITE);
|
||||||
|
|
||||||
// Crea los sprites de cada linea
|
// Crea los sprites de cada linea
|
||||||
@@ -51,7 +51,7 @@ Logo::Logo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BRIGHT_BLACK));
|
Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
@@ -227,7 +227,7 @@ void Logo::render()
|
|||||||
{
|
{
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
Screen::get()->clearSurface();
|
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
// Dibuja los objetos
|
// Dibuja los objetos
|
||||||
for (const auto &s : jailgames_sprite_)
|
for (const auto &s : jailgames_sprite_)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ constexpr Subsection DEFAULT_SUBSECTION = Subsection::LOGO_TO_INTRO;
|
|||||||
constexpr ControlScheme DEFAULT_CONTROL_SCHEME = ControlScheme::CURSOR; // Control por defecto
|
constexpr ControlScheme DEFAULT_CONTROL_SCHEME = ControlScheme::CURSOR; // Control por defecto
|
||||||
constexpr NotificationPosition DEFAULT_NOTIFICATION_POSITION = NotificationPosition::UPPER_LEFT; // Posición de las notificaciones por defecto
|
constexpr NotificationPosition DEFAULT_NOTIFICATION_POSITION = NotificationPosition::UPPER_LEFT; // Posición de las notificaciones por defecto
|
||||||
constexpr bool DEFAULT_NOTIFICATION_SOUND = true; // Sonido de las notificaciones por defecto
|
constexpr bool DEFAULT_NOTIFICATION_SOUND = true; // Sonido de las notificaciones por defecto
|
||||||
const Uint8 DEFAULT_NOTIFICATION_COLOR = 1; // Color de las notificaciones por defecto
|
const Uint8 DEFAULT_NOTIFICATION_COLOR = static_cast<Uint8>(PaletteColor::BLACK); // Color de las notificaciones por defecto
|
||||||
constexpr bool DEFAULT_CONSOLE = false; // Consola desactivada por defecto
|
constexpr bool DEFAULT_CONSOLE = false; // Consola desactivada por defecto
|
||||||
constexpr const char *DEFAULT_VERSION = "1.10"; // Versión por defecto
|
constexpr const char *DEFAULT_VERSION = "1.10"; // Versión por defecto
|
||||||
|
|
||||||
|
|||||||
@@ -428,18 +428,16 @@ void Resource::renderProgress()
|
|||||||
constexpr int BAR_HEIGHT = 10;
|
constexpr int BAR_HEIGHT = 10;
|
||||||
const int bar_position = options.game.height - BAR_HEIGHT - Y_PADDING;
|
const int bar_position = options.game.height - BAR_HEIGHT - Y_PADDING;
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
Screen::get()->clearSurface();
|
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
auto surface = Screen::get()->getRendererSurface();
|
auto surface = Screen::get()->getRendererSurface();
|
||||||
const int wired_bar_width = options.game.width - (X_PADDING * 2);
|
const int wired_bar_width = options.game.width - (X_PADDING * 2);
|
||||||
SDL_Rect rect_wired = {X_PADDING, bar_position, wired_bar_width, X_PADDING};
|
SDL_Rect rect_wired = {X_PADDING, bar_position, wired_bar_width, X_PADDING};
|
||||||
surface->drawRectBorder(&rect_wired, stringToColor("white"));
|
surface->drawRectBorder(&rect_wired, static_cast<Uint8>(PaletteColor::WHITE));
|
||||||
|
|
||||||
const int full_bar_width = wired_bar_width * count_.getPercentage();
|
const int full_bar_width = wired_bar_width * count_.getPercentage();
|
||||||
SDL_Rect rect_full = {X_PADDING, bar_position, full_bar_width, X_PADDING};
|
SDL_Rect rect_full = {X_PADDING, bar_position, full_bar_width, X_PADDING};
|
||||||
surface->fillRect(&rect_full, stringToColor("white"));
|
surface->fillRect(&rect_full, static_cast<Uint8>(PaletteColor::WHITE));
|
||||||
|
|
||||||
Screen::get()->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los eventos de la pantalla de carga
|
// Comprueba los eventos de la pantalla de carga
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
|||||||
current_palette_ = findPalette(options.video.palette);
|
current_palette_ = findPalette(options.video.palette);
|
||||||
|
|
||||||
// Define el color del borde para el modo de pantalla completa
|
// Define el color del borde para el modo de pantalla completa
|
||||||
border_color_ = 1;
|
border_color_ = static_cast<Uint8>(PaletteColor::BLACK);
|
||||||
|
|
||||||
// Establece el modo de escalado
|
// Establece el modo de escalado
|
||||||
SDL_RenderSetIntegerScale(renderer_, options.video.integer_scale ? SDL_TRUE : SDL_FALSE);
|
SDL_RenderSetIntegerScale(renderer_, options.video.integer_scale ? SDL_TRUE : SDL_FALSE);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public:
|
|||||||
|
|
||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
void clear(Color color = {0x00, 0x00, 0x00});
|
void clear(Color color = {0x00, 0x00, 0x00});
|
||||||
void clearSurface(Uint8 index = 1);
|
void clearSurface(Uint8 index = 0);
|
||||||
|
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
void start();
|
void start();
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ Title::Title()
|
|||||||
createCheevosTexture();
|
createCheevosTexture();
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BRIGHT_BLACK));
|
Screen::get()->setBorderColor(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
// Rellena la textura de fondo con todos los gráficos
|
// Rellena la textura de fondo con todos los gráficos
|
||||||
fillSurface();
|
fillSurface();
|
||||||
@@ -164,7 +164,8 @@ void Title::updateMarquee()
|
|||||||
|
|
||||||
// Comprueba si ha terminado la marquesina y la reinicia
|
// Comprueba si ha terminado la marquesina y la reinicia
|
||||||
if (letters_[letters_.size() - 1].x < -10)
|
if (letters_[letters_.size() - 1].x < -10)
|
||||||
{ // Inicializa la marquesina
|
{
|
||||||
|
// Inicializa la marquesina
|
||||||
initMarquee();
|
initMarquee();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,10 +247,11 @@ void Title::render()
|
|||||||
{
|
{
|
||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
Screen::get()->clearSurface(stringToColor("black"));
|
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
if (state_ == TitleState::SHOW_MENU)
|
switch (state_)
|
||||||
{
|
{
|
||||||
|
case TitleState::SHOW_MENU:
|
||||||
// Dibuja la textura de fondo
|
// Dibuja la textura de fondo
|
||||||
bg_surface_->render(0, 0);
|
bg_surface_->render(0, 0);
|
||||||
|
|
||||||
@@ -261,9 +263,10 @@ void Title::render()
|
|||||||
{
|
{
|
||||||
cheevos_sprite_->render();
|
cheevos_sprite_->render();
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
case TitleState::SHOW_LOADING_SCREEN:
|
||||||
|
case TitleState::FADE_LOADING_SCREEN:
|
||||||
// Dibuja la pantalla de carga
|
// Dibuja la pantalla de carga
|
||||||
pCls(4);
|
pCls(4);
|
||||||
pBlit(0, 0, 0, 0, 256, 128);
|
pBlit(0, 0, 0, 0, 256, 128);
|
||||||
@@ -271,6 +274,10 @@ void Title::render()
|
|||||||
|
|
||||||
// Dibuja el logo del título
|
// Dibuja el logo del título
|
||||||
title_logo_sprite_->render();
|
title_logo_sprite_->render();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
@@ -291,18 +298,13 @@ void Title::run()
|
|||||||
// Desplaza la lista de logros
|
// Desplaza la lista de logros
|
||||||
void Title::moveCheevosList(int direction)
|
void Title::moveCheevosList(int direction)
|
||||||
{
|
{
|
||||||
const int speed = 2;
|
// Modifica la posición de la ventana de vista
|
||||||
cheevos_surface_view_.y = direction == 0 ? cheevos_surface_view_.y - speed : cheevos_surface_view_.y + speed;
|
constexpr int SPEED = 2;
|
||||||
|
cheevos_surface_view_.y = direction == 0 ? cheevos_surface_view_.y - SPEED : cheevos_surface_view_.y + SPEED;
|
||||||
|
|
||||||
const int bottom = cheevos_surface_->getHeight() - cheevos_surface_view_.h;
|
// Ajusta los limites
|
||||||
if (cheevos_surface_view_.y < 0)
|
const int BOTTOM = cheevos_surface_->getHeight() - cheevos_surface_view_.h;
|
||||||
{
|
cheevos_surface_view_.y = std::clamp(cheevos_surface_view_.y, 0, BOTTOM);
|
||||||
cheevos_surface_view_.y = 0;
|
|
||||||
}
|
|
||||||
else if (cheevos_surface_view_.y > bottom)
|
|
||||||
{
|
|
||||||
cheevos_surface_view_.y = bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||||
}
|
}
|
||||||
@@ -315,7 +317,7 @@ void Title::fillSurface()
|
|||||||
Screen::get()->setRendererSurface(bg_surface_);
|
Screen::get()->setRendererSurface(bg_surface_);
|
||||||
|
|
||||||
// Rellena la textura de color
|
// Rellena la textura de color
|
||||||
bg_surface_->clear(1);
|
bg_surface_->clear(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
// Pinta el gráfico del titulo a partir del sprite
|
// Pinta el gráfico del titulo a partir del sprite
|
||||||
title_logo_sprite_->render();
|
title_logo_sprite_->render();
|
||||||
@@ -327,7 +329,6 @@ void Title::fillSurface()
|
|||||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 11 * TEXT_SIZE, "1.PLAY", 1, COLOR);
|
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 11 * TEXT_SIZE, "1.PLAY", 1, COLOR);
|
||||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * TEXT_SIZE, "2.ACHIEVEMENTS", 1, COLOR);
|
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * TEXT_SIZE, "2.ACHIEVEMENTS", 1, COLOR);
|
||||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * TEXT_SIZE, "3.REDEFINE KEYS", 1, COLOR);
|
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * TEXT_SIZE, "3.REDEFINE KEYS", 1, COLOR);
|
||||||
//text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 20 * TEXT_SIZE, "ESC.EXIT GAME", 1, COLOR);
|
|
||||||
|
|
||||||
// Devuelve el puntero del renderizador a su sitio
|
// Devuelve el puntero del renderizador a su sitio
|
||||||
Screen::get()->setRendererSurface(previuos_renderer);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
@@ -352,7 +353,7 @@ void Title::createCheevosTexture()
|
|||||||
Screen::get()->setRendererSurface(cheevos_surface_);
|
Screen::get()->setRendererSurface(cheevos_surface_);
|
||||||
|
|
||||||
// Rellena la textura con color sólido
|
// Rellena la textura con color sólido
|
||||||
const Uint8 CHEEVOS_BG_COLOR = stringToColor("black");
|
const Uint8 CHEEVOS_BG_COLOR = static_cast<Uint8>(PaletteColor::BLACK);
|
||||||
cheevos_surface_->clear(CHEEVOS_BG_COLOR);
|
cheevos_surface_->clear(CHEEVOS_BG_COLOR);
|
||||||
|
|
||||||
// Escribe la lista de logros en la textura
|
// Escribe la lista de logros en la textura
|
||||||
@@ -363,20 +364,18 @@ void Title::createCheevosTexture()
|
|||||||
pos += TEXT->getCharacterSize();
|
pos += TEXT->getCharacterSize();
|
||||||
const Uint8 CHEEVO_LOCKED_COLOR = stringToColor("white");
|
const Uint8 CHEEVO_LOCKED_COLOR = stringToColor("white");
|
||||||
const Uint8 CHEEVO_UNLOCKED_COLOR = stringToColor("bright_green");
|
const Uint8 CHEEVO_UNLOCKED_COLOR = stringToColor("bright_green");
|
||||||
Uint8 cheevoColor;
|
|
||||||
constexpr int LINE_X1 = (CHEEVOS_TEXTURE_WIDTH / 7) * 3;
|
constexpr int LINE_X1 = (CHEEVOS_TEXTURE_WIDTH / 7) * 3;
|
||||||
constexpr int LINE_X2 = LINE_X1 + ((CHEEVOS_TEXTURE_WIDTH / 7) * 1);
|
constexpr int LINE_X2 = LINE_X1 + ((CHEEVOS_TEXTURE_WIDTH / 7) * 1);
|
||||||
|
|
||||||
for (const auto &cheevo : CHEEVOS_LIST)
|
for (const auto &cheevo : CHEEVOS_LIST)
|
||||||
{
|
{
|
||||||
cheevoColor = cheevo.completed ? CHEEVO_UNLOCKED_COLOR : CHEEVO_LOCKED_COLOR;
|
const Uint8 CHEEVO_COLOR = cheevo.completed ? CHEEVO_UNLOCKED_COLOR : CHEEVO_LOCKED_COLOR;
|
||||||
pos += CHEEVOS_PADDING;
|
pos += CHEEVOS_PADDING;
|
||||||
constexpr int HALF = CHEEVOS_PADDING / 2;
|
constexpr int HALF = CHEEVOS_PADDING / 2;
|
||||||
auto surface = Screen::get()->getRendererSurface();
|
cheevos_surface_->drawLine(LINE_X1, pos - HALF - 1, LINE_X2, pos - HALF - 1, CHEEVO_COLOR);
|
||||||
surface->drawLine(LINE_X1, pos - HALF - 1, LINE_X2, pos - HALF - 1, cheevoColor);
|
TEXT->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.caption, 1, CHEEVO_COLOR);
|
||||||
TEXT->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.caption, 1, cheevoColor);
|
|
||||||
pos += TEXT->getCharacterSize() + 1;
|
pos += TEXT->getCharacterSize() + 1;
|
||||||
TEXT->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.description, 1, cheevoColor);
|
TEXT->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.description, 1, CHEEVO_COLOR);
|
||||||
pos += TEXT->getCharacterSize();
|
pos += TEXT->getCharacterSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user