Demo: añadida la clase screen
This commit is contained in:
22
main.cpp
22
main.cpp
@@ -13,6 +13,7 @@ Código fuente creado por JailDesigner
|
||||
#include "units/asset.h"
|
||||
#include "units/movingsprite.h"
|
||||
#include "units/texture.h"
|
||||
#include "units/screen.h"
|
||||
|
||||
SDL_Event *event;
|
||||
SDL_Window *window;
|
||||
@@ -30,6 +31,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Inicializa las opciones
|
||||
struct options_t *options = new options_t;
|
||||
initOptions(options);
|
||||
options->gameWidth = 640;
|
||||
options->gameHeight = 480;
|
||||
options->console = true;
|
||||
@@ -41,6 +43,8 @@ int main(int argc, char *argv[])
|
||||
asset->add("/data/smb2.txt", t_font);
|
||||
asset->add("/data/smb2.png", t_bitmap);
|
||||
asset->add("/data/z80.png", t_bitmap);
|
||||
asset->add("/data/notify.png", t_bitmap);
|
||||
asset->add("/data/notify.wav", t_sound);
|
||||
asset->setVerbose(options->console);
|
||||
if (!asset->check())
|
||||
{
|
||||
@@ -74,6 +78,10 @@ int main(int argc, char *argv[])
|
||||
sound = JA_LoadSound(asset->get("sound.wav").c_str());
|
||||
int volume = 128;
|
||||
|
||||
// Inicializa el objeto screen
|
||||
Screen *screen = new Screen(window, renderer, options);
|
||||
screen->addNotifier(asset->get("notify.png"), asset->get("smb2.png"), asset->get("smb2.txt"), asset->get("notify.wav"));
|
||||
|
||||
// Inicializa el texto
|
||||
Text *text = new Text(asset->get("smb2.txt"), asset->get("smb2.png"), renderer);
|
||||
|
||||
@@ -160,7 +168,7 @@ int main(int argc, char *argv[])
|
||||
sprite->update();
|
||||
|
||||
// Actualiza el degradado
|
||||
//if (counter % 4 == 0)
|
||||
// if (counter % 4 == 0)
|
||||
{
|
||||
gradBreathDirection == 0 ? gradCurrentColor-- : gradCurrentColor++;
|
||||
if (gradCurrentColor == gradColorMin)
|
||||
@@ -175,8 +183,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Dibuja en pantalla
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
//SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||
//SDL_RenderClear(renderer);
|
||||
screen->start();
|
||||
screen->clean();
|
||||
// Dibuja un degradado de fondo
|
||||
const int gradFirstLine = options->gameHeight / 3;
|
||||
const int gradLastLine = options->gameHeight;
|
||||
@@ -195,7 +205,8 @@ int main(int argc, char *argv[])
|
||||
// Dibuja el sprite
|
||||
sprite->render();
|
||||
// Vuelca el buffer en pantalla
|
||||
SDL_RenderPresent(renderer);
|
||||
//SDL_RenderPresent(renderer);
|
||||
screen->blit();
|
||||
}
|
||||
|
||||
// Finaliza el sprite
|
||||
@@ -205,6 +216,9 @@ int main(int argc, char *argv[])
|
||||
// Finaliza el texto
|
||||
delete text;
|
||||
|
||||
// Finaliza el objeto screen
|
||||
delete screen;
|
||||
|
||||
// Finaliza jail_audio
|
||||
JA_DeleteSound(sound);
|
||||
JA_DeleteMusic(music);
|
||||
|
||||
Reference in New Issue
Block a user