Trabajando en integrar la clase screen
This commit is contained in:
@@ -5,10 +5,11 @@
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Intro::Intro(SDL_Renderer *renderer, std::string *fileList, Lang *lang)
|
||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, std::string *fileList, Lang *lang)
|
||||
{
|
||||
// Copia los punteros
|
||||
mRenderer = renderer;
|
||||
mScreen = screen;
|
||||
mFileList = fileList;
|
||||
mLang = lang;
|
||||
|
||||
@@ -28,6 +29,11 @@ Intro::Intro(SDL_Renderer *renderer, std::string *fileList, Lang *lang)
|
||||
// Destructor
|
||||
Intro::~Intro()
|
||||
{
|
||||
mRenderer = nullptr;
|
||||
mScreen = nullptr;
|
||||
mFileList = nullptr;
|
||||
mLang = nullptr;
|
||||
|
||||
delete mEventHandler;
|
||||
mEventHandler = nullptr;
|
||||
|
||||
@@ -210,28 +216,29 @@ section_t Intro::run()
|
||||
|
||||
while (mSection.name == PROG_SECTION_INTRO)
|
||||
{
|
||||
// Comprueba los eventos que hay en la cola
|
||||
while (SDL_PollEvent(mEventHandler) != 0)
|
||||
{
|
||||
// Evento de salida de la aplicación
|
||||
if (mEventHandler->type == SDL_QUIT)
|
||||
{
|
||||
mSection.name = PROG_SECTION_QUIT;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((mEventHandler->type == SDL_KEYDOWN) || (mEventHandler->type == SDL_JOYBUTTONDOWN))
|
||||
{
|
||||
JA_StopMusic();
|
||||
mSection = {PROG_SECTION_TITLE, TITLE_SECTION_1};
|
||||
}
|
||||
}
|
||||
|
||||
// Calcula la lógica del bucle
|
||||
if (SDL_GetTicks() - mTicks > mTicksSpeed)
|
||||
{
|
||||
// Actualiza el contador de ticks
|
||||
mTicks = SDL_GetTicks();
|
||||
|
||||
// Comprueba los eventos que hay en la cola
|
||||
while (SDL_PollEvent(mEventHandler) != 0)
|
||||
{
|
||||
// Evento de salida de la aplicación
|
||||
if (mEventHandler->type == SDL_QUIT)
|
||||
{
|
||||
mSection.name = PROG_SECTION_QUIT;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((mEventHandler->type == SDL_KEYDOWN) || (mEventHandler->type == SDL_JOYBUTTONDOWN))
|
||||
{
|
||||
JA_StopMusic();
|
||||
mSection = {PROG_SECTION_TITLE, TITLE_SECTION_1};
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza los objetos
|
||||
for (int i = 0; i < INTRO_TOTAL_BITMAPS; i++)
|
||||
mBitmap[i]->update();
|
||||
@@ -352,8 +359,14 @@ section_t Intro::run()
|
||||
}
|
||||
|
||||
// Limpia la pantalla
|
||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 0xFF);
|
||||
SDL_RenderClear(mRenderer);
|
||||
//SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 0xFF);
|
||||
//SDL_RenderClear(mRenderer);
|
||||
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
mScreen->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
mScreen->clean(bgColor);
|
||||
|
||||
// Dibuja los objetos
|
||||
for (int i = 0; i < INTRO_TOTAL_BITMAPS; i++)
|
||||
@@ -362,7 +375,10 @@ section_t Intro::run()
|
||||
mWriter[i]->render();
|
||||
|
||||
// Actualiza la pantalla
|
||||
SDL_RenderPresent(mRenderer);
|
||||
//SDL_RenderPresent(mRenderer);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
mScreen->blit();
|
||||
}
|
||||
|
||||
return mSection;
|
||||
|
||||
Reference in New Issue
Block a user