Tratando de eliminar las variables globales
This commit is contained in:
@@ -54,6 +54,9 @@ un tipo asociado diferente a NO_KIND
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
//La ventana donde dibujamos
|
||||
SDL_Window *gWindow = NULL;
|
||||
|
||||
//Arranca SDL y crea la ventana
|
||||
bool init();
|
||||
|
||||
@@ -90,23 +93,6 @@ bool init()
|
||||
success = false;
|
||||
}
|
||||
|
||||
//Comprueba los mandos
|
||||
if (SDL_NumJoysticks() < 1)
|
||||
{
|
||||
printf("Warning: No joysticks connected!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Carga el mando
|
||||
gGameController = SDL_JoystickOpen(0);
|
||||
if (gGameController == NULL)
|
||||
{
|
||||
printf("Warning: Unable to open game controller! SDL Error: %s\n", SDL_GetError());
|
||||
}
|
||||
printf("%i joysticks were found.\n", SDL_NumJoysticks());
|
||||
std::cout << SDL_JoystickNumButtons(gGameController) << " buttons\n";
|
||||
}
|
||||
|
||||
//Crea la ventana
|
||||
gWindow = SDL_CreateWindow("Super Popping (Like Loc) in Jailers World", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, VIEW_WIDTH, VIEW_HEIGHT, SDL_WINDOW_SHOWN);
|
||||
if (gWindow == NULL)
|
||||
@@ -214,38 +200,6 @@ bool loadMedia()
|
||||
success = false;
|
||||
}
|
||||
|
||||
//Carga la música del titulo
|
||||
gTitleMusic = Mix_LoadMUS("media/music/title.ogg");
|
||||
if (gTitleMusic == NULL)
|
||||
{
|
||||
printf("Failed to load title music! SDL_mixer Error: %s\n", Mix_GetError());
|
||||
success = false;
|
||||
}
|
||||
|
||||
//Carga la música del juego
|
||||
gPlayingMusic = Mix_LoadMUS("media/music/playing.ogg");
|
||||
if (gPlayingMusic == NULL)
|
||||
{
|
||||
printf("Failed to load playing music! SDL_mixer Error: %s\n", Mix_GetError());
|
||||
success = false;
|
||||
}
|
||||
|
||||
//Carga los efectos de sonido para la explosión de los globos
|
||||
gPopBalloonFX = Mix_LoadWAV("media/sound/balloon.wav");
|
||||
if (gPopBalloonFX == NULL)
|
||||
{
|
||||
printf("Failed to load balloon sound effect! SDL_mixer Error: %s\n", Mix_GetError());
|
||||
success = false;
|
||||
}
|
||||
|
||||
//Carga los efectos de sonido para los disparos del jugador
|
||||
gBulletFX = Mix_LoadWAV("media/sound/bullet.wav");
|
||||
if (gBulletFX == NULL)
|
||||
{
|
||||
printf("Failed to load bullet sound effect! SDL_mixer Error: %s\n", Mix_GetError());
|
||||
success = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -262,22 +216,6 @@ void close()
|
||||
gBalloonTexture.free();
|
||||
gMiscTexture.free();
|
||||
|
||||
//Libera los efectos de sonido
|
||||
Mix_FreeChunk(gPopBalloonFX);
|
||||
Mix_FreeChunk(gBulletFX);
|
||||
gPopBalloonFX = NULL;
|
||||
gBulletFX = NULL;
|
||||
|
||||
//Libra la música
|
||||
Mix_FreeMusic(gTitleMusic);
|
||||
gTitleMusic = NULL;
|
||||
Mix_FreeMusic(gPlayingMusic);
|
||||
gPlayingMusic = NULL;
|
||||
|
||||
//Libera el mando
|
||||
SDL_JoystickClose(gGameController);
|
||||
gGameController = NULL;
|
||||
|
||||
//Destruye la ventana
|
||||
SDL_DestroyRenderer(gRenderer);
|
||||
SDL_DestroyWindow(gWindow);
|
||||
|
||||
Reference in New Issue
Block a user