From 83cf446c37af74ced440023f963c16cbdb498af1 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Wed, 2 Jul 2025 17:15:49 +0200 Subject: [PATCH] =?UTF-8?q?-=20[NEW]=20M=C3=B3dul=20"info"retocat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bola.cpp | 7 +++--- bola.h | 3 +-- info.cpp | 14 +++++++++++ info.h | 21 ++++++++-------- main.cpp | 23 +++++++++--------- mapa.cpp | 29 +++++++++++----------- mapa.h | 3 +-- marcador.cpp | 20 +++++++--------- marcador.h | 3 +-- modulegame.cpp | 60 ++++++++++++++++++++++------------------------ modulegame.h | 3 +-- modulesequence.cpp | 49 +++++++++++++++++++------------------ modulesequence.h | 3 +-- momia.cpp | 15 ++++++------ momia.h | 3 +-- prota.cpp | 11 ++++----- prota.h | 3 +-- 17 files changed, 134 insertions(+), 136 deletions(-) create mode 100644 info.cpp diff --git a/bola.cpp b/bola.cpp index e0751be..75dbaef 100644 --- a/bola.cpp +++ b/bola.cpp @@ -2,8 +2,7 @@ #include "jgame.h" #include -Bola::Bola( JD8_Surface gfx, Info* info, Prota* sam ) : Sprite( gfx ) { - this->info = info; +Bola::Bola( JD8_Surface gfx, Prota* sam ) : Sprite( gfx ) { this->sam = sam; this->entitat = (Entitat*)malloc( sizeof( Entitat ) ); @@ -58,8 +57,8 @@ void Bola::update() { // Comprovem si ha tocat a Sam if( this->x > ( this->sam->x - 7 ) && this->x < ( this->sam->x + 7 ) && this->y > ( this->sam->y - 7 ) && this->y < ( this->sam->y + 7 ) ) { this->contador = 200; - this->info->vida--; - if( this->info->vida == 0 ) this->sam->o = 5; + info::vida--; + if( info::vida == 0 ) this->sam->o = 5; } } else { this->contador--; diff --git a/bola.h b/bola.h index 392e180..601a2e8 100644 --- a/bola.h +++ b/bola.h @@ -8,7 +8,7 @@ class Bola : public Sprite { public: - Bola( JD8_Surface gfx, Info* info, Prota* sam ); + Bola( JD8_Surface gfx, Prota* sam ); void draw(); void update(); @@ -18,6 +18,5 @@ protected: Uint8 contador; Prota* sam; - Info* info; }; diff --git a/info.cpp b/info.cpp new file mode 100644 index 0000000..9ad305b --- /dev/null +++ b/info.cpp @@ -0,0 +1,14 @@ +#include "info.h" + +namespace info +{ + int num_piramide; + int num_habitacio; + int diners; + int diamants; + int vida; + int momies; + int engendros; + bool nou_personatge; + bool pepe_activat; +}; diff --git a/info.h b/info.h index 869259b..9d1325a 100644 --- a/info.h +++ b/info.h @@ -1,13 +1,14 @@ #pragma once -struct Info { - int num_piramide; - int num_habitacio; - int diners; - int diamants; - int vida; - int momies; - int engendros; - bool nou_personatge; - bool pepe_activat; +namespace info +{ + extern int num_piramide; + extern int num_habitacio; + extern int diners; + extern int diamants; + extern int vida; + extern int momies; + extern int engendros; + extern bool nou_personatge; + extern bool pepe_activat; }; diff --git a/main.cpp b/main.cpp index 135dc8a..0f2f717 100644 --- a/main.cpp +++ b/main.cpp @@ -37,19 +37,18 @@ int main( int argc, char* args[] ) { JD8_Init("Aventures En Egipte"); JA_Init(48000, SDL_AUDIO_S16, 2); - Info info; - info.num_habitacio = 1; - info.num_piramide = 255; - info.diners = 0; - info.diamants = 0; - info.vida = 5; - info.momies = 0; - info.nou_personatge = false; - info.pepe_activat = false; + info::num_habitacio = 1; + info::num_piramide = 255; + info::diners = 0; + 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; + info::nou_personatge = true; fclose(ini); } @@ -59,13 +58,13 @@ int main( int argc, char* args[] ) { switch (gameState) { case 0: ModuleGame* moduleGame; - moduleGame = new ModuleGame( &info ); + moduleGame = new ModuleGame(); gameState = moduleGame->Go(); delete moduleGame; break; case 1: ModuleSequence* moduleSequence; - moduleSequence = new ModuleSequence( &info ); + moduleSequence = new ModuleSequence(); gameState = moduleSequence->Go(); delete moduleSequence; break; diff --git a/mapa.cpp b/mapa.cpp index 1f730cf..0b5722a 100644 --- a/mapa.cpp +++ b/mapa.cpp @@ -4,10 +4,9 @@ #include "jinput.h" #include -Mapa::Mapa( JD8_Surface gfx, Info* info, Prota* sam ) { +Mapa::Mapa( JD8_Surface gfx, Prota* sam ) { this->gfx = gfx; - this->info = info; this->sam = sam; this->preparaFondoEstatic(); @@ -31,7 +30,7 @@ Mapa::~Mapa(void) { void Mapa::draw() { - if( this->info->num_piramide != 4 ) { + if( info::num_piramide != 4 ) { switch( sam->o ) { case 0: // Down JD8_BlitCKToSurface( sam->x, sam->y, this->gfx, 15, 125 + sam->frame_pejades, 15, 1, this->fondo, 255 ); @@ -97,7 +96,7 @@ void Mapa::preparaFondoEstatic() { // Prepara el fondo est�tic de l'habitaci� this->fondo = JD8_NewSurface(); - if (info->num_piramide == 6) { + if (info::num_piramide == 6) { JD8_BlitToSurface(9, 2, this->gfx, 227, 185, 92, 7, this->fondo); // Text "SECRETA" } else { @@ -106,12 +105,12 @@ void Mapa::preparaFondoEstatic() { } JD8_BlitToSurface(130, 2, this->gfx, 225, 192, 19, 8, this->fondo); // Montonet de monedes + signe '=' JD8_BlitToSurface(220, 2, this->gfx, 160, 185, 48, 7, this->fondo); // Text "ENERGIA" - if (this->info->diners >= 200) JD8_BlitToSurface(175, 3, this->gfx, 60, 193, 7, 6, this->fondo); + if (info::diners >= 200) JD8_BlitToSurface(175, 3, this->gfx, 60, 193, 7, 6, this->fondo); // Pinta taulells for( int y = 0; y < 11; y++ ) { for( int x = 0; x < 19; x++ ) { - switch( info->num_piramide ) { + switch( info::num_piramide ) { case 1: JD8_BlitToSurface( 20+(x*15), 30+(y*15), this->gfx, 0, 80, 15, 15, this->fondo ); break; @@ -156,7 +155,7 @@ void Mapa::preparaFondoEstatic() { // Pinta la porta JD8_BlitCKToSurface( 150, 18, this->gfx, 0, 143, 15, 12, this->fondo, 255 ); - if( info->num_piramide == 2 ) { + if( info::num_piramide == 2 ) { JD8_BlitToSurface( 5, 100, this->gfx, 30, 140, 15, 15, this->fondo ); } } @@ -168,9 +167,9 @@ void swap( Uint8& a, Uint8& b ) { } void Mapa::preparaTombes() { - const Uint8 contingut = this->info->num_piramide == 6 ? CONTE_DIAMANT : CONTE_RES; - int cx = this->info->num_piramide == 6 ? 270 : 0; - int cy = this->info->num_piramide == 6 ? 50 : 0; + const Uint8 contingut = info::num_piramide == 6 ? CONTE_DIAMANT : CONTE_RES; + int cx = info::num_piramide == 6 ? 270 : 0; + int cy = info::num_piramide == 6 ? 50 : 0; for( int i = 0; i < 16; i++ ) { this->tombes[i].contingut = contingut; @@ -182,7 +181,7 @@ void Mapa::preparaTombes() { this->tombes[i].x = cx; this->tombes[i].y = cy; } - if (this->info->num_piramide == 6) return; + if (info::num_piramide == 6) return; this->tombes[0].contingut = CONTE_FARAO; this->tombes[1].contingut = CONTE_CLAU; this->tombes[2].contingut = CONTE_PERGAMI; @@ -254,7 +253,7 @@ void Mapa::comprovaCaixa( Uint8 num ) break; case CONTE_TRESOR: this->tombes[num].x = 100; - info->diners++; + info::diners++; break; case CONTE_FARAO: this->tombes[num].x = 150; @@ -274,9 +273,9 @@ void Mapa::comprovaCaixa( Uint8 num ) break; case CONTE_DIAMANT: this->tombes[num].y = 70; - info->diamants++; - info->diners += VALOR_DIAMANT; - if (info->diamants == 16) this->farao = this->clau = true; + info::diamants++; + info::diners += VALOR_DIAMANT; + if (info::diamants == 16) this->farao = this->clau = true; break; } diff --git a/mapa.h b/mapa.h index c67cf3e..e5ee2e4 100644 --- a/mapa.h +++ b/mapa.h @@ -30,7 +30,7 @@ class Mapa { public: - Mapa( JD8_Surface gfx, Info* info, Prota* sam ); + Mapa( JD8_Surface gfx, Prota* sam ); ~Mapa(void); void draw(); @@ -52,7 +52,6 @@ protected: JD8_Surface fondo; Vertex vertex; Vertex ultim_vertex; - Info* info; Uint8 frame_torxes; Prota* sam; diff --git a/marcador.cpp b/marcador.cpp index a981098..d24f3af 100644 --- a/marcador.cpp +++ b/marcador.cpp @@ -1,11 +1,9 @@ #include "marcador.h" -Marcador::Marcador( JD8_Surface gfx, Info* info, Prota* sam ) { +Marcador::Marcador( JD8_Surface gfx, Prota* sam ) { this->gfx = gfx; - this->info = info; this->sam = sam; - } Marcador::~Marcador(void) { @@ -13,19 +11,19 @@ Marcador::~Marcador(void) { void Marcador::draw() { - if (this->info->num_piramide < 6) { - this->pintaNumero(55, 2, this->info->num_piramide); - this->pintaNumero(80, 2, this->info->num_habitacio); + if (info::num_piramide < 6) { + this->pintaNumero(55, 2, info::num_piramide); + this->pintaNumero(80, 2, info::num_habitacio); } - this->pintaNumero( 149, 2, this->info->diners / 100 ); - this->pintaNumero( 156, 2, ( this->info->diners % 100 ) / 10 ); - this->pintaNumero( 163, 2, this->info->diners % 10 ); + this->pintaNumero( 149, 2, info::diners / 100 ); + this->pintaNumero( 156, 2, ( info::diners % 100 ) / 10 ); + this->pintaNumero( 163, 2, info::diners % 10 ); if( this->sam->pergami ) JD8_BlitCK( 190, 1, this->gfx, 209, 185, 15, 14, 255 ); - JD8_BlitCK( 271, 1, this->gfx, 0, 20, 15, this->info->vida*3, 255 ); - if( this->info->vida < 5 ) JD8_BlitCK( 271, 1+(this->info->vida*3), this->gfx, 75, 20, 15, 15-(this->info->vida*3), 255 ); + JD8_BlitCK( 271, 1, this->gfx, 0, 20, 15, info::vida*3, 255 ); + if( info::vida < 5 ) JD8_BlitCK( 271, 1+(info::vida*3), this->gfx, 75, 20, 15, 15-(info::vida*3), 255 ); } void Marcador::pintaNumero( Uint16 x, Uint16 y, Uint8 num ) { diff --git a/marcador.h b/marcador.h index 6a6d6f5..f0d0481 100644 --- a/marcador.h +++ b/marcador.h @@ -8,7 +8,7 @@ class Marcador { public: - Marcador( JD8_Surface gfx, Info* info, Prota* sam ); + Marcador( JD8_Surface gfx, Prota* sam ); ~Marcador(void); void draw(); @@ -18,7 +18,6 @@ protected: void pintaNumero( Uint16 x, Uint16 y, Uint8 num ); JD8_Surface gfx; - Info* info; Prota* sam; }; diff --git a/modulegame.cpp b/modulegame.cpp index 55bb684..793c575 100644 --- a/modulegame.cpp +++ b/modulegame.cpp @@ -6,18 +6,16 @@ #include "jinput.h" #include "jfile.h" -ModuleGame::ModuleGame( Info* info ) { +ModuleGame::ModuleGame() { - this->info = info; - - this->gfx = JD8_LoadSurface( this->info->pepe_activat ? "frames2.gif" : "frames.gif" ); + this->gfx = JD8_LoadSurface( info::pepe_activat ? "frames2.gif" : "frames.gif" ); JG_SetUpdateTicks(10); - this->sam = new Prota( this->gfx, this->info ); - this->mapa = new Mapa( this->gfx, this->info, this->sam ); - this->marcador = new Marcador( this->gfx, this->info, this->sam ); - if( this->info->num_piramide == 2 ) { - this->bola = new Bola( this->gfx, this->info, this->sam ); + this->sam = new Prota( this->gfx ); + this->mapa = new Mapa( this->gfx, this->sam ); + this->marcador = new Marcador( this->gfx, this->sam ); + if( info::num_piramide == 2 ) { + this->bola = new Bola( this->gfx, this->sam ); } else { this->bola = NULL; } @@ -49,7 +47,7 @@ int ModuleGame::Go() { this->Draw(); - const char* music = this->info->num_piramide == 3 ? "00000008.ogg" : (this->info->num_piramide == 2 ? "00000007.ogg" : (this->info->num_piramide == 6 ? "00000002.ogg" : "00000006.ogg")); + const char* music = info::num_piramide == 3 ? "00000008.ogg" : (info::num_piramide == 2 ? "00000007.ogg" : (info::num_piramide == 6 ? "00000002.ogg" : "00000006.ogg")); const char *current_music = JA_GetMusicFilename(); if ( (JA_GetMusicState()!=JA_MUSIC_PLAYING) || !(strcmp(music, current_music) == 0)) { int size; @@ -57,7 +55,7 @@ int ModuleGame::Go() { JA_PlayMusic(JA_LoadMusic((Uint8*)buffer, size, music)); } - JD8_FadeToPal( JD8_LoadPalette(this->info->pepe_activat ? "frames2.gif" : "frames.gif") ); + JD8_FadeToPal( JD8_LoadPalette(info::pepe_activat ? "frames2.gif" : "frames.gif") ); while (this->final == 0 && !JG_Quitting()) { @@ -68,20 +66,20 @@ int ModuleGame::Go() { //JS_FadeOutMusic(); if( this->final == 1 ) { - this->info->num_habitacio++; - if( this->info->num_habitacio == 6 ) { - this->info->num_habitacio = 1; - this->info->num_piramide++; + info::num_habitacio++; + if( info::num_habitacio == 6 ) { + info::num_habitacio = 1; + info::num_piramide++; } - if (this->info->num_piramide == 6 && this->info->num_habitacio == 2) this->info->num_piramide++; + if (info::num_piramide == 6 && info::num_habitacio == 2) info::num_piramide++; } else if (this->final == 2) { - this->info->num_piramide = 100; + info::num_piramide = 100; } if( JG_Quitting() ) { return -1; } else { - if (this->info->num_habitacio == 1 || this->info->num_piramide == 100 || this->info->num_piramide == 7) { + if (info::num_habitacio == 1 || info::num_piramide == 100 || info::num_piramide == 7) { return 1; } else { return 0; @@ -109,27 +107,27 @@ void ModuleGame::Update() { Momia* seguent = this->momies->next; delete this->momies; this->momies = seguent; - this->info->momies--; + info::momies--; } if( this->bola != NULL ) this->bola->update(); this->mapa->update(); if( this->mapa->novaMomia() ) { if( this->momies != NULL ) { - this->momies->insertar( new Momia( this->gfx, this->info, true, 0, 0, this->sam ) ); - this->info->momies++; + this->momies->insertar( new Momia( this->gfx, true, 0, 0, this->sam ) ); + info::momies++; } else { - this->momies = new Momia( this->gfx, this->info, true, 0, 0, this->sam ); - this->info->momies++; + this->momies = new Momia( this->gfx, true, 0, 0, this->sam ); + info::momies++; } } - if( JI_CheatActivated( "reviu" ) ) this->info->vida = 5; + if( JI_CheatActivated( "reviu" ) ) info::vida = 5; if( JI_CheatActivated( "alone" ) ) { if( this->momies != NULL ) { this->momies->clear(); delete this->momies; this->momies = NULL; - this->info->momies = 0; + info::momies = 0; } } if( JI_CheatActivated( "obert" ) ) { @@ -150,17 +148,17 @@ void ModuleGame::Update() { void ModuleGame::iniciarMomies() { - if( this->info->num_habitacio == 1 ) { this->info->momies = 1; } else { this->info->momies++; } - if (this->info->num_piramide == 6) this->info->momies = 8; + if( info::num_habitacio == 1 ) { info::momies = 1; } else { info::momies++; } + if (info::num_piramide == 6) info::momies = 8; int x = 20; int y = 170; - bool dimonis = this->info->num_piramide == 6; - for( int i = 0; i < info->momies; i++ ) { + bool dimonis = info::num_piramide == 6; + for( int i = 0; i < info::momies; i++ ) { if( this->momies == NULL) { - this->momies = new Momia( this->gfx, this->info, dimonis, x, y, this->sam ); + this->momies = new Momia( this->gfx, dimonis, x, y, this->sam ); } else { - this->momies->insertar( new Momia( this->gfx, this->info, dimonis, x, y, this->sam ) ); + this->momies->insertar( new Momia( this->gfx, dimonis, x, y, this->sam ) ); } x += 65; if( x == 345 ) { x = 20; y -= 35; } diff --git a/modulegame.h b/modulegame.h index 2a6dbab..087ad95 100644 --- a/modulegame.h +++ b/modulegame.h @@ -11,7 +11,7 @@ class ModuleGame { public: - ModuleGame( Info* info ); + ModuleGame(); ~ModuleGame(void); int Go(); @@ -24,7 +24,6 @@ private: void iniciarMomies(); Uint8 final; - Info* info; JD8_Surface gfx; Mapa* mapa; diff --git a/modulesequence.cpp b/modulesequence.cpp index 94e61f5..0bc71b9 100644 --- a/modulesequence.cpp +++ b/modulesequence.cpp @@ -8,8 +8,7 @@ #include #include -ModuleSequence::ModuleSequence( Info* info ) { - this->info = info; +ModuleSequence::ModuleSequence() { } ModuleSequence::~ModuleSequence(void) { @@ -17,9 +16,9 @@ ModuleSequence::~ModuleSequence(void) { int ModuleSequence::Go() { - if( this->info->num_piramide == 6 && this->info->diners < 200 ) this->info->num_piramide = 7; + if( info::num_piramide == 6 && info::diners < 200 ) info::num_piramide = 7; - switch( this->info->num_piramide ) { + switch( info::num_piramide ) { case 255: // Intro doIntro(); break; @@ -52,22 +51,22 @@ int ModuleSequence::Go() { if( JG_Quitting() ) { return -1; } else { - if( this->info->num_piramide == 255 ) { - this->info->num_piramide = 0; + if( info::num_piramide == 255 ) { + info::num_piramide = 0; return 1; - } else if( this->info->num_piramide == 0 ) { - this->info->num_piramide = 1; - //this->info->num_piramide = 6; - //this->info->diners = 200; + } else if( info::num_piramide == 0 ) { + info::num_piramide = 1; + //info::num_piramide = 6; + //info::diners = 200; return 1; - } else if( this->info->num_piramide == 7 ) { - this->info->num_piramide = 8; + } else if( info::num_piramide == 7 ) { + info::num_piramide = 8; return 1; - } else if( this->info->num_piramide == 8 ) { - this->info->num_piramide = 255; + } else if( info::num_piramide == 8 ) { + info::num_piramide = 255; return 1; - } else if( this->info->num_piramide == 100 ) { - this->info->num_piramide = 0; + } else if( info::num_piramide == 100 ) { + info::num_piramide = 0; return 1; } else { return 0; @@ -620,7 +619,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... + if ((contador % 100 > 30) && info::nou_personatge) JD8_BlitCK(68, 141, gfx, 128, 105, 189, 9, 255); // 'p' per a personatge nou... JD8_Flip(); @@ -632,7 +631,7 @@ void ModuleSequence::doMenu() { JI_Update(); } } - this->info->pepe_activat = JI_KeyPressed(SDL_SCANCODE_P); + info::pepe_activat = JI_KeyPressed(SDL_SCANCODE_P); JI_DisableKeyboard(60); JD8_FreeSurface( fondo ); JD8_FreeSurface( gfx ); @@ -644,9 +643,9 @@ void ModuleSequence::doSlides() { const char* arxiu; - if( this->info->num_piramide == 7 ) { + if( info::num_piramide == 7 ) { play_music("00000005.ogg", 1); - if (this->info->diners < 200) { + if (info::diners < 200) { arxiu = "intro2.gif"; } else { arxiu = "intro3.gif"; @@ -706,7 +705,7 @@ void ModuleSequence::doSlides() { step++; break; case 8: - if (this->info->num_piramide != 7) JA_FadeOutMusic(250); + if (info::num_piramide != 7) JA_FadeOutMusic(250); exit = true; break; } @@ -730,7 +729,7 @@ void ModuleSequence::doBanner() { JD8_Blit( 81, 24, gfx, 81, 155, 168, 21 ); JD8_Blit( 39, 150, gfx, 39, 175, 248, 20 ); - switch( this->info->num_piramide ) { + switch( info::num_piramide ) { case 2: JD8_Blit( 82, 60, gfx, 0, 0, 160, 75 ); break; @@ -885,7 +884,7 @@ void ModuleSequence::doCredits() { JD8_BlitCK(100, 20, vaddr2, 85, 0, 120, 140, 0); } - if (this->info->diamants == 16) { + if (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); @@ -909,7 +908,7 @@ void ModuleSequence::doCredits() { FILE* ini = fopen("trick.ini", "wb"); fwrite("1", 1, 1, ini); fclose(ini); - this->info->nou_personatge = true; + info::nou_personatge = true; JD8_FreeSurface(vaddr3); JD8_FreeSurface(vaddr2); @@ -920,7 +919,7 @@ void ModuleSequence::doMort() { JI_DisableKeyboard(60); - this->info->vida = 5; + info::vida = 5; this->contador = 1000; JD8_Surface gfx = JD8_LoadSurface( "gameover.gif" ); diff --git a/modulesequence.h b/modulesequence.h index a209cf5..a7fe94b 100644 --- a/modulesequence.h +++ b/modulesequence.h @@ -6,7 +6,7 @@ class ModuleSequence { public: - ModuleSequence( Info* info ); + ModuleSequence(); ~ModuleSequence(void); int Go(); @@ -21,6 +21,5 @@ private: void doCredits(); void doMort(); - Info* info; int contador; }; diff --git a/momia.cpp b/momia.cpp index 8c51abe..3bd5201 100644 --- a/momia.cpp +++ b/momia.cpp @@ -2,8 +2,7 @@ #include "jgame.h" #include -Momia::Momia( JD8_Surface gfx, Info* info, bool dimoni, Uint16 x, Uint16 y, Prota* sam ) : Sprite( gfx ) { - this->info = info; +Momia::Momia( JD8_Surface gfx, bool dimoni, Uint16 x, Uint16 y, Prota* sam ) : Sprite( gfx ) { this->dimoni = dimoni; this->sam = sam; @@ -16,7 +15,7 @@ Momia::Momia( JD8_Surface gfx, Info* info, bool dimoni, Uint16 x, Uint16 y, Prot for( int x = 0; x < 5; x++ ) { this->entitat->frames[frame].w = 15; this->entitat->frames[frame].h = 15; - if( this->info->num_piramide == 4 ) this->entitat->frames[frame].h -= 5; + if( info::num_piramide == 4 ) this->entitat->frames[frame].h -= 5; this->entitat->frames[frame].x = (x*15)+75; if( this->dimoni ) this->entitat->frames[frame].x += 75; this->entitat->frames[frame].y = 20+(y*15); @@ -83,7 +82,7 @@ void Momia::draw() { Sprite::draw(); - if( this->info->num_piramide == 4 ) { + if( info::num_piramide == 4 ) { if( ( JG_GetCycleCounter() % 40 ) < 20 ) { JD8_BlitCK(this->x, this->y, this->gfx, 220, 80, 15, 15, 255 ); } else { @@ -104,7 +103,7 @@ bool Momia::update() { this->engendro = NULL; } } else { - if( this->sam->o < 4 && ( this->dimoni || this->info->num_piramide == 5 || JG_GetCycleCounter()%2 == 0 ) ) { + if( this->sam->o < 4 && ( this->dimoni || info::num_piramide == 5 || JG_GetCycleCounter()%2 == 0 ) ) { if( ( this->x - 20 ) % 65 == 0 && ( this->y - 30 ) % 35 == 0 ) { if( this->dimoni ) { @@ -149,8 +148,8 @@ bool Momia::update() { if( this->sam->pergami ) { this->sam->pergami = false; } else { - this->info->vida--; - if( this->info->vida == 0 ) this->sam->o = 5; + info::vida--; + if( info::vida == 0 ) this->sam->o = 5; } } } @@ -161,7 +160,7 @@ bool Momia::update() { Momia* seguent = this->next->next; delete this->next; this->next = seguent; - this->info->momies--; + info::momies--; } } diff --git a/momia.h b/momia.h index c06fc09..670dd90 100644 --- a/momia.h +++ b/momia.h @@ -9,7 +9,7 @@ class Momia : public Sprite { public: - Momia( JD8_Surface gfx, Info* info, bool dimoni, Uint16 x, Uint16 y, Prota* sam ); + Momia( JD8_Surface gfx, bool dimoni, Uint16 x, Uint16 y, Prota* sam ); void clear(); void draw(); @@ -22,7 +22,6 @@ public: protected: Prota* sam; - Info* info; Engendro* engendro; }; diff --git a/prota.cpp b/prota.cpp index 3192bde..9550b4d 100644 --- a/prota.cpp +++ b/prota.cpp @@ -3,8 +3,7 @@ #include "jinput.h" #include -Prota::Prota( JD8_Surface gfx, Info* info ) : Sprite( gfx ) { - this->info = info; +Prota::Prota( JD8_Surface gfx ) : Sprite( gfx ) { this->entitat = (Entitat*)malloc( sizeof( Entitat ) ); this->entitat->num_frames = 82; @@ -14,7 +13,7 @@ Prota::Prota( JD8_Surface gfx, Info* info ) : Sprite( gfx ) { for( int x = 0; x < 5; x++ ) { this->entitat->frames[frame].w = 15; this->entitat->frames[frame].h = 15; - if( this->info->num_piramide == 4 ) this->entitat->frames[frame].h -= 5; + if( info::num_piramide == 4 ) this->entitat->frames[frame].h -= 5; this->entitat->frames[frame].x = x*15; this->entitat->frames[frame].y = 20+(y*15); frame++; @@ -26,7 +25,7 @@ Prota::Prota( JD8_Surface gfx, Info* info ) : Sprite( gfx ) { if( x != 300 || y != 155 ) { this->entitat->frames[frame].w = 15; this->entitat->frames[frame].h = 30; - if( this->info->num_piramide == 4 ) this->entitat->frames[frame].h -= 5; + if( info::num_piramide == 4 ) this->entitat->frames[frame].h -= 5; this->entitat->frames[frame].x = x; this->entitat->frames[frame].y = y; frame++; @@ -37,7 +36,7 @@ Prota::Prota( JD8_Surface gfx, Info* info ) : Sprite( gfx ) { for( int x = 225; x < 315; x+=15 ) { this->entitat->frames[frame].w = 15; this->entitat->frames[frame].h = 15; - if( this->info->num_piramide == 4 ) this->entitat->frames[frame].h -= 5; + if( info::num_piramide == 4 ) this->entitat->frames[frame].h -= 5; this->entitat->frames[frame].x = x; this->entitat->frames[frame].y = y; frame++; @@ -80,7 +79,7 @@ void Prota::draw() { Sprite::draw(); - if( this->info->num_piramide == 4 && this->o != 4) { + if( info::num_piramide == 4 && this->o != 4) { if( ( JG_GetCycleCounter() % 40 ) < 20 ) { JD8_BlitCK(this->x, this->y, this->gfx, 220, 80, 15, 15, 255 ); } else { diff --git a/prota.h b/prota.h index aefd2af..af89e17 100644 --- a/prota.h +++ b/prota.h @@ -7,7 +7,7 @@ class Prota : public Sprite { public: - Prota( JD8_Surface gfx, Info* info ); + Prota( JD8_Surface gfx ); void draw(); Uint8 update(); @@ -17,6 +17,5 @@ public: protected: - Info* info; };