Still working on the BIG FUCKING CONVERSION...
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.vscode/*
|
||||||
|
*.exe
|
||||||
@@ -24,14 +24,9 @@ bool AppController::Init(void)
|
|||||||
|
|
||||||
drawManager = new DrawManager(gameInfo->modeGrafic);
|
drawManager = new DrawManager(gameInfo->modeGrafic);
|
||||||
inputManager = new InputManager(gameInfo);
|
inputManager = new InputManager(gameInfo);
|
||||||
musicManager = new MusicManager();
|
|
||||||
|
|
||||||
if ( !drawManager->Init() ) { return false; }
|
if ( !drawManager->Init() ) { return false; }
|
||||||
musicManager->Init();
|
music_init();
|
||||||
|
|
||||||
SDL_WM_SetCaption( APPLICATION_NAME, NULL );
|
|
||||||
|
|
||||||
SDL_ShowCursor(0);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -44,43 +39,43 @@ void AppController::Go()
|
|||||||
switch ( gameInfo->estado ) {
|
switch ( gameInfo->estado ) {
|
||||||
case ESTADO_SEQUENCIA:
|
case ESTADO_SEQUENCIA:
|
||||||
SequenceController *sequenceController;
|
SequenceController *sequenceController;
|
||||||
sequenceController = new SequenceController(drawManager, inputManager, musicManager);
|
sequenceController = new SequenceController(drawManager, inputManager);
|
||||||
sequenceController->Go(gameInfo);
|
sequenceController->Go(gameInfo);
|
||||||
delete sequenceController;
|
delete sequenceController;
|
||||||
break;
|
break;
|
||||||
case ESTADO_MENU:
|
case ESTADO_MENU:
|
||||||
MenuController *menuController;
|
MenuController *menuController;
|
||||||
menuController = new MenuController(drawManager, inputManager, musicManager);
|
menuController = new MenuController(drawManager, inputManager);
|
||||||
menuController->Go(gameInfo);
|
menuController->Go(gameInfo);
|
||||||
delete menuController;
|
delete menuController;
|
||||||
break;
|
break;
|
||||||
case ESTADO_PASSWORD:
|
case ESTADO_PASSWORD:
|
||||||
PasswordController *passwordController;
|
PasswordController *passwordController;
|
||||||
passwordController = new PasswordController(drawManager, inputManager, musicManager);
|
passwordController = new PasswordController(drawManager, inputManager);
|
||||||
passwordController->Go(gameInfo);
|
passwordController->Go(gameInfo);
|
||||||
delete passwordController;
|
delete passwordController;
|
||||||
break;
|
break;
|
||||||
case ESTADO_PREFASE:
|
case ESTADO_PREFASE:
|
||||||
PrefaseController *prefaseController;
|
PrefaseController *prefaseController;
|
||||||
prefaseController = new PrefaseController(drawManager, inputManager, musicManager);
|
prefaseController = new PrefaseController(drawManager, inputManager);
|
||||||
prefaseController->Go(gameInfo);
|
prefaseController->Go(gameInfo);
|
||||||
delete prefaseController;
|
delete prefaseController;
|
||||||
break;
|
break;
|
||||||
case ESTADO_JUEGO:
|
case ESTADO_JUEGO:
|
||||||
GameController *gameController;
|
GameController *gameController;
|
||||||
gameController = new GameController(drawManager, inputManager, musicManager);
|
gameController = new GameController(drawManager, inputManager);
|
||||||
gameController->Go(gameInfo);
|
gameController->Go(gameInfo);
|
||||||
delete gameController;
|
delete gameController;
|
||||||
break;
|
break;
|
||||||
case ESTADO_POSTFASE:
|
case ESTADO_POSTFASE:
|
||||||
PostfaseController *postfaseController;
|
PostfaseController *postfaseController;
|
||||||
postfaseController = new PostfaseController(drawManager, inputManager, musicManager);
|
postfaseController = new PostfaseController(drawManager, inputManager);
|
||||||
postfaseController->Go(gameInfo);
|
postfaseController->Go(gameInfo);
|
||||||
delete postfaseController;
|
delete postfaseController;
|
||||||
break;
|
break;
|
||||||
case ESTADO_MORT:
|
case ESTADO_MORT:
|
||||||
MortController *mortController;
|
MortController *mortController;
|
||||||
mortController = new MortController(drawManager, inputManager, musicManager);
|
mortController = new MortController(drawManager, inputManager);
|
||||||
mortController->Go(gameInfo);
|
mortController->Go(gameInfo);
|
||||||
delete mortController;
|
delete mortController;
|
||||||
break;
|
break;
|
||||||
@@ -94,7 +89,6 @@ void AppController::Finalize(void)
|
|||||||
{
|
{
|
||||||
delete drawManager;
|
delete drawManager;
|
||||||
delete inputManager;
|
delete inputManager;
|
||||||
delete musicManager;
|
|
||||||
delete gameInfo;
|
delete gameInfo;
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ private:
|
|||||||
|
|
||||||
DrawManager *drawManager;
|
DrawManager *drawManager;
|
||||||
InputManager *inputManager;
|
InputManager *inputManager;
|
||||||
MusicManager *musicManager;
|
|
||||||
GameInfo *gameInfo;
|
GameInfo *gameInfo;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -816,3 +816,40 @@ void ArounderProcesor::put_pixel( int x, int y, Uint32 pixel )
|
|||||||
{
|
{
|
||||||
pixels[ ( y * mapa->w ) + x ] = pixel;
|
pixels[ ( y * mapa->w ) + x ] = pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
#define COLOR 0xFFFFFFFF;
|
||||||
|
|
||||||
|
void vline(const int x, const int y1, const int y2) {
|
||||||
|
if (x < 0 || x > 319) return;
|
||||||
|
const int yy1 = y1 < 0 ? 0 : y1 > 239 ? 239 : y1;
|
||||||
|
const int yy2 = y2 < 0 ? 0 : y2 > 239 ? 239 : y2;
|
||||||
|
for (int y=yy1;y<=yy2;y++) pixels[x+y*pitch] = COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void hline(const int x1, const int x2, const int y) {
|
||||||
|
if (y < 0 || y > 239) return;
|
||||||
|
const int yy = y*pitch;
|
||||||
|
const int xx1 = x1 < 0 ? 0 : x1 > 319 ? 319 : x1;
|
||||||
|
const int xx2 = x2 < 0 ? 0 : x2 > 319 ? 319 : x2;
|
||||||
|
for (int x=xx1;x<=xx2;x++) pixels[x+yy] = COLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void circle(const int x, const int y) {
|
||||||
|
hline(x+9, x+9+7, y+0); hline(x+9, x+9+7, y+24);
|
||||||
|
hline(x+7, x+7+11, y+1); hline(x+7, x+7+11, y+23);
|
||||||
|
hline(x+5, x+5+15, y+2); hline(x+5, x+5+15, y+22);
|
||||||
|
hline(x+4, x+4+17, y+3); hline(x+4, x+4+17, y+21);
|
||||||
|
hline(x+3, x+3+19, y+4); hline(x+3, x+3+19, y+20);
|
||||||
|
hline(x+2, x+2+21, y+5); hline(x+2, x+2+21, y+19);
|
||||||
|
hline(x+2, x+2+21, y+6); hline(x+2, x+2+21, y+18);
|
||||||
|
hline(x+1, x+1+23, y+7); hline(x+1, x+1+23, y+17);
|
||||||
|
hline(x+1, x+1+23, y+8); hline(x+1, x+1+23, y+16);
|
||||||
|
hline(x, x+25, y+9); hline(x, x+25, y+15);
|
||||||
|
hline(x, x+25, y+10); hline(x, x+25, y+14);
|
||||||
|
hline(x, x+25, y+11); hline(x, x+25, y+13);
|
||||||
|
hline(x, x+25, y+12);
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -4,38 +4,31 @@
|
|||||||
#include "SDL2/SDL_image.h"
|
#include "SDL2/SDL_image.h"
|
||||||
|
|
||||||
|
|
||||||
|
SDL_Window *sdlWindow = NULL;
|
||||||
|
SDL_Renderer *sdlRenderer = NULL;
|
||||||
|
|
||||||
DrawManager::DrawManager(int pMode)
|
DrawManager::DrawManager(int pMode) {
|
||||||
{
|
|
||||||
mode = pMode;
|
mode = pMode;
|
||||||
screen = NULL;
|
screen = NULL;
|
||||||
screenBig = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawManager::~DrawManager(void)
|
DrawManager::~DrawManager(void) {
|
||||||
{
|
|
||||||
SDL_FreeSurface(temp);
|
SDL_FreeSurface(temp);
|
||||||
SDL_FreeSurface(black);
|
SDL_FreeSurface(black);
|
||||||
SDL_FreeSurface(faded);
|
SDL_FreeSurface(faded);
|
||||||
|
|
||||||
|
SDL_DestroyRenderer(sdlRenderer);
|
||||||
|
SDL_DestroyWindow(sdlWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrawManager::Init(void)
|
bool DrawManager::Init(void) {
|
||||||
{
|
|
||||||
switch (mode) {
|
sdlWindow = SDL_CreateWindow(APPLICATION_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
|
||||||
case 1:
|
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
|
||||||
screenBig = SDL_SetVideoMode( SCREEN_WIDTH<<1, SCREEN_HEIGHT<<1, SCREEN_BPP, SDL_SWSURFACE );
|
SDL_RenderSetLogicalSize(sdlRenderer, 320, 240);
|
||||||
if( screenBig == NULL ) { return false; }
|
|
||||||
screen = LoadBitmap("black.gif");
|
SDL_ShowCursor(0);
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_FULLSCREEN );
|
|
||||||
if( screen == NULL ) { return false; }
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
|
|
||||||
if( screen == NULL ) { return false; }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
color_blanco = -1;
|
color_blanco = -1;
|
||||||
color_rojo = SDL_MapRGB( screen->format, 255, 0, 0 );
|
color_rojo = SDL_MapRGB( screen->format, 255, 0, 0 );
|
||||||
color_verde = SDL_MapRGB( screen->format, 0, 255, 0 );
|
color_verde = SDL_MapRGB( screen->format, 0, 255, 0 );
|
||||||
@@ -50,34 +43,15 @@ bool DrawManager::Init(void)
|
|||||||
|
|
||||||
bool DrawManager::Flip(void)
|
bool DrawManager::Flip(void)
|
||||||
{
|
{
|
||||||
if (mode == 1) {
|
SDL_RenderPresent(sdlRenderer);
|
||||||
for (int x=0; x<320; x++) {
|
|
||||||
for (int y=0; y<200; y++) {
|
|
||||||
put_pixel32(screenBig, x<<1 , y<<1 , get_pixel32(screen, x, y));
|
|
||||||
put_pixel32(screenBig, (x<<1)+1, y<<1 , get_pixel32(screen, x, y));
|
|
||||||
put_pixel32(screenBig, x<<1 , (y<<1)+1, get_pixel32(screen, x, y));
|
|
||||||
put_pixel32(screenBig, (x<<1)+1, (y<<1)+1, get_pixel32(screen, x, y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (SDL_Flip( screenBig ) == -1 ) {
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (SDL_Flip( screen ) == -1 ) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *DrawManager::LoadBitmap(char *bitmapfilename, bool doColorKey)
|
SDL_Surface *DrawManager::LoadBitmap(const char *bitmapfilename, const bool doColorKey)
|
||||||
{
|
{
|
||||||
//Get the bitmap's buffer and size from the resource file
|
//Get the bitmap's buffer and size from the resource file
|
||||||
int filesize = 0;
|
int filesize = 0;
|
||||||
char *buffer = GetBufferFromResource(bitmapfilename, &filesize);
|
const char *buffer = file_getBufferFromResource(bitmapfilename, filesize);
|
||||||
|
|
||||||
//Load the buffer into a surface using RWops
|
//Load the buffer into a surface using RWops
|
||||||
SDL_RWops *rw = SDL_RWFromMem(buffer, filesize);
|
SDL_RWops *rw = SDL_RWFromMem(buffer, filesize);
|
||||||
@@ -111,11 +85,11 @@ SDL_Surface *DrawManager::LoadBitmap(char *bitmapfilename, bool doColorKey)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SDL_Surface *DrawManager::LoadMask(char *bitmapfilename)
|
SDL_Surface *DrawManager::LoadMask(const char *bitmapfilename)
|
||||||
{
|
{
|
||||||
//Get the bitmap's buffer and size from the resource file
|
//Get the bitmap's buffer and size from the resource file
|
||||||
int filesize = 0;
|
int filesize = 0;
|
||||||
char *buffer = GetBufferFromResource(bitmapfilename, &filesize);
|
const char *buffer = file_getBufferFromResource(bitmapfilename, filesize);
|
||||||
|
|
||||||
//Load the buffer into a surface using RWops
|
//Load the buffer into a surface using RWops
|
||||||
SDL_RWops *rw = SDL_RWFromMem(buffer, filesize);
|
SDL_RWops *rw = SDL_RWFromMem(buffer, filesize);
|
||||||
@@ -162,7 +136,7 @@ void DrawManager::Blit( int x, int y, SDL_Surface* source, SDL_Rect* clip )
|
|||||||
apply_surface(x, y, source, screen, clip);
|
apply_surface(x, y, source, screen, clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawManager::Print( int x, int y, SDL_Surface* source, int w, int h, char *text, SDL_Surface *dest ) {
|
void DrawManager::Print( int x, int y, SDL_Surface* source, int w, int h, const char *text, SDL_Surface *dest ) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
SDL_Rect clip;
|
SDL_Rect clip;
|
||||||
|
|
||||||
@@ -273,7 +247,7 @@ void DrawManager::DrawFadedBack() {
|
|||||||
Blit(0,0, faded);
|
Blit(0,0, faded);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *DrawManager::LoadFont(char *bitmapfilename, Uint32 color)
|
SDL_Surface *DrawManager::LoadFont(const char *bitmapfilename, const Uint32 color)
|
||||||
{
|
{
|
||||||
if (color == 0xFFFFFFFF) {
|
if (color == 0xFFFFFFFF) {
|
||||||
return LoadBitmap(bitmapfilename, true);
|
return LoadBitmap(bitmapfilename, true);
|
||||||
|
|||||||
@@ -10,17 +10,17 @@ public:
|
|||||||
bool Init(void);
|
bool Init(void);
|
||||||
bool Flip(void);
|
bool Flip(void);
|
||||||
|
|
||||||
SDL_Surface *LoadBitmap(char *bitmapfilename, bool doColorKey = false);
|
SDL_Surface *LoadBitmap(const char *bitmapfilename, const bool doColorKey = false);
|
||||||
SDL_Surface *LoadMask(char *bitmapfilename);
|
SDL_Surface *LoadMask(const char *bitmapfilename);
|
||||||
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL );
|
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL );
|
||||||
void Blit( int x, int y, SDL_Surface* source, SDL_Rect* clip = NULL );
|
void Blit( int x, int y, SDL_Surface* source, SDL_Rect* clip = NULL );
|
||||||
void Print( int x, int y, SDL_Surface* source, int w, int h, char *text, SDL_Surface* dest = NULL );
|
void Print( int x, int y, SDL_Surface* source, int w, int h, const char *text, SDL_Surface* dest = NULL );
|
||||||
void FadeOut();
|
void FadeOut();
|
||||||
void FadeIn();
|
void FadeIn();
|
||||||
void FadeOutGray();
|
void FadeOutGray();
|
||||||
void FadeInGray();
|
void FadeInGray();
|
||||||
void DrawFadedBack();
|
void DrawFadedBack();
|
||||||
SDL_Surface *LoadFont(char *bitmapfilename, Uint32 color = 0xFFFFFFFF);
|
SDL_Surface *LoadFont(const char *bitmapfilename, const Uint32 color = 0xFFFFFFFF);
|
||||||
|
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
@@ -30,7 +30,6 @@ public:
|
|||||||
Uint32 color_azul;
|
Uint32 color_azul;
|
||||||
private:
|
private:
|
||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
SDL_Surface *screenBig;
|
|
||||||
SDL_Surface *black;
|
SDL_Surface *black;
|
||||||
SDL_Surface *temp;
|
SDL_Surface *temp;
|
||||||
SDL_Surface *faded;
|
SDL_Surface *faded;
|
||||||
|
|||||||
@@ -2,13 +2,12 @@
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "fileManager.h"
|
#include "fileManager.h"
|
||||||
|
|
||||||
GameController::GameController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager) {
|
GameController::GameController(DrawManager *p_drawManager, InputManager *p_inputManager) {
|
||||||
drawManager = p_drawManager;
|
drawManager = p_drawManager;
|
||||||
inputManager = p_inputManager;
|
inputManager = p_inputManager;
|
||||||
musicManager = p_musicManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameController::~GameController(void) {
|
GameController::~GameController() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameController::Init()
|
bool GameController::Init()
|
||||||
@@ -33,9 +32,9 @@ bool GameController::Init()
|
|||||||
arounderSeleccionat = primerArounder;
|
arounderSeleccionat = primerArounder;
|
||||||
|
|
||||||
if ( ((gameInfo->fase+1) % 5) == 0) {
|
if ( ((gameInfo->fase+1) % 5) == 0) {
|
||||||
musicManager->Load( "mus6.mp3");
|
music_load( "mus6.mp3");
|
||||||
} else {
|
} else {
|
||||||
musicManager->Load( "mus4.mp3");
|
music_load( "mus4.mp3");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -53,7 +52,7 @@ void GameController::Go(GameInfo *pGameInfo)
|
|||||||
|
|
||||||
if ( !Init() ) { salir = true; gameInfo->estado = ESTADO_SALIR; }
|
if ( !Init() ) { salir = true; gameInfo->estado = ESTADO_SALIR; }
|
||||||
|
|
||||||
musicManager->Play(-1);
|
music_play(-1);
|
||||||
drawManager->Blit(0,0, fondo);
|
drawManager->Blit(0,0, fondo);
|
||||||
drawManager->Blit(0,0, mapa);
|
drawManager->Blit(0,0, mapa);
|
||||||
drawManager->FadeIn();
|
drawManager->FadeIn();
|
||||||
@@ -183,7 +182,7 @@ void GameController::Go(GameInfo *pGameInfo)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
musicManager->FadeOut();
|
music_fadeOut();
|
||||||
drawManager->FadeOut();
|
drawManager->FadeOut();
|
||||||
|
|
||||||
Finalize();
|
Finalize();
|
||||||
@@ -253,7 +252,7 @@ bool GameController::Pausa() {
|
|||||||
return salirJuego;
|
return salirJuego;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameController::Menu(bool bypass) {
|
bool GameController::Menu(const bool bypass) {
|
||||||
|
|
||||||
if (!bypass) {
|
if (!bypass) {
|
||||||
PintarEscena();
|
PintarEscena();
|
||||||
@@ -312,10 +311,10 @@ bool GameController::Menu(bool bypass) {
|
|||||||
return salirJuego;
|
return salirJuego;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::CarregarMapa(int numMapa)
|
void GameController::CarregarMapa(const int numMapa)
|
||||||
{
|
{
|
||||||
int filesize = 0;
|
int filesize = 0;
|
||||||
char *buffer = GetBufferFromResource("MAPES.BAL", &filesize);
|
const char *buffer = file_getBufferFromResource("MAPES.BAL", filesize);
|
||||||
|
|
||||||
int punter = numMapa * 212;
|
int punter = numMapa * 212;
|
||||||
|
|
||||||
@@ -404,7 +403,7 @@ void GameController::Finalize(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *GameController::formatejar(int numero) {
|
const char *GameController::formatejar(const int numero) {
|
||||||
char *resultat;
|
char *resultat;
|
||||||
resultat = (char *) malloc(3);
|
resultat = (char *) malloc(3);
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
class GameController
|
class GameController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager);
|
GameController(DrawManager *p_drawManager, InputManager *p_inputManager);
|
||||||
~GameController(void);
|
~GameController();
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
void Go(GameInfo *pGameInfo);
|
void Go(GameInfo *pGameInfo);
|
||||||
@@ -22,7 +22,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
DrawManager *drawManager;
|
DrawManager *drawManager;
|
||||||
InputManager *inputManager;
|
InputManager *inputManager;
|
||||||
MusicManager *musicManager;
|
|
||||||
AiguaProcesor *aiguaProcesor;
|
AiguaProcesor *aiguaProcesor;
|
||||||
MarcadorProcesor *marcadorProcesor;
|
MarcadorProcesor *marcadorProcesor;
|
||||||
|
|
||||||
@@ -51,8 +50,8 @@ private:
|
|||||||
void PintarEscena();
|
void PintarEscena();
|
||||||
void PintarCursor();
|
void PintarCursor();
|
||||||
bool Pausa();
|
bool Pausa();
|
||||||
bool Menu(bool bypass = false);
|
bool Menu(const bool bypass = false);
|
||||||
void CarregarMapa(int numMapa);
|
void CarregarMapa(const int numMapa);
|
||||||
char *formatejar(int numero);
|
const char *formatejar(const int numero);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#include "MenuController.h"
|
#include "MenuController.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
MenuController::MenuController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager) {
|
MenuController::MenuController(DrawManager *p_drawManager, InputManager *p_inputManager) {
|
||||||
drawManager = p_drawManager;
|
drawManager = p_drawManager;
|
||||||
inputManager = p_inputManager;
|
inputManager = p_inputManager;
|
||||||
musicManager = p_musicManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuController::~MenuController(void) {
|
MenuController::~MenuController(void) {
|
||||||
@@ -13,9 +12,9 @@ MenuController::~MenuController(void) {
|
|||||||
bool MenuController::Init() {
|
bool MenuController::Init() {
|
||||||
fondo = drawManager->LoadBitmap("menuprin.gif");
|
fondo = drawManager->LoadBitmap("menuprin.gif");
|
||||||
cursor = drawManager->LoadFont("cursor.gif");
|
cursor = drawManager->LoadFont("cursor.gif");
|
||||||
if (!musicManager->Sonant()) {
|
if (!music_sonant()) {
|
||||||
musicManager->Load( "mus3.mp3");
|
music_load("mus3.mp3");
|
||||||
musicManager->Play(-1);
|
music_play(-1);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -66,7 +65,7 @@ void MenuController::Go(GameInfo *gameInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gameInfo->estado == ESTADO_SALIR) musicManager->FadeOut();
|
if (gameInfo->estado == ESTADO_SALIR) music_fadeOut();
|
||||||
drawManager->FadeOut();
|
drawManager->FadeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
class MenuController
|
class MenuController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MenuController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager);
|
MenuController(DrawManager *p_drawManager, InputManager *p_inputManager);
|
||||||
~MenuController(void);
|
~MenuController(void);
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
@@ -18,7 +18,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
DrawManager *drawManager;
|
DrawManager *drawManager;
|
||||||
InputManager *inputManager;
|
InputManager *inputManager;
|
||||||
MusicManager *musicManager;
|
|
||||||
|
|
||||||
SDL_Surface *fondo;
|
SDL_Surface *fondo;
|
||||||
SDL_Surface *cursor;
|
SDL_Surface *cursor;
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#include "MortController.h"
|
#include "MortController.h"
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
MortController::MortController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager) {
|
MortController::MortController(DrawManager *p_drawManager, InputManager *p_inputManager) {
|
||||||
drawManager = p_drawManager;
|
drawManager = p_drawManager;
|
||||||
inputManager = p_inputManager;
|
inputManager = p_inputManager;
|
||||||
musicManager = p_musicManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MortController::~MortController(void) {
|
MortController::~MortController(void) {
|
||||||
@@ -13,7 +12,7 @@ MortController::~MortController(void) {
|
|||||||
bool MortController::Init() {
|
bool MortController::Init() {
|
||||||
fondo = drawManager->LoadBitmap("mort.gif");
|
fondo = drawManager->LoadBitmap("mort.gif");
|
||||||
cursor = drawManager->LoadFont("cursor.gif");
|
cursor = drawManager->LoadFont("cursor.gif");
|
||||||
musicManager->Load( "mus5.mp3");
|
music_load( "mus5.mp3");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -23,7 +22,7 @@ void MortController::Go(GameInfo *gameInfo) {
|
|||||||
|
|
||||||
if ( !Init() ) { salir = true; gameInfo->estado = ESTADO_SALIR; }
|
if ( !Init() ) { salir = true; gameInfo->estado = ESTADO_SALIR; }
|
||||||
|
|
||||||
musicManager->Play(-1);
|
music_play(-1);
|
||||||
drawManager->Blit(0,0, fondo);
|
drawManager->Blit(0,0, fondo);
|
||||||
drawManager->FadeIn();
|
drawManager->FadeIn();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
class MortController
|
class MortController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MortController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager);
|
MortController(DrawManager *p_drawManager, InputManager *p_inputManager);
|
||||||
~MortController(void);
|
~MortController(void);
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
@@ -18,7 +18,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
DrawManager *drawManager;
|
DrawManager *drawManager;
|
||||||
InputManager *inputManager;
|
InputManager *inputManager;
|
||||||
MusicManager *musicManager;
|
|
||||||
|
|
||||||
SDL_Surface *fondo;
|
SDL_Surface *fondo;
|
||||||
SDL_Surface *cursor;
|
SDL_Surface *cursor;
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "fileManager.h"
|
#include "fileManager.h"
|
||||||
|
|
||||||
PasswordController::PasswordController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager) {
|
PasswordController::PasswordController(DrawManager *p_drawManager, InputManager *p_inputManager) {
|
||||||
drawManager = p_drawManager;
|
drawManager = p_drawManager;
|
||||||
inputManager = p_inputManager;
|
inputManager = p_inputManager;
|
||||||
musicManager = p_musicManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PasswordController::~PasswordController(void) {
|
PasswordController::~PasswordController(void) {
|
||||||
@@ -82,7 +81,7 @@ char PasswordController::ObtenerTecla() {
|
|||||||
|
|
||||||
int PasswordController::ObtenerFaseDePassword(char *password) {
|
int PasswordController::ObtenerFaseDePassword(char *password) {
|
||||||
int filesize = 0;
|
int filesize = 0;
|
||||||
char *buffer = GetBufferFromResource("offsets.bal", &filesize);
|
const char *buffer = file_getBufferFromResource("offsets.bal", filesize);
|
||||||
|
|
||||||
int punter = 0;
|
int punter = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
class PasswordController
|
class PasswordController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PasswordController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager);
|
PasswordController(DrawManager *p_drawManager, InputManager *p_inputManager);
|
||||||
~PasswordController(void);
|
~PasswordController(void);
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
@@ -21,7 +21,6 @@ private:
|
|||||||
|
|
||||||
DrawManager *drawManager;
|
DrawManager *drawManager;
|
||||||
InputManager *inputManager;
|
InputManager *inputManager;
|
||||||
MusicManager *musicManager;
|
|
||||||
|
|
||||||
SDL_Surface *fondo;
|
SDL_Surface *fondo;
|
||||||
SDL_Surface *cursor;
|
SDL_Surface *cursor;
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "fileManager.h"
|
#include "fileManager.h"
|
||||||
|
|
||||||
PostfaseController::PostfaseController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager) {
|
PostfaseController::PostfaseController(DrawManager *p_drawManager, InputManager *p_inputManager) {
|
||||||
drawManager = p_drawManager;
|
drawManager = p_drawManager;
|
||||||
inputManager = p_inputManager;
|
inputManager = p_inputManager;
|
||||||
musicManager = p_musicManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PostfaseController::~PostfaseController(void) {
|
PostfaseController::~PostfaseController(void) {
|
||||||
@@ -25,8 +24,8 @@ void PostfaseController::Go(GameInfo *gameInfo) {
|
|||||||
gameInfo->estado = ESTADO_SEQUENCIA;
|
gameInfo->estado = ESTADO_SEQUENCIA;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
musicManager->Load( "mus3.mp3");
|
music_load( "mus3.mp3");
|
||||||
musicManager->Play(-1);
|
music_play(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameInfo->fase % 5 == 0 && gameInfo->fase != 30) {
|
if (gameInfo->fase % 5 == 0 && gameInfo->fase != 30) {
|
||||||
@@ -67,7 +66,7 @@ void PostfaseController::Go(GameInfo *gameInfo) {
|
|||||||
|
|
||||||
char *PostfaseController::ObtenerPasswordDeFase(int fase) {
|
char *PostfaseController::ObtenerPasswordDeFase(int fase) {
|
||||||
int filesize = 0;
|
int filesize = 0;
|
||||||
char *buffer = GetBufferFromResource("offsets.bal", &filesize);
|
const char *buffer = file_getBufferFromResource("offsets.bal", filesize);
|
||||||
|
|
||||||
int punter = (fase-1)*11;
|
int punter = (fase-1)*11;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
class PostfaseController
|
class PostfaseController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PostfaseController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager);
|
PostfaseController(DrawManager *p_drawManager, InputManager *p_inputManager);
|
||||||
~PostfaseController(void);
|
~PostfaseController(void);
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
@@ -21,7 +21,6 @@ private:
|
|||||||
|
|
||||||
DrawManager *drawManager;
|
DrawManager *drawManager;
|
||||||
InputManager *inputManager;
|
InputManager *inputManager;
|
||||||
MusicManager *musicManager;
|
|
||||||
|
|
||||||
SDL_Surface *fondo;
|
SDL_Surface *fondo;
|
||||||
SDL_Surface *font;
|
SDL_Surface *font;
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "fileManager.h"
|
#include "fileManager.h"
|
||||||
|
|
||||||
PrefaseController::PrefaseController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager) {
|
PrefaseController::PrefaseController(DrawManager *p_drawManager, InputManager *p_inputManager) {
|
||||||
drawManager = p_drawManager;
|
drawManager = p_drawManager;
|
||||||
inputManager = p_inputManager;
|
inputManager = p_inputManager;
|
||||||
musicManager = p_musicManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrefaseController::~PrefaseController(void) {
|
PrefaseController::~PrefaseController(void) {
|
||||||
@@ -64,7 +63,7 @@ void PrefaseController::Go(GameInfo *gameInfo) {
|
|||||||
salir = true;
|
salir = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
musicManager->FadeOut();
|
music_fadeOut();
|
||||||
drawManager->FadeOut();
|
drawManager->FadeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +73,10 @@ void PrefaseController::Finalize(void) {
|
|||||||
SDL_FreeSurface(font);
|
SDL_FreeSurface(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrefaseController::CarregarMapa(int numMapa)
|
void PrefaseController::CarregarMapa(const int numMapa)
|
||||||
{
|
{
|
||||||
int filesize = 0;
|
int filesize = 0;
|
||||||
char *buffer = GetBufferFromResource("MAPES.BAL", &filesize);
|
const char *buffer = file_getBufferFromResource("MAPES.BAL", filesize);
|
||||||
|
|
||||||
int punter = numMapa * 212;
|
int punter = numMapa * 212;
|
||||||
|
|
||||||
@@ -87,7 +86,7 @@ void PrefaseController::CarregarMapa(int numMapa)
|
|||||||
aroundersNec = buffer[punter++];
|
aroundersNec = buffer[punter++];
|
||||||
}
|
}
|
||||||
|
|
||||||
char *PrefaseController::formatejar(int numero) {
|
const char *PrefaseController::formatejar(const int numero) {
|
||||||
char *resultat;
|
char *resultat;
|
||||||
resultat = (char *) malloc(3);
|
resultat = (char *) malloc(3);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
class PrefaseController
|
class PrefaseController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrefaseController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager);
|
PrefaseController(DrawManager *p_drawManager, InputManager *p_inputManager);
|
||||||
~PrefaseController(void);
|
~PrefaseController(void);
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
@@ -16,12 +16,11 @@ public:
|
|||||||
void Finalize(void);
|
void Finalize(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *formatejar(int numero);
|
const char *formatejar(const int numero);
|
||||||
void CarregarMapa(int numMapa);
|
void CarregarMapa(const int numMapa);
|
||||||
|
|
||||||
DrawManager *drawManager;
|
DrawManager *drawManager;
|
||||||
InputManager *inputManager;
|
InputManager *inputManager;
|
||||||
MusicManager *musicManager;
|
|
||||||
|
|
||||||
SDL_Surface *fondo;
|
SDL_Surface *fondo;
|
||||||
SDL_Surface *cursor;
|
SDL_Surface *cursor;
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include "fileManager.h"
|
#include "fileManager.h"
|
||||||
|
|
||||||
SequenceController::SequenceController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager) {
|
SequenceController::SequenceController(DrawManager *p_drawManager, InputManager *p_inputManager) {
|
||||||
drawManager = p_drawManager;
|
drawManager = p_drawManager;
|
||||||
inputManager = p_inputManager;
|
inputManager = p_inputManager;
|
||||||
musicManager = p_musicManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SequenceController::~SequenceController(void) {
|
SequenceController::~SequenceController(void) {
|
||||||
@@ -18,7 +17,7 @@ bool SequenceController::Init() {
|
|||||||
void SequenceController::Go(GameInfo *pGameInfo) {
|
void SequenceController::Go(GameInfo *pGameInfo) {
|
||||||
bool salir = false;
|
bool salir = false;
|
||||||
int pantalla = 0;
|
int pantalla = 0;
|
||||||
char *file;
|
const char *file;
|
||||||
int filesize;
|
int filesize;
|
||||||
|
|
||||||
gameInfo = pGameInfo;
|
gameInfo = pGameInfo;
|
||||||
@@ -26,28 +25,28 @@ void SequenceController::Go(GameInfo *pGameInfo) {
|
|||||||
if (gameInfo->fase % 5 == 0 || gameInfo->fase < 0) {
|
if (gameInfo->fase % 5 == 0 || gameInfo->fase < 0) {
|
||||||
switch (gameInfo->fase) {
|
switch (gameInfo->fase) {
|
||||||
case -1:
|
case -1:
|
||||||
file = GetBufferFromResource("seqIN.seq", &filesize);
|
file = file_getBufferFromResource("seqIN.seq", filesize);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
file = GetBufferFromResource("seq00.seq", &filesize);
|
file = file_getBufferFromResource("seq00.seq", filesize);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
file = GetBufferFromResource("seq05.seq", &filesize);
|
file = file_getBufferFromResource("seq05.seq", filesize);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
file = GetBufferFromResource("seq10.seq", &filesize);
|
file = file_getBufferFromResource("seq10.seq", filesize);
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
file = GetBufferFromResource("seq15.seq", &filesize);
|
file = file_getBufferFromResource("seq15.seq", filesize);
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
file = GetBufferFromResource("seq20.seq", &filesize);
|
file = file_getBufferFromResource("seq20.seq", filesize);
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
file = GetBufferFromResource("seq25.seq", &filesize);
|
file = file_getBufferFromResource("seq25.seq", filesize);
|
||||||
break;
|
break;
|
||||||
case 30:
|
case 30:
|
||||||
file = GetBufferFromResource("seq30.seq", &filesize);
|
file = file_getBufferFromResource("seq30.seq", filesize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ProcesarSecuencia(file);
|
ProcesarSecuencia(file);
|
||||||
@@ -61,7 +60,7 @@ void SequenceController::Go(GameInfo *pGameInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequenceController::ProcesarSecuencia(char *file) {
|
void SequenceController::ProcesarSecuencia(const char *file) {
|
||||||
char numDiapositives = (char)file[0];
|
char numDiapositives = (char)file[0];
|
||||||
int punter = 1;
|
int punter = 1;
|
||||||
char *filename;
|
char *filename;
|
||||||
@@ -201,12 +200,12 @@ void SequenceController::FadeOut() {
|
|||||||
|
|
||||||
void SequenceController::FadeOutWithMusic() {
|
void SequenceController::FadeOutWithMusic() {
|
||||||
drawManager->FadeOut();
|
drawManager->FadeOut();
|
||||||
musicManager->FadeOut();
|
music_fadeOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequenceController::Musica(char *archivo, int loop) {
|
void SequenceController::Musica(char *archivo, int loop) {
|
||||||
musicManager->Load(archivo);
|
music_load(archivo);
|
||||||
musicManager->Play(loop);
|
music_play(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequenceController::Finalize(void) {
|
void SequenceController::Finalize(void) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
class SequenceController
|
class SequenceController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SequenceController(DrawManager *p_drawManager, InputManager *p_inputManager, MusicManager *p_musicManager);
|
SequenceController(DrawManager *p_drawManager, InputManager *p_inputManager);
|
||||||
~SequenceController(void);
|
~SequenceController(void);
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
void Finalize(void);
|
void Finalize(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ProcesarSecuencia(char *file);
|
void ProcesarSecuencia(const char *file);
|
||||||
|
|
||||||
bool Esperar(Uint32 temps);
|
bool Esperar(Uint32 temps);
|
||||||
void FadeIn(char *archivo);
|
void FadeIn(char *archivo);
|
||||||
@@ -28,7 +28,6 @@ private:
|
|||||||
|
|
||||||
DrawManager *drawManager;
|
DrawManager *drawManager;
|
||||||
InputManager *inputManager;
|
InputManager *inputManager;
|
||||||
MusicManager *musicManager;
|
|
||||||
GameInfo *gameInfo;
|
GameInfo *gameInfo;
|
||||||
|
|
||||||
SDL_Surface *fondo;
|
SDL_Surface *fondo;
|
||||||
|
|||||||
6
main.cpp
6
main.cpp
@@ -5,14 +5,14 @@
|
|||||||
int main( int argc, char* args[] )
|
int main( int argc, char* args[] )
|
||||||
{
|
{
|
||||||
int modeGrafic = MODE_ZOOMX2;
|
int modeGrafic = MODE_ZOOMX2;
|
||||||
char *porDefecto = "data.jrf";
|
const char *porDefecto = "data.jrf";
|
||||||
setResourceFile(porDefecto);
|
file_setResourceFile(porDefecto);
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
for (int i=1;i<argc;i++) {
|
for (int i=1;i<argc;i++) {
|
||||||
if (!strcmp(args[i], "normal")) modeGrafic = MODE_NORMAL;
|
if (!strcmp(args[i], "normal")) modeGrafic = MODE_NORMAL;
|
||||||
if (!strcmp(args[i], "fullscreen")) modeGrafic = MODE_FULLSCREEN;
|
if (!strcmp(args[i], "fullscreen")) modeGrafic = MODE_FULLSCREEN;
|
||||||
if (args[i][4] == '.') setResourceFile(args[i]);
|
if (args[i][4] == '.') file_setResourceFile(args[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppController *appController;
|
AppController *appController;
|
||||||
|
|||||||
Reference in New Issue
Block a user