From 60af56270fa016b39de2ba8214ecbb62ee16573f Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Thu, 12 Dec 2019 19:00:56 +0100 Subject: [PATCH] Canvis varios --- info.h | 4 ++- jdraw8.cpp | 4 +++ jdraw8.h | 1 + main.cpp | 18 ++++++++++-- modulemenu.cpp | 68 +++++++++++++++++++++++++++----------------- pepe.vcxproj | 2 ++ pepe.vcxproj.filters | 6 ++++ 7 files changed, 73 insertions(+), 30 deletions(-) diff --git a/info.h b/info.h index c2bf271..1ab7625 100644 --- a/info.h +++ b/info.h @@ -11,5 +11,7 @@ #define ESTAT_MORT 7 struct Info { - int estat_joc; + int estat_joc; + bool rosita_enabled; + bool job_enabled; }; diff --git a/jdraw8.cpp b/jdraw8.cpp index 3a6212c..a74988e 100644 --- a/jdraw8.cpp +++ b/jdraw8.cpp @@ -196,6 +196,10 @@ void JD8_PutPixel( JD8_Surface surface, int x, int y, Uint8 pixel ) { surface[x + (y*320)] = pixel; } +void JD8_PutPixel(int x, int y, Uint8 pixel) { + screen[x + (y * 320)] = pixel; +} + void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b) { main_palette[index].r = r << 2; main_palette[index].g = g << 2; diff --git a/jdraw8.h b/jdraw8.h index 8766c3c..9014449 100644 --- a/jdraw8.h +++ b/jdraw8.h @@ -47,6 +47,7 @@ void JD8_FreeSurface(JD8_Surface surface); Uint8 JD8_GetPixel( JD8_Surface surface, int x, int y ); void JD8_PutPixel( JD8_Surface surface, int x, int y, Uint8 pixel ); +void JD8_PutPixel(int x, int y, Uint8 pixel); void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b); diff --git a/main.cpp b/main.cpp index 11d24cd..4056cdf 100644 --- a/main.cpp +++ b/main.cpp @@ -5,6 +5,7 @@ #include "info.h" #include "modulestaticscreen.h" #include "modulemenu.h" +#include "moduleselect.h" #include "time.h" #include @@ -36,12 +37,17 @@ int main( int argc, char* args[] ) { Info info; info.estat_joc = ESTAT_ICEKAS; + info.rosita_enabled = false; + info.job_enabled = false; -/* FILE* ini = fopen("trick.ini", "rb"); + FILE* ini = fopen("trick.ini", "rb"); if (ini != NULL) { - info.nou_personatge = true; + unsigned char contingut = 0; + fread(&contingut, 1, 1, ini); fclose(ini); - }*/ + if (contingut > 0) info.rosita_enabled = true; + if (contingut > 1) info.job_enabled = true; + } while (info.estat_joc != ESTAT_EIXIR) { switch (info.estat_joc) { @@ -58,6 +64,12 @@ int main( int argc, char* args[] ) { info.estat_joc = moduleMenu->Go(); delete moduleMenu; break; + case ESTAT_SELECT: + ModuleSelect * moduleSelect; + moduleSelect = new ModuleSelect(&info); + info.estat_joc = moduleSelect->Go(); + delete moduleSelect; + break; } } diff --git a/modulemenu.cpp b/modulemenu.cpp index 1bd1494..850afe1 100644 --- a/modulemenu.cpp +++ b/modulemenu.cpp @@ -7,6 +7,12 @@ #include #include +#define SENSE_OPCIO -1 +#define OPCIO_TIMEATTACK 0 +#define OPCIO_WORLDTOUR 1 +#define OPCIO_CLASSICMODE 2 +#define OPCIO_OPTIONS 3 + ModuleMenu::ModuleMenu(Info* info) { this->info = info; } @@ -42,51 +48,50 @@ int ModuleMenu::Go() { JD8_Flip(); x--; } + JD8_BlitCKToSurface(0, 50, opcions, 0, 50, 320, 38, fondo, 0); + x = 320; while (!JG_Quitting() && x > 25) { while (!JG_ShouldUpdate()) { JI_Update(); } JD8_Blit(fondo); - JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0); JD8_BlitCKCut(x, 88, opcions, 25, 88, 135, 37, 0); JD8_Flip(); x--; } + JD8_BlitCKToSurface(25, 88, opcions, 25, 88, 135, 37, fondo, 0); + x = 320; while (!JG_Quitting() && x > 0) { while (!JG_ShouldUpdate()) { JI_Update(); } JD8_Blit(fondo); - JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0); - JD8_BlitCK(25, 88, opcions, 25, 88, 135, 37, 0); JD8_BlitCKCut(x, 125, opcions, 0, 125, 320, 38, 0); JD8_Flip(); x--; } + JD8_BlitCKToSurface(0, 125, opcions, 0, 125, 320, 38, fondo, 0); + x = 320; while (!JG_Quitting() && x > 0) { while (!JG_ShouldUpdate()) { JI_Update(); } JD8_Blit(fondo); - JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0); - JD8_BlitCK(25, 88, opcions, 25, 88, 135, 37, 0); - JD8_BlitCK(0, 125, opcions, 0, 125, 320, 38, 0); JD8_BlitCKCut(x, 163, opcions, 0, 163, 320, 37, 0); JD8_Flip(); x--; } + JD8_BlitCKToSurface(0, 163, opcions, 0, 163, 320, 37, fondo, 0); + int y = 50; while (!JG_Quitting() && y > 0) { while (!JG_ShouldUpdate()) { JI_Update(); } JD8_Blit(fondo); - JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0); - JD8_BlitCK(25, 88, opcions, 25, 88, 135, 37, 0); - JD8_BlitCK(0, 125, opcions, 0, 125, 320, 38, 0); - JD8_BlitCK(0, 163, opcions, 0, 163, 320, 37, 0); JD8_BlitCKCut(0, -y, opcions, 0, 0, 320, 50, 0); JD8_Flip(); y--; } + JD8_BlitCKToSurface(0, 0, opcions, 0, 0, 320, 50, fondo, 0); - int opcio_seleccionada = 0; - int opcio_triada = -1; + int opcio_seleccionada = OPCIO_TIMEATTACK; + int opcio_triada = SENSE_OPCIO; bool fletxa_amunt_pulsada = false; bool fletxa_avall_pulsada = false; float x_fletxa = 0; @@ -94,7 +99,7 @@ int ModuleMenu::Go() { JG_SetUpdateTicks(20); - while (!JG_Quitting() && opcio_triada == -1) { + while (!JG_Quitting() && opcio_triada == SENSE_OPCIO) { while (!JG_ShouldUpdate()) { JI_Update(); if (JI_KeyPressed(SDL_SCANCODE_UP)) { @@ -113,6 +118,9 @@ int ModuleMenu::Go() { } else { fletxa_avall_pulsada = false; } + if (JI_KeyPressed(SDL_SCANCODE_SPACE)) { + opcio_triada = opcio_seleccionada; + } } x_fletxa += x_velocitat; @@ -123,21 +131,28 @@ int ModuleMenu::Go() { x_velocitat = 1; } JD8_Blit(fondo); - JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0); - JD8_BlitCK(25, 88, opcions, 25, 88, 135, 37, 0); - JD8_BlitCK(0, 125, opcions, 0, 125, 320, 38, 0); - JD8_BlitCK(0, 163, opcions, 0, 163, 320, 37, 0); - JD8_BlitCK(0, 0, opcions, 0, 0, 320, 50, 0); JD8_BlitCK(10+x_fletxa, 60+opcio_seleccionada*37, gfx, 18, 5, 9, 10, 255); JD8_Flip(); } + JD8_BlitCKToSurface(10 + x_fletxa, 60 + opcio_seleccionada * 37, gfx, 18, 5, 9, 10, fondo, 255); - // FADE OUT - JG_SetUpdateTicks(2); - while (!JD8_FadeOutAsync() && !JG_Quitting()) { + // BLINDS OUT + JG_SetUpdateTicks(8); + x = 0; + while (x < 32 && !JG_Quitting()) { while (!JG_ShouldUpdate()) { JI_Update(); } + + for (y = 0; y < 200; y++) { + for (int i = 0; i < 10; i++) { + JD8_PutPixel(fondo, i * 32 + x, y, 0); + } + } + x++; + JD8_Blit(fondo); + JD8_Flip(); } + // FREE EVERYTHING JD8_FreeSurface(fondo); JD8_FreeSurface(opcions); JD8_FreeSurface(gfx); @@ -148,11 +163,12 @@ int ModuleMenu::Go() { if (JG_Quitting()) { return ESTAT_EIXIR; - } - else { - switch (this->info->estat_joc) { - case ESTAT_ICEKAS: return ESTAT_LOGO; break; - case ESTAT_LOGO: return ESTAT_MENU; break; + } else { + switch (opcio_triada) { + case OPCIO_TIMEATTACK: return ESTAT_LOGO; break; + case OPCIO_WORLDTOUR: return ESTAT_SELECT; break; + case OPCIO_CLASSICMODE: return ESTAT_MENU; break; + case OPCIO_OPTIONS: return ESTAT_MENU; break; } } return ESTAT_EIXIR; diff --git a/pepe.vcxproj b/pepe.vcxproj index 6380eaa..4408a1f 100644 --- a/pepe.vcxproj +++ b/pepe.vcxproj @@ -88,6 +88,7 @@ + @@ -98,6 +99,7 @@ + diff --git a/pepe.vcxproj.filters b/pepe.vcxproj.filters index 253c70a..256a29c 100644 --- a/pepe.vcxproj.filters +++ b/pepe.vcxproj.filters @@ -42,6 +42,9 @@ Source Files + + Source Files + @@ -68,5 +71,8 @@ Header Files + + Header Files + \ No newline at end of file