From 2a553b64e6ef6bed19bc3191d1cbf8f4da9ce118 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Tue, 23 Feb 2016 13:56:22 +0100 Subject: [PATCH] finals fets. Credits fets. Personatge secret fet --- .hgignore | 3 ++- aee.vcxproj | 6 +++--- info.h | 2 ++ jdraw8.cpp | 19 ++++++++++++++++- jdraw8.h | 4 ++++ main.cpp | 8 +++++++ modulegame.cpp | 7 ++---- modulesequence.cpp | 53 ++++++++++++++++++++++++++++++++++------------ 8 files changed, 79 insertions(+), 23 deletions(-) diff --git a/.hgignore b/.hgignore index 3b4215e..1de44aa 100644 --- a/.hgignore +++ b/.hgignore @@ -12,4 +12,5 @@ data/* *.opensdf *.user *.dll -.DS_Store \ No newline at end of file +.DS_Store +trick.ini \ No newline at end of file diff --git a/aee.vcxproj b/aee.vcxproj index f3ffa8c..036863c 100644 --- a/aee.vcxproj +++ b/aee.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,13 +19,13 @@ Application true - v120 + v140 Unicode Application false - v120 + v140 true Unicode diff --git a/info.h b/info.h index 453438e..869259b 100755 --- a/info.h +++ b/info.h @@ -8,4 +8,6 @@ struct Info { int vida; int momies; int engendros; + bool nou_personatge; + bool pepe_activat; }; diff --git a/jdraw8.cpp b/jdraw8.cpp index 1a6e0a1..fc3b8fb 100755 --- a/jdraw8.cpp +++ b/jdraw8.cpp @@ -85,6 +85,12 @@ void JD8_SetScreenPalette(JD8_Palette palette) { main_palette = palette; } +void JD8_FillSquare(int ini, int height, Uint8 color) { + const int offset = ini * 320; + const int size = height * 320; + memset(&screen[offset], color, size); +} + void JD8_Blit(JD8_Surface surface) { memcpy( screen, surface, 64000 ); } @@ -126,13 +132,24 @@ void JD8_BlitCKCut(int x, int y, JD8_Surface surface, int sx, int sy, int sw, in int dst_pointer = x + (y * 320); for (int j = 0; j < sh; j++) { for (int i = 0; i < sw; i++) { - if (surface[src_pointer + i] != colorkey && (x+i >= 0) && (y+j >= 0) && (x+i < 320) && (y+i < 200)) screen[dst_pointer + i] = surface[src_pointer + i]; + if (surface[src_pointer + i] != colorkey && (x+i >= 0) && (y+j >= 0) && (x+i < 320) && (y+j < 200)) screen[dst_pointer + i] = surface[src_pointer + i]; } src_pointer += 320; dst_pointer += 320; } } +void JD8_BlitCKScroll(int y, JD8_Surface surface, int sx, int sy, int sh, Uint8 colorkey) { + int dst_pointer = y * 320; + for (int j = sy; j < sy+sh; j++) { + for (int i = 0; i < 320; i++) { + int x = (i+sx) % 320; + if (surface[x + j*320] != colorkey) screen[dst_pointer] = surface[x + j * 320]; + dst_pointer++; + } + } +} + void JD8_BlitCKToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, JD8_Surface dest, Uint8 colorkey) { int src_pointer = sx + (sy*320); int dst_pointer = x + (y*320); diff --git a/jdraw8.h b/jdraw8.h index d42438c..71ceedd 100755 --- a/jdraw8.h +++ b/jdraw8.h @@ -24,6 +24,8 @@ JD8_Palette JD8_LoadPalette(const char *file); void JD8_SetScreenPalette(JD8_Palette palette); +void JD8_FillSquare(int ini, int height, Uint8 color); + void JD8_Blit(JD8_Surface surface); void JD8_Blit(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh); @@ -34,6 +36,8 @@ void JD8_BlitCK(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int s void JD8_BlitCKCut(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, Uint8 colorkey); +void JD8_BlitCKScroll(int y, JD8_Surface surface, int sx, int sy, int sh, Uint8 colorkey); + void JD8_BlitCKToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int sw, int sh, JD8_Surface dest, Uint8 colorkey ); void JD8_Flip(); diff --git a/main.cpp b/main.cpp index 7f1e8f5..de3195c 100755 --- a/main.cpp +++ b/main.cpp @@ -41,6 +41,14 @@ int main( int argc, char* args[] ) { info.diamants = 0; info.vida = 5; info.momies = 0; + info.nou_personatge = false; + info.pepe_activat = false; + + FILE* ini = fopen("trick.ini", "rb"); + if (ini != NULL) { + info.nou_personatge = true; + fclose(ini); + } int gameState = 1; diff --git a/modulegame.cpp b/modulegame.cpp index bc5c832..37bc470 100755 --- a/modulegame.cpp +++ b/modulegame.cpp @@ -10,10 +10,7 @@ ModuleGame::ModuleGame( Info* info ) { this->info = info; - //this->info->num_piramide = 6; - //this->info->diners = 200; - - this->gfx = JD8_LoadSurface( "frames.gif" ); + this->gfx = JD8_LoadSurface( this->info->pepe_activat ? "frames2.gif" : "frames.gif" ); JG_SetUpdateTicks(10); this->sam = new Prota( this->gfx, this->info ); @@ -58,7 +55,7 @@ int ModuleGame::Go() { JS_PlayMusic(-1); } - JD8_FadeToPal( JD8_LoadPalette( "frames.gif" ) ); + JD8_FadeToPal( JD8_LoadPalette(this->info->pepe_activat ? "frames2.gif" : "frames.gif") ); while (this->final == 0 && !JG_Quitting()) { diff --git a/modulesequence.cpp b/modulesequence.cpp index 921c970..6959b50 100755 --- a/modulesequence.cpp +++ b/modulesequence.cpp @@ -27,7 +27,6 @@ int ModuleSequence::Go() { break; case 1: // Slides case 7: - //doSecreta(); doSlides(); break; case 2: // Pre-piràmide @@ -56,8 +55,9 @@ int ModuleSequence::Go() { this->info->num_piramide = 0; return 1; } else if( this->info->num_piramide == 0 ) { - this->info->num_piramide = 6; - this->info->diners = 200; + this->info->num_piramide = 1; + //this->info->num_piramide = 6; + //this->info->diners = 200; return 1; } else if( this->info->num_piramide == 7 ) { this->info->num_piramide = 8; @@ -596,7 +596,7 @@ void ModuleSequence::doMenu() { int camello = 0; JI_Update(); - while( !JI_AnyKey() && !JG_Quitting() ) { + while( !JI_AnyKey() && !JG_Quitting() && !JI_KeyPressed(SDL_SCANCODE_P)) { JD8_Blit( 0, 0, fondo, 0, 0, 320, 100 ); // fondo sol estatic @@ -613,6 +613,7 @@ void ModuleSequence::doMenu() { JD8_BlitCK( 303, 193, gfx, 305, 143, 15, 5, 255 ); // versio if( contador%100 > 30 ) JD8_BlitCK( 98, 130, gfx, 161, 92, 127, 9, 255 ); // pulsa tecla... + if ((contador % 100 > 30) && this->info->nou_personatge) JD8_BlitCK(68, 141, gfx, 128, 105, 189, 9, 255); // 'p' per a personatge nou... JD8_Flip(); @@ -624,7 +625,8 @@ void ModuleSequence::doMenu() { JI_Update(); } } - + this->info->pepe_activat = JI_KeyPressed(SDL_SCANCODE_P); + JI_DisableKeyboard(60); JD8_FreeSurface( fondo ); JD8_FreeSurface( gfx ); free( pal ); @@ -688,7 +690,7 @@ void ModuleSequence::doSlides() { case 4: case 7: contador--; - if( contador == 1 ) step++; + if (contador == -150) { contador = 0; step++; } break; case 2: case 5: @@ -845,7 +847,9 @@ void ModuleSequence::doSecreta() { void ModuleSequence::doCredits() { - JD8_ClearScreen(0); + struct { Uint16 x, y; } frames_coche[8] = { { 214, 152 }, { 214, 104 }, { 214, 56 }, { 214, 104 }, { 214, 152 }, { 214, 8 }, { 108, 152 }, { 214, 8 } }; + const Uint32 n_frames_coche = 8; + const Uint32 velocitat_coche = 3; JD8_Surface vaddr2 = JD8_LoadSurface("final.gif"); JD8_Surface vaddr3 = JD8_LoadSurface("finals.gif"); @@ -861,25 +865,48 @@ void ModuleSequence::doCredits() { if (JG_ShouldUpdate()) { JI_Update(); - if (JI_AnyKey()) { + if (JI_AnyKey() || contador >= 3100) { exit = true; } + JD8_ClearScreen(255); + if (contador < 2750) { - JD8_BlitCKCut(115, 200 - (contador / 10), vaddr2, 0, 0, 80, 200, 255); + JD8_BlitCKCut(115, 200 - (contador / 6), vaddr2, 0, 0, 80, 200, 0); } - if ((contador > 2000) && (contador < 3800)) { - JD8_BlitCKCut(100, 200 - ((contador-2000) / 10), vaddr2, 85, 0, 120, 140, 255); - } else if (contador >= 3750) { - JD8_BlitCK(100, 20, vaddr2, 85, 0, 120, 140, 255); + if ((contador > 1200) && (contador < 2280)) { + JD8_BlitCKCut(100, 200 - ((contador-1200) / 6), vaddr2, 85, 0, 120, 140, 0); + } else if (contador >= 2250) { + JD8_BlitCK(100, 20, vaddr2, 85, 0, 120, 140, 0); } + if (this->info->diamants == 16) { + //scroll_final_joc(vaddr3, vaddr, contador_final); + JD8_BlitCKScroll(50, vaddr3, ((contador >> 3) % 320) + 1, 0, 50, 255); + JD8_BlitCKScroll(50, vaddr3, ((contador >> 2) % 320) + 1, 50, 50, 255); + JD8_BlitCKScroll(50, vaddr3, ((contador >> 1) % 320) + 1, 100, 50, 255); + JD8_BlitCKScroll(50, vaddr3, (contador % 320) + 1, 150, 50, 255); + + JD8_BlitCK(100, 50, vaddr2, frames_coche[(contador / velocitat_coche) % n_frames_coche].x, frames_coche[(contador / velocitat_coche) % n_frames_coche].y, 106, 48, 255); + } else { + JD8_BlitCK(0, 50, vaddr3, 0, 0, 320, 50, 255); + JD8_BlitCK(0, 50, vaddr3, 0, 50, 320, 50, 255); + } + + JD8_FillSquare(0, 50, 255); + JD8_FillSquare(100, 10, 255); + JD8_Flip(); contador++; } } + FILE* ini = fopen("trick.ini", "wb"); + fwrite("1", 1, 1, ini); + fclose(ini); + this->info->nou_personatge = true; + JD8_FreeSurface(vaddr3); JD8_FreeSurface(vaddr2); }