forked from jaildesigner-jailgames/jaildoctors_dilemma
Ya se dibuja el gif en pantalla
This commit is contained in:
@@ -39,6 +39,12 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
}
|
}
|
||||||
SDL_SetTextureBlendMode(bgTexture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(bgTexture, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
|
// Carga la surface con los gráficos de la pantalla de carga
|
||||||
|
pInit(renderer, 256, 192);
|
||||||
|
loading_screen = pLoadSurface("data/title/loading_screen_color.gif");
|
||||||
|
pLoadPal("data/title/loading_screen_color.gif");
|
||||||
|
pSetSource(loading_screen);
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section->name = SECTION_TITLE;
|
section->name = SECTION_TITLE;
|
||||||
@@ -48,6 +54,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *
|
|||||||
marqueeSpeed = 3;
|
marqueeSpeed = 3;
|
||||||
initMarquee();
|
initMarquee();
|
||||||
showCheevos = false;
|
showCheevos = false;
|
||||||
|
state = show_loading_screen;
|
||||||
|
|
||||||
// Crea y rellena la textura para mostrar los logros
|
// Crea y rellena la textura para mostrar los logros
|
||||||
createCheevosTexture();
|
createCheevosTexture();
|
||||||
@@ -69,6 +76,7 @@ Title::~Title()
|
|||||||
delete cheevosTexture;
|
delete cheevosTexture;
|
||||||
delete text;
|
delete text;
|
||||||
delete infoText;
|
delete infoText;
|
||||||
|
pDeleteSurface(loading_screen);
|
||||||
SDL_DestroyTexture(bgTexture);
|
SDL_DestroyTexture(bgTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,23 +272,43 @@ void Title::update()
|
|||||||
// Comprueba las entradas
|
// Comprueba las entradas
|
||||||
checkInput();
|
checkInput();
|
||||||
|
|
||||||
// Incrementa el contador
|
|
||||||
counter++;
|
|
||||||
|
|
||||||
// Actualiza la marquesina
|
|
||||||
updateMarquee();
|
|
||||||
|
|
||||||
// Actualiza las notificaciones
|
// Actualiza las notificaciones
|
||||||
screen->updateNotifier();
|
screen->updateNotifier();
|
||||||
|
|
||||||
// Si el contador alcanza cierto valor, termina la seccion
|
// Incrementa el contador
|
||||||
if (counter == 2200)
|
counter++;
|
||||||
|
|
||||||
|
switch (state)
|
||||||
{
|
{
|
||||||
if (!showCheevos)
|
case show_loading_screen:
|
||||||
|
if (counter == 500)
|
||||||
{
|
{
|
||||||
section->name = SECTION_CREDITS;
|
counter = 0;
|
||||||
section->subsection = 0;
|
state = show_menu;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case fade_loading_screen:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case show_menu:
|
||||||
|
|
||||||
|
// Actualiza la marquesina
|
||||||
|
updateMarquee();
|
||||||
|
|
||||||
|
// Si el contador alcanza cierto valor, termina la seccion
|
||||||
|
if (counter == 2200)
|
||||||
|
{
|
||||||
|
if (!showCheevos)
|
||||||
|
{
|
||||||
|
section->name = SECTION_CREDITS;
|
||||||
|
section->subsection = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,16 +319,36 @@ void Title::render()
|
|||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
screen->start();
|
screen->start();
|
||||||
|
|
||||||
// Dibuja la textura de fondo
|
switch (state)
|
||||||
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
|
|
||||||
|
|
||||||
// Dibuja la marquesina
|
|
||||||
renderMarquee();
|
|
||||||
|
|
||||||
// Dibuja la información de logros
|
|
||||||
if (showCheevos)
|
|
||||||
{
|
{
|
||||||
cheevosSprite->render();
|
case show_loading_screen:
|
||||||
|
// Dibuja la textura de fondo
|
||||||
|
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
|
||||||
|
|
||||||
|
// Dibuja la pantalla de carga
|
||||||
|
pBlit(0, 0, 0, 0, 256, 192);
|
||||||
|
pFlip(renderer);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case fade_loading_screen:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case show_menu:
|
||||||
|
// Dibuja la textura de fondo
|
||||||
|
SDL_RenderCopy(renderer, bgTexture, nullptr, nullptr);
|
||||||
|
|
||||||
|
// Dibuja la marquesina
|
||||||
|
renderMarquee();
|
||||||
|
|
||||||
|
// Dibuja la información de logros
|
||||||
|
if (showCheevos)
|
||||||
|
{
|
||||||
|
cheevosSprite->render();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "jail_engine/input.h"
|
#include "jail_engine/input.h"
|
||||||
#include "jail_engine/jail_audio.h"
|
#include "jail_engine/jail_audio.h"
|
||||||
#include "jail_engine/resource.h"
|
#include "jail_engine/resource.h"
|
||||||
|
#include "jail_engine/paleta.h"
|
||||||
#include "jail_engine/screen.h"
|
#include "jail_engine/screen.h"
|
||||||
#include "jail_engine/sprite.h"
|
#include "jail_engine/sprite.h"
|
||||||
#include "jail_engine/text.h"
|
#include "jail_engine/text.h"
|
||||||
@@ -28,6 +29,13 @@ private:
|
|||||||
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum states_e
|
||||||
|
{
|
||||||
|
show_loading_screen,
|
||||||
|
fade_loading_screen,
|
||||||
|
show_menu
|
||||||
|
};
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
@@ -57,6 +65,8 @@ private:
|
|||||||
int marqueeSpeed; // Velocidad de desplazamiento de la marquesina
|
int marqueeSpeed; // Velocidad de desplazamiento de la marquesina
|
||||||
bool showCheevos; // Indica si se muestra por pantalla el listado de logros
|
bool showCheevos; // Indica si se muestra por pantalla el listado de logros
|
||||||
SDL_Rect cheevosTextureView; // Zona visible de la textura con el listado de logros
|
SDL_Rect cheevosTextureView; // Zona visible de la textura con el listado de logros
|
||||||
|
states_e state; // Estado en el que se encuentra el bucle principal
|
||||||
|
jSurface loading_screen; // Surface con los gráficos de la pantalla de carga
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ struct jSurface_s
|
|||||||
Uint16 w, h;
|
Uint16 w, h;
|
||||||
};
|
};
|
||||||
|
|
||||||
static SDL_Window *jWin = NULL;
|
|
||||||
static SDL_Renderer *jRen = NULL;
|
|
||||||
static SDL_Texture *jTex = NULL;
|
static SDL_Texture *jTex = NULL;
|
||||||
static jSurface jScreen;
|
static jSurface jScreen;
|
||||||
static jSurface jDestSurf;
|
static jSurface jDestSurf;
|
||||||
@@ -17,9 +15,17 @@ static jSurface jSourceSurf = NULL;
|
|||||||
static Uint32 paleta[256];
|
static Uint32 paleta[256];
|
||||||
static int jWidth = 320;
|
static int jWidth = 320;
|
||||||
static int jHeight = 240;
|
static int jHeight = 240;
|
||||||
static int jZoom = 2;
|
|
||||||
static int transparentColor = 0;
|
static int transparentColor = 0;
|
||||||
|
|
||||||
|
void pInit(SDL_Renderer *renderer, int w, int h)
|
||||||
|
{
|
||||||
|
jWidth = w;
|
||||||
|
jHeight = h;
|
||||||
|
jTex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
|
||||||
|
jScreen = pNewSurface(w, h);
|
||||||
|
jDestSurf = jScreen;
|
||||||
|
}
|
||||||
|
|
||||||
jSurface pNewSurface(int w, int h)
|
jSurface pNewSurface(int w, int h)
|
||||||
{
|
{
|
||||||
jSurface surf = (jSurface)malloc(sizeof(jSurface_s));
|
jSurface surf = (jSurface)malloc(sizeof(jSurface_s));
|
||||||
@@ -115,20 +121,6 @@ void pLoadPal(const char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pInit(const char *titol, int w, int h, int z)
|
|
||||||
{
|
|
||||||
SDL_Init(SDL_INIT_EVERYTHING);
|
|
||||||
jWidth = w;
|
|
||||||
jHeight = h;
|
|
||||||
jZoom = z;
|
|
||||||
jWin = SDL_CreateWindow(titol, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w * z, h * z, SDL_WINDOW_SHOWN);
|
|
||||||
jRen = SDL_CreateRenderer(jWin, -1, 0);
|
|
||||||
SDL_RenderSetLogicalSize(jRen, w, h);
|
|
||||||
jTex = SDL_CreateTexture(jRen, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h);
|
|
||||||
jScreen = pNewSurface(w, h);
|
|
||||||
jDestSurf = jScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pSetPal(int index, Uint32 color)
|
void pSetPal(int index, Uint32 color)
|
||||||
{
|
{
|
||||||
paleta[index] = color;
|
paleta[index] = color;
|
||||||
@@ -140,7 +132,7 @@ void pCls(Uint8 color)
|
|||||||
jDestSurf->data[i] = color;
|
jDestSurf->data[i] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pFlip()
|
void pFlip(SDL_Renderer *renderer)
|
||||||
{
|
{
|
||||||
Uint32 *pixels;
|
Uint32 *pixels;
|
||||||
int pitch;
|
int pitch;
|
||||||
@@ -148,8 +140,8 @@ void pFlip()
|
|||||||
for (int i = 0; i < jWidth * jHeight; ++i)
|
for (int i = 0; i < jWidth * jHeight; ++i)
|
||||||
pixels[i] = paleta[jScreen->data[i]];
|
pixels[i] = paleta[jScreen->data[i]];
|
||||||
SDL_UnlockTexture(jTex);
|
SDL_UnlockTexture(jTex);
|
||||||
SDL_RenderCopy(jRen, jTex, NULL, NULL);
|
SDL_RenderCopy(renderer, jTex, NULL, NULL);
|
||||||
SDL_RenderPresent(jRen);
|
//SDL_RenderPresent(jRen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pPutPixel(int x, int y, Uint8 color)
|
void pPutPixel(int x, int y, Uint8 color)
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ Uint8 pGetPixel(int x, int y);
|
|||||||
|
|
||||||
void pBlit(int dx, int dy, int sx, int sy, int w, int h);
|
void pBlit(int dx, int dy, int sx, int sy, int w, int h);
|
||||||
|
|
||||||
void pInit(const char *titol, int w, int h, int z);
|
void pInit(SDL_Renderer *renderer, int w, int h);
|
||||||
|
|
||||||
void pSetPal(int index, Uint32 color);
|
void pSetPal(int index, Uint32 color);
|
||||||
void pLoadPal(const char *filename);
|
void pLoadPal(const char *filename);
|
||||||
|
|
||||||
void pCls(Uint8 color);
|
void pCls(Uint8 color);
|
||||||
|
|
||||||
void pFlip();
|
void pFlip(SDL_Renderer *renderer);
|
||||||
|
|||||||
Reference in New Issue
Block a user