From d17ac3a2ed5869106707b82c7d5b73072d1fc5f3 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 4 Oct 2024 17:53:27 +0200 Subject: [PATCH] - [NEW] Intro acabada --- source/config.h | 1 - source/m_gameover.cpp | 2 +- source/m_intro.cpp | 77 ++++++++++++++++++++++++++++--------------- source/m_logo.cpp | 2 +- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/source/config.h b/source/config.h index db383e3..92a5d4b 100644 --- a/source/config.h +++ b/source/config.h @@ -5,7 +5,6 @@ namespace config #define SOUND_ALL 0 #define SOUND_BASIC 1 #define SOUND_NONE 2 - #define SOUND_MUSIC 2 #define KEY_UP 0 #define KEY_DOWN 1 diff --git a/source/m_gameover.cpp b/source/m_gameover.cpp index febe5fc..8c6c3c1 100644 --- a/source/m_gameover.cpp +++ b/source/m_gameover.cpp @@ -17,7 +17,7 @@ namespace modules void init() { - audio::playMusic("mus_gameover.ogg"); + if (audio::getCurrentMusic() != "mus_gameover.ogg") audio::playMusic("mus_gameover.ogg"); if (heroi == nullptr) heroi = actor::create("HERO", {16,32,8}, {6,6,12}, "test.gif", {0,32,20,32}, {-6,38}); heroi->flags = FLAG_ANIMATED; diff --git a/source/m_intro.cpp b/source/m_intro.cpp index 3220361..d9ab71b 100644 --- a/source/m_intro.cpp +++ b/source/m_intro.cpp @@ -1,6 +1,7 @@ #include "m_intro.h" #include "jdraw.h" #include "jinput.h" +#include "jaudio.h" #include "controller.h" #include "config.h" #include @@ -10,7 +11,7 @@ namespace modules { namespace intro { - int stage = 7; + int stage = 0; uint32_t time = 0; void init() @@ -25,15 +26,23 @@ namespace modules draw::print2("QUE BON DIA FA!", 13, 19, WHITE, FONT_ZOOM_NONE); draw::render(); + if (audio::getCurrentMusic() != "mus_menu.ogg") audio::playMusic("mus_menu.ogg"); } const bool shouldGoToNext() { - return //(SDL_GetTicks()-time > 5000) || + return (SDL_GetTicks()-time > (stage==8?10000:5000)) || (controller::pressed(KEY_JUMP)) || (controller::pressed(KEY_PICK)) || (input::keyPressed(SDL_SCANCODE_SPACE)) || (input::keyPressed(SDL_SCANCODE_RETURN)); } + void drawActorAt(const char* name, const int x, const int y) + { + draw::swapcol(1,PURPLE); + actor::actor_t *act = actor::createFromTemplate(name); act->flags &= ~FLAG_SPECIAL; + actor::drawAt(act, x, y); actor::remove(act); + } + bool loop() { if (input::keyPressed(SDL_SCANCODE_ESCAPE)) return false; @@ -53,7 +62,7 @@ namespace modules draw::draw(96, 28, 128, 96, 0, 0); draw::print2("ME ANE A ESCABUSSARME", 10, 17, WHITE, FONT_ZOOM_NONE); draw::print2("EN LA NOVA PISCINA!", 11, 19, WHITE, FONT_ZOOM_NONE); - draw::render(); + //draw::render(); break; case 2: draw::cls(2); @@ -61,7 +70,7 @@ namespace modules draw::setSource(draw::getSurface("intro3.gif")); draw::draw(96, 28, 128, 96, 0, 0); draw::print2("PERO QUE...??", 14, 17, WHITE, FONT_ZOOM_NONE); - draw::render(); + //draw::render(); break; case 3: draw::cls(2); @@ -70,7 +79,7 @@ namespace modules draw::draw(96, 28, 128, 96, 0, 0); draw::print2("ESTOS PAIASOS ENCARA", 10, 17, WHITE, FONT_ZOOM_NONE); draw::print2("NO L'HAN ACABAT!", 12, 19, WHITE, FONT_ZOOM_NONE); - draw::render(); + //draw::render(); break; case 4: draw::cls(2); @@ -79,7 +88,7 @@ namespace modules draw::draw(96, 28, 128, 96, 0, 0); draw::print2("TINDRE QUE TROBAR JO LES", 8, 17, WHITE, FONT_ZOOM_NONE); draw::print2("PECES DE LA DEPURADORA", 9, 19, WHITE, FONT_ZOOM_NONE); - draw::render(); + //draw::render(); break; case 5: draw::cls(2); @@ -88,7 +97,7 @@ namespace modules draw::draw(96, 28, 128, 96, 0, 0); draw::print2("I ARA ON ESTAN LES ", 11, 17, WHITE, FONT_ZOOM_NONE); draw::print2("MEUES COSES...?", 12, 19, WHITE, FONT_ZOOM_NONE); - draw::render(); + //draw::render(); break; case 6: draw::cls(2); @@ -97,7 +106,7 @@ namespace modules draw::draw(96, 28, 128, 96, 0, 0); draw::print2("ELS GATS ME LES HAN", 11, 17, WHITE, FONT_ZOOM_NONE); draw::print2("REPARTIT PER TOTA LA CASA", 8, 19, WHITE, FONT_ZOOM_NONE); - draw::render(); + //draw::render(); break; case 7: draw::cls(2); @@ -106,39 +115,55 @@ namespace modules draw::draw(96, 28, 128, 96, 0, 0); draw::print2("ESPERE TROBARME ALGUN", 9, 17, WHITE, FONT_ZOOM_NONE); draw::print2("CAFE PEL CAMI...", 12, 19, WHITE, FONT_ZOOM_NONE); - draw::render(); + //draw::render(); break; case 8: actor::templates::load(); draw::cls(2); - actor::actor_t *act = actor::createFromTemplate("S-SHOES"); act->flags &= ~FLAG_SPECIAL; - actor::drawAt(act, 20, 22); actor::remove(act); - draw::print2("SABATES", 7, 3, WHITE, FONT_ZOOM_NONE); - draw::print2("GUANTS", 7, 7, WHITE, FONT_ZOOM_NONE); - draw::print2("PANTALONS", 7, 11, WHITE, FONT_ZOOM_NONE); - draw::print2("MOTXILA", 7, 15, WHITE, FONT_ZOOM_NONE); - draw::print("PER A PODER BOTAR", 57, 35, TEAL, PAPER); - - draw::restorecol(1); - act = actor::createFromTemplate("S-GLOVES"); act->flags &= ~FLAG_SPECIAL; - actor::drawAt(act, 20, 60); actor::remove(act); - act = actor::createFromTemplate("S-PANTS"); act->flags &= ~FLAG_SPECIAL; - actor::drawAt(act, 20, 90); actor::remove(act); + draw::print2("HABILITATS:", 4, 3, YELLOW, FONT_ZOOM_VERTICAL); - act = actor::createFromTemplate("S-BAG"); act->flags &= ~FLAG_SPECIAL; - actor::drawAt(act, 20, 120); actor::remove(act); + draw::print2("PARTS DE LA", 24, 3, YELLOW, FONT_ZOOM_VERTICAL); + draw::print2("DEPURADORA:", 24, 6, YELLOW, FONT_ZOOM_VERTICAL); + + draw::print2("CAFE:", 6, 24, YELLOW, FONT_ZOOM_VERTICAL); + + draw::print2("SABATES", 7, 7, WHITE, FONT_ZOOM_NONE); + draw::print2("GUANTS", 7, 11, WHITE, FONT_ZOOM_NONE); + draw::print2("PANTALONS", 7, 15, WHITE, FONT_ZOOM_NONE); + draw::print2("MOTXILA", 7, 19, WHITE, FONT_ZOOM_NONE); + + draw::print("PER A PODER BOTAR", 57, 51+16, TEAL, PAPER); + draw::print("PER A ESPENTAR OBJECTES", 57, 83+16, TEAL, PAPER); + draw::print("PER A AGAFAR UN OBJECTE", 57, 115+16, TEAL, PAPER); + draw::print("PER A ARREPLEGAR LES PARTS", 57, 147+16, TEAL, PAPER); + + draw::print("BOT LLARG, SUPERVELOCITAT,", 47, 211, TEAL, PAPER); + draw::print("IMMUNITAT, VIDA EXTRA", 47, 218, TEAL, PAPER); + + drawActorAt("S-SHOES", 18, 38+16); + drawActorAt("S-GLOVES", 20, 71+16); + drawActorAt("S-PANTS", 20, 101+16); + drawActorAt("S-BAG", 20, 131+16); + + drawActorAt("P-FILTER", 200, 80); + drawActorAt("P-PIPE", 250, 80); + drawActorAt("P-ELBOW", 200, 120); + drawActorAt("P-SALT", 250, 120); + drawActorAt("P-TIMER", 200, 160); + drawActorAt("P-PUMP", 250, 160); + + drawActorAt("BOOSTER", 20, 190); /*draw::swapcol(1, 10); draw::setSource(draw::getSurface("intro5.gif")); draw::draw(96, 28, 128, 96, 0, 0); draw::print2("ESPERE TROBARME ALGUN", 9, 17, WHITE, FONT_ZOOM_NONE); draw::print2("CAFE PEL CAMI...", 12, 19, WHITE, FONT_ZOOM_NONE);*/ - draw::render(); break; } } - + draw::render(); return true; } } diff --git a/source/m_logo.cpp b/source/m_logo.cpp index 766a98f..4462a2a 100644 --- a/source/m_logo.cpp +++ b/source/m_logo.cpp @@ -79,7 +79,7 @@ namespace modules } } else if (steps<56) { draw::swapcol(1, 12+(steps-40)/2); - //draw::swapcol(2, 19-(steps-40)/2); + draw::swapcol(2, 19-(steps-40)/2); for (int i=0; i