Trabajando en la clase screen
This commit is contained in:
@@ -6,31 +6,38 @@ Prog::Prog(std::string executablePath)
|
||||
// Establece las opciones por defecto
|
||||
options = new options_t;
|
||||
options->fullScreenMode = 0;
|
||||
options->windowSize = 1;
|
||||
options->windowSize = 3;
|
||||
options->filter = FILTER_NEAREST;
|
||||
options->vSync = true;
|
||||
options->screenWidth = 320;
|
||||
options->screenHeight = 240;
|
||||
options->screenWidth = GAME_WIDTH * options->windowSize;
|
||||
options->screenHeight = GAME_HEIGHT * options->windowSize;
|
||||
options->integerScale = true;
|
||||
options->keepAspect = true;
|
||||
|
||||
// Crea los objetos
|
||||
asset = new Asset(executablePath);
|
||||
input = new Input(asset->get("gamecontrollerdb.txt"));
|
||||
screen = new Screen(renderer,320,240,320,240);
|
||||
|
||||
// Inicializa las variables
|
||||
section.name = PROG_SECTION_GAME;
|
||||
|
||||
// Inicia las librerias
|
||||
initSDL();
|
||||
initJailAudio();
|
||||
|
||||
// Crea los objetos
|
||||
asset = new Asset(executablePath.substr(0, executablePath.find_last_of("\\/")));
|
||||
if (!setFileList())
|
||||
{
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
section.name = SECTION_PROG_GAME;
|
||||
}
|
||||
input = new Input(asset->get("gamecontrollerdb.txt"));
|
||||
screen = new Screen(window, renderer, options->screenWidth, options->screenWidth, GAME_WIDTH, GAME_HEIGHT);
|
||||
}
|
||||
|
||||
Prog::~Prog()
|
||||
{
|
||||
delete options;
|
||||
delete asset;
|
||||
delete input;
|
||||
delete options;
|
||||
delete screen;
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
@@ -67,7 +74,7 @@ bool Prog::initSDL()
|
||||
}
|
||||
|
||||
// Crea la ventana
|
||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options->screenWidth * options->windowSize, options->screenHeight * options->windowSize, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options->screenWidth, options->screenHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||
if (window == NULL)
|
||||
{
|
||||
printf("Window could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||
@@ -100,7 +107,7 @@ bool Prog::initSDL()
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf("SDL is running...\n");
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -154,30 +161,28 @@ void Prog::setSection(section_t section)
|
||||
|
||||
void Prog::runGame()
|
||||
{
|
||||
game = new Game();
|
||||
//setSection(game->run());
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
setSection(section);
|
||||
game = new Game(renderer, asset, screen, input);
|
||||
setSection(game->run());
|
||||
delete game;
|
||||
}
|
||||
|
||||
void Prog::run()
|
||||
{
|
||||
// Bucle principal
|
||||
while (!(getSection() == PROG_SECTION_QUIT))
|
||||
while (!(getSection() == SECTION_PROG_QUIT))
|
||||
{
|
||||
switch (getSection())
|
||||
{
|
||||
case PROG_SECTION_LOGO:
|
||||
//runLogo();
|
||||
case SECTION_PROG_LOGO:
|
||||
// runLogo();
|
||||
break;
|
||||
case PROG_SECTION_INTRO:
|
||||
//runIntro();
|
||||
case SECTION_PROG_INTRO:
|
||||
// runIntro();
|
||||
break;
|
||||
case PROG_SECTION_TITLE:
|
||||
//runTitle();
|
||||
case SECTION_PROG_TITLE:
|
||||
// runTitle();
|
||||
break;
|
||||
case PROG_SECTION_GAME:
|
||||
case SECTION_PROG_GAME:
|
||||
runGame();
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user