Arreglada la calse text
This commit is contained in:
94
main.cpp
Normal file
94
main.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
|
||||
Ejemplo de uso de las unidades incluídas en jail_engine
|
||||
Código fuente creado por JailDesigner
|
||||
|
||||
*/
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <iostream>
|
||||
#include "units/jail_audio.h"
|
||||
#include "units/text.h"
|
||||
#include "units/utils.h"
|
||||
|
||||
SDL_Event *event;
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
// Inicializa las opciones
|
||||
struct options_t *options = new options_t;
|
||||
options->gameWidth = 640;
|
||||
options->gameHeight = 480;
|
||||
|
||||
// Inicializa SDL y la ventana
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
window = SDL_CreateWindow("jail_engine_demo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, options->gameWidth, options->gameHeight, SDL_WINDOW_SHOWN);
|
||||
if (window != nullptr)
|
||||
{
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
}
|
||||
event = new SDL_Event();
|
||||
|
||||
// Inicializa jail_audio
|
||||
JA_Init(48000, AUDIO_S16, 2);
|
||||
|
||||
JA_Music_t *music;
|
||||
JA_Sound_t *peiv;
|
||||
|
||||
music = JA_LoadMusic("data/music.ogg");
|
||||
peiv = JA_LoadSound("data/sound.wav");
|
||||
int volume = 128;
|
||||
|
||||
// Inicializa el texto
|
||||
Text *text = new Text("data/smb2.txt", "data/smb2.png", renderer);
|
||||
|
||||
// Bucle principal
|
||||
JA_PlayMusic(music, true);
|
||||
bool should_exit = false;
|
||||
while (!should_exit)
|
||||
{
|
||||
|
||||
// Actualiza la lógica del programa
|
||||
while (SDL_PollEvent(event))
|
||||
{
|
||||
if (event->type == SDL_QUIT)
|
||||
{
|
||||
should_exit = true;
|
||||
break;
|
||||
}
|
||||
if (event->type == SDL_KEYDOWN)
|
||||
{
|
||||
switch (event->key.keysym.scancode)
|
||||
{
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja en pantalla
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
text->writeCentered(options->gameWidth / 2 ,text->getCharacterSize(),"Jail Engine DEMO");
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
// Finaliza el texto
|
||||
delete text;
|
||||
|
||||
// Finaliza jail_audio
|
||||
JA_DeleteSound(peiv);
|
||||
JA_DeleteMusic(music);
|
||||
|
||||
// Finaliza SDL y la ventana
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
delete event;
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user