diff --git a/data/gifs.txt b/data/gifs.txt index a3fff03..eb7682f 100644 --- a/data/gifs.txt +++ b/data/gifs.txt @@ -22,6 +22,8 @@ mapa.gif objectes.gif obrer.gif piscina.gif +prologo1.gif +prologo2.gif roomaux.gif sam.gif test.gif diff --git a/data/prologo1.gif b/data/prologo1.gif new file mode 100644 index 0000000..042e41f Binary files /dev/null and b/data/prologo1.gif differ diff --git a/data/prologo2.gif b/data/prologo2.gif new file mode 100644 index 0000000..462e558 Binary files /dev/null and b/data/prologo2.gif differ diff --git a/data/rooms/64.txt b/data/rooms/64.txt index 16a6472..2131394 100644 --- a/data/rooms/64.txt +++ b/data/rooms/64.txt @@ -176,11 +176,11 @@ actor{ } actor{ - name: S-BAG + name: X-0 bmp: objectes.gif - bmp-rect: 145 41 20 25 - bmp-offset: -5 27 - pos: 31 13 16 + bmp-rect: 162 0 28 22 + bmp-offset: -3 24 + pos: 8 32 0 size: 4 4 4 anim-cycle: SEQ anim-wait: 2 @@ -189,25 +189,12 @@ actor{ } actor{ - name: S-GLOVES - bmp: objectes.gif - bmp-rect: 165 45 21 22 - bmp-offset: -2 26 - pos: 24 14 4 - size: 4 4 4 - anim-cycle: SEQ - anim-wait: 2 - flags: SPECIAL - movement: CW -} - -actor{ - name: S-PANTS + name: X-1 bmp: objectes.gif bmp-rect: 167 22 18 23 bmp-offset: -7 27 pos: 16 24 4 - size: 4 4 4 + size: 4 4 6 anim-cycle: SEQ anim-wait: 2 flags: SPECIAL @@ -215,12 +202,25 @@ actor{ } actor{ - name: S-SHOES + name: X-2 bmp: objectes.gif - bmp-rect: 162 0 28 22 - bmp-offset: -3 24 - pos: 0 24 0 - size: 4 4 4 + bmp-rect: 165 45 21 22 + bmp-offset: -2 26 + pos: 24 14 4 + size: 4 4 5 + anim-cycle: SEQ + anim-wait: 2 + flags: SPECIAL + movement: CW +} + +actor{ + name: X-3 + bmp: objectes.gif + bmp-rect: 145 41 20 25 + bmp-offset: -5 27 + pos: 34 13 16 + size: 6 4 6 anim-cycle: SEQ anim-wait: 2 flags: SPECIAL diff --git a/data/rooms/69.txt b/data/rooms/69.txt index a708bf5..9c10cbf 100644 --- a/data/rooms/69.txt +++ b/data/rooms/69.txt @@ -210,19 +210,6 @@ actor{ movement: Y } -actor{ - name: S-GLOVES - bmp: objectes.gif - bmp-rect: 165 45 21 22 - bmp-offset: -2 26 - pos: 8 22 0 - size: 4 4 4 - anim-cycle: SEQ - anim-wait: 2 - flags: SPECIAL - movement: CW -} - actor{ name: WC bmp: altres.gif @@ -234,3 +221,16 @@ actor{ flags: ORIENTABLE movement: CCW } + +actor{ + name: Y-2 + bmp: objectes.gif + bmp-rect: 165 45 21 22 + bmp-offset: -2 26 + pos: 8 22 0 + size: 4 4 5 + anim-cycle: SEQ + anim-wait: 2 + flags: SPECIAL + movement: CW +} diff --git a/data/rooms/75.txt b/data/rooms/75.txt index 9622cca..e519ee3 100644 --- a/data/rooms/75.txt +++ b/data/rooms/75.txt @@ -94,19 +94,6 @@ actor{ movement: Y } -actor{ - name: S-PANTS - bmp: objectes.gif - bmp-rect: 167 22 18 23 - bmp-offset: -7 27 - pos: 0 16 0 - size: 4 4 4 - anim-cycle: SEQ - anim-wait: 2 - flags: SPECIAL - movement: CW -} - actor{ name: TRANSPA-00 bmp: altres.gif @@ -316,3 +303,16 @@ actor{ size: 8 8 6 movement: CW } + +actor{ + name: Y-1 + bmp: objectes.gif + bmp-rect: 167 22 18 23 + bmp-offset: -7 27 + pos: 0 16 0 + size: 4 4 6 + anim-cycle: SEQ + anim-wait: 2 + flags: SPECIAL + movement: CW +} diff --git a/data/rooms/78.txt b/data/rooms/78.txt index 4934a87..89878fa 100644 --- a/data/rooms/78.txt +++ b/data/rooms/78.txt @@ -402,12 +402,12 @@ actor{ } actor{ - name: S-SHOES + name: Y-0 bmp: objectes.gif bmp-rect: 162 0 28 22 bmp-offset: -3 24 pos: 40 0 4 - size: 4 4 4 + size: 6 6 4 anim-cycle: SEQ anim-wait: 2 flags: SPECIAL diff --git a/data/rooms/85.txt b/data/rooms/85.txt index fd7f51d..24f8f41 100644 --- a/data/rooms/85.txt +++ b/data/rooms/85.txt @@ -155,19 +155,6 @@ actor{ movement: Y } -actor{ - name: S-BAG - bmp: objectes.gif - bmp-rect: 145 41 20 25 - bmp-offset: -5 27 - pos: 0 56 20 - size: 4 4 4 - anim-cycle: SEQ - anim-wait: 2 - flags: SPECIAL - movement: CW -} - actor{ name: TRANSPA-00 bmp: altres.gif @@ -268,3 +255,16 @@ actor{ flags: PUSHABLE GRAVITY movement: CW } + +actor{ + name: Y-3 + bmp: objectes.gif + bmp-rect: 145 41 20 25 + bmp-offset: -5 27 + pos: 0 56 20 + size: 6 4 6 + anim-cycle: SEQ + anim-wait: 2 + flags: SPECIAL + movement: CW +} diff --git a/source/actor.cpp b/source/actor.cpp index 0113d1c..5c27c6b 100644 --- a/source/actor.cpp +++ b/source/actor.cpp @@ -675,6 +675,36 @@ namespace actor hero::pickAnbernic(act->name); audio::playSound("snd_pick.wav", SOUND_BASIC); } + else if (act->name[0] == 'X') + { + if (hero::isCarryingPrologoObject()) { + audio::playSound("snd_push.wav", SOUND_BASIC); + return result; + } else { + hero::pickPrologoObject(act->name[2]-48); + audio::playSound("snd_pick.wav", SOUND_BASIC); + } + } + else if (act->name[0] == 'Y') + { + const int which = act->name[2]-48; + if (hero::getPrologoObjectState(which)==PROLOGO_OBJECT_PICKED) + { + hero::leavePrologoObject(which); + audio::playSound("snd_pick.wav", SOUND_BASIC); + act->name[0] = 'Z'; + room::cycleColor(1); + return result; + } else { + audio::playSound("snd_push.wav", SOUND_BASIC); + return result; + } + } + else if (act->name[0] == 'Z') + { + audio::playSound("snd_push.wav", SOUND_BASIC); + return result; + } else { SDL_assert(false); @@ -1500,9 +1530,10 @@ namespace actor if (editor::isEditing() && (act == selected) && modules::game::getSection() == modules::game::SECTION_ACTOR) draw::swapcol(1, room::getColor(1)); // Si està seleccionat, que canvie de color draw::stencil::set(act->tag); - draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x + ao, act->bmp_rect.y + oo, flip); + if (!(act->flags & FLAG_SPECIAL) || !(act->name[0] == 'Y') || (brilli_brilli<4) ) + draw::draw(x, y, act->bmp_rect.w, act->bmp_rect.h, act->bmp_rect.x + ao, act->bmp_rect.y + oo, flip); draw::swapcol(1, room::getColor(0)); // Tornem al color per defecte - if ((act->flags & FLAG_SPECIAL) && (act->name[0] != 'A')) + if ((act->flags & FLAG_SPECIAL) && (act->name[0] != 'A') && (act->name[0] != 'Z')) { draw::setSource(brilli); const int dx = (act->bmp_rect.w - 22) >> 1; @@ -1917,10 +1948,11 @@ namespace actor int first_orient = 0; bool dead = false; bool prologo = false; + int prologo_objects[4] = {PROLOGO_OBJECT_INITIAL, PROLOGO_OBJECT_INITIAL, PROLOGO_OBJECT_INITIAL, PROLOGO_OBJECT_INITIAL}; - void setPrologo() + void setPrologo(const bool value) { - prologo = true; + prologo = value; } const bool isPrologo() @@ -1951,6 +1983,7 @@ namespace actor lives = 8; skills = SKILL_NONE; if (prologo) skills &= SKILL_SHOES; + for (int i=0;i<4;++i) prologo_objects[i] = PROLOGO_OBJECT_INITIAL; parts = PART_NONE; for (int i = 0; i < 10; ++i) anbernics[i] = false; @@ -2238,6 +2271,27 @@ namespace actor return count; } + void pickPrologoObject(int which) + { + prologo_objects[which] = PROLOGO_OBJECT_PICKED; + } + + void leavePrologoObject(int which) + { + prologo_objects[which] = PROLOGO_OBJECT_LEFT; + } + + const bool isCarryingPrologoObject() + { + for (auto object : prologo_objects) if (object==PROLOGO_OBJECT_PICKED) return true; + return false; + } + + const int getPrologoObjectState(int which) + { + return prologo_objects[which]; + } + void move(int *x, int *y, int *z) { actor_t *hero = actor::find("HERO"); diff --git a/source/actor.h b/source/actor.h index 40d832a..40a739f 100644 --- a/source/actor.h +++ b/source/actor.h @@ -198,7 +198,16 @@ namespace actor namespace hero { - void setPrologo(); + #define PROLOGO_OBJECT_INITIAL 0 + #define PROLOGO_OBJECT_PICKED 1 + #define PROLOGO_OBJECT_LEFT 2 + + #define PROLOGO_SHOES 0 + #define PROLOGO_PANTS 1 + #define PROLOGO_GLOVES 2 + #define PROLOGO_BAG 3 + + void setPrologo(const bool value); const bool isPrologo(); void init(const bool complete = true); int getLives(); @@ -239,6 +248,11 @@ namespace actor bool wasAnbernicCollected(char *name); int getNumAmbernicsCollected(); + void pickPrologoObject(int which); + void leavePrologoObject(int which); + const bool isCarryingPrologoObject(); + const int getPrologoObjectState(int which); + void move(int *x, int *y, int *z); void setFirstPos(); } diff --git a/source/m_game.cpp b/source/m_game.cpp index 64c99fe..8922b94 100644 --- a/source/m_game.cpp +++ b/source/m_game.cpp @@ -24,7 +24,7 @@ namespace modules void init(const bool prologo) { - if (prologo) actor::hero::setPrologo(); + actor::hero::setPrologo(prologo); actor::clear(true); ::game::setUpdateTicks(64); actor::templates::load(); @@ -398,45 +398,64 @@ namespace modules draw::print2("no", 4, 25, col3, FONT_ZOOM_NONE); draw::print2(actor::hero::getLives(), 2, 4, 26, col1, FONT_ZOOM_VERTICAL); - draw::print2("a", 9, 26, col1, FONT_ZOOM_NONE); - draw::print2("b", 12, 26, col2, FONT_ZOOM_NONE); - draw::print2("c", 15, 26, col3, FONT_ZOOM_NONE); - - draw::print2(actor::hero::getBoostJump(), 2, 8, 27, col3, FONT_ZOOM_NONE); - draw::print2(actor::hero::getBoostGod()/2, 2, 11, 27, col1, FONT_ZOOM_NONE); - draw::print2(actor::hero::getBoostRun()/2, 2, 14, 27, col2, FONT_ZOOM_NONE); - - draw::stencil::enable(); - draw::stencil::clear(255); - - draw::setSource(draw::getSurface("objectes.gif")); - draw::stencil::set(SKILL_SHOES); - draw::swapcol(1, actor::hero::getSkills()&SKILL_SHOES ? col1 : col3); - draw::draw(276,166, 28, 22, 162, 0); - draw::stencil::set(SKILL_PANTS); - draw::swapcol(1, actor::hero::getSkills()&SKILL_PANTS ? col1 : col3); - draw::draw(250,183, 18, 23, 167, 22); - draw::stencil::set(SKILL_GLOVES); - draw::swapcol(1, actor::hero::getSkills()&SKILL_GLOVES ? col1 : col3); - draw::draw(222,200, 21, 22, 165, 45); - draw::stencil::set(SKILL_BAG); - draw::swapcol(1, actor::hero::getSkills()&SKILL_BAG ? col1 : col3); - draw::draw(279,200, 20, 25, 145, 41); - - draw::stencil::disable(); - - // Si estem en el editor, fent click en els skills del marcador els obtenim - if (editor::isDevMode() && input::mouseClk(1)) + if (!actor::hero::isPrologo()) { - const uint8_t val = draw::stencil::query(input::mouseX(), input::mouseY()); - if (val != 255) + draw::print2("a", 9, 26, col1, FONT_ZOOM_NONE); + draw::print2("b", 12, 26, col2, FONT_ZOOM_NONE); + draw::print2("c", 15, 26, col3, FONT_ZOOM_NONE); + + draw::print2(actor::hero::getBoostJump(), 2, 8, 27, col3, FONT_ZOOM_NONE); + draw::print2(actor::hero::getBoostGod()/2, 2, 11, 27, col1, FONT_ZOOM_NONE); + draw::print2(actor::hero::getBoostRun()/2, 2, 14, 27, col2, FONT_ZOOM_NONE); + + draw::stencil::enable(); + draw::stencil::clear(255); + + draw::setSource(draw::getSurface("objectes.gif")); + draw::stencil::set(SKILL_SHOES); + draw::swapcol(1, actor::hero::getSkills()&SKILL_SHOES ? col1 : col3); + draw::draw(276,166, 28, 22, 162, 0); + draw::stencil::set(SKILL_PANTS); + draw::swapcol(1, actor::hero::getSkills()&SKILL_PANTS ? col1 : col3); + draw::draw(250,183, 18, 23, 167, 22); + draw::stencil::set(SKILL_GLOVES); + draw::swapcol(1, actor::hero::getSkills()&SKILL_GLOVES ? col1 : col3); + draw::draw(222,200, 21, 22, 165, 45); + draw::stencil::set(SKILL_BAG); + draw::swapcol(1, actor::hero::getSkills()&SKILL_BAG ? col1 : col3); + draw::draw(279,200, 20, 25, 145, 41); + + draw::stencil::disable(); + + // Si estem en el editor, fent click en els skills del marcador els obtenim + if (editor::isDevMode() && input::mouseClk(1)) { - if (actor::hero::getSkills() & val) - actor::hero::dropSkill(val); - else - actor::hero::giveSkill(val); - - room::cycleColor(1); + const uint8_t val = draw::stencil::query(input::mouseX(), input::mouseY()); + if (val != 255) + { + if (actor::hero::getSkills() & val) + actor::hero::dropSkill(val); + else + actor::hero::giveSkill(val); + + room::cycleColor(1); + } + } + } else if (actor::hero::isCarryingPrologoObject()) + { + draw::setSource(draw::getSurface("objectes.gif")); + if (actor::hero::getPrologoObjectState(PROLOGO_SHOES)==PROLOGO_OBJECT_PICKED) + { + draw::draw(276,166, 28, 22, 162, 0); + } else if (actor::hero::getPrologoObjectState(PROLOGO_PANTS)==PROLOGO_OBJECT_PICKED) + { + draw::draw(276,166, 18, 23, 167, 22); + } else if (actor::hero::getPrologoObjectState(PROLOGO_GLOVES)==PROLOGO_OBJECT_PICKED) + { + draw::draw(276,166, 21, 22, 165, 45); + } else if (actor::hero::getPrologoObjectState(PROLOGO_BAG)==PROLOGO_OBJECT_PICKED) + { + draw::draw(276,166, 20, 25, 145, 41); } } } diff --git a/source/m_gameover.cpp b/source/m_gameover.cpp index 9d01f78..ad68381 100644 --- a/source/m_gameover.cpp +++ b/source/m_gameover.cpp @@ -19,7 +19,12 @@ namespace modules { if (audio::getCurrentMusic() != "mus_gameover.ogg") audio::playMusic("mus_gameover.ogg", 0); - if (heroi == nullptr) heroi = actor::create("HERO", {16,32,8}, {6,6,12}, "test.gif", {0,32,20,32}, {-6,38}); + if (heroi) actor::remove(heroi); + if (actor::hero::isPrologo()) { + heroi = actor::create("HERO", {16, 32, 0}, {6, 6, 8}, "gat.gif", {0, 0, 24, 28}, {-4, 32}); + } else { + heroi = actor::create("HERO", {16,32,8}, {6,6,12}, "test.gif", {0,32,20,32}, {-6,38}); + } heroi->flags = FLAG_ANIMATED; int milliseconds = SDL_GetTicks()-actor::stats::getStartTime(); @@ -50,8 +55,16 @@ namespace modules draw::print2("GAME OVER", 15, 7, YELLOW, FONT_ZOOM_VERTICAL); - draw::print2(actor::stats::getNumPartsCollected(), 2, 11, 12, TEAL, FONT_ZOOM_NONE); - draw::print2("PARTS TROBADES", 14, 12, GREEN, FONT_ZOOM_NONE); + if (actor::hero::isPrologo()) + { + int num_objectes = 0; + for (int i=0;i<4;++i) if (actor::hero::getPrologoObjectState(i)==PROLOGO_OBJECT_LEFT) num_objectes++; + draw::print2(num_objectes, 2, 11, 12, TEAL, FONT_ZOOM_NONE); + draw::print2("OBJECTES DEJATS", 14, 12, GREEN, FONT_ZOOM_NONE); + } else { + draw::print2(actor::stats::getNumPartsCollected(), 2, 11, 12, TEAL, FONT_ZOOM_NONE); + draw::print2("PARTS TROBADES", 14, 12, GREEN, FONT_ZOOM_NONE); + } draw::print2(actor::stats::getRoomsVisited(), 2, 8, 14, TEAL, FONT_ZOOM_NONE); draw::print2("HABITACIONS VISITADES", 11, 14, GREEN, FONT_ZOOM_NONE); diff --git a/source/m_prologo_intro.cpp b/source/m_prologo_intro.cpp new file mode 100644 index 0000000..dd7d930 --- /dev/null +++ b/source/m_prologo_intro.cpp @@ -0,0 +1,92 @@ +#include "m_prologo_intro.h" +#include "jdraw.h" +#include "jinput.h" +#include "jaudio.h" +#include "controller.h" +#include "config.h" +#include +#include "actor.h" + +namespace modules +{ + namespace prologo_intro + { + int stage = 0; + uint32_t time = 0; + + void init() + { + time = SDL_GetTicks(); + draw::restorecol(2); + draw::cls(2); + + draw::swapcol(1, 9); + draw::setSource(draw::getSurface("prologo1.gif")); + 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(); + + if (audio::getCurrentMusic() != "mus_menu.ogg") audio::playMusic("mus_menu.ogg"); + } + + const bool shouldGoToNext() + { + 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 (controller::pressed(KEY_MENU)) return false; + + if (shouldGoToNext()) + { + time = SDL_GetTicks(); + stage++; + if (stage == 4) return false; + + switch (stage) + { + case 1: + draw::cls(2); + draw::swapcol(1, 9); + draw::setSource(draw::getSurface("prologo2.gif")); + draw::draw(96, 28, 128, 96, 0, 0); + draw::print2("MIRA, ESTE SA DEJAT", 10, 17, WHITE, FONT_ZOOM_NONE); + draw::print2("TOT TIRADO PER AI...", 10, 19, WHITE, FONT_ZOOM_NONE); + //draw::render(); + break; + case 2: + draw::cls(2); + draw::swapcol(1, 9); + draw::setSource(draw::getSurface("prologo2.gif")); + draw::draw(96, 28, 128, 96, 0, 0); + draw::print2("BACH A DEJARO TOT", 12, 17, WHITE, FONT_ZOOM_NONE); + draw::print2("EN SU PUESTO!", 14, 19, WHITE, FONT_ZOOM_NONE); + //draw::render(); + break; + case 3: + draw::cls(2); + draw::swapcol(1, 9); + draw::setSource(draw::getSurface("prologo2.gif")); + draw::draw(96, 28, 128, 96, 0, 0); + draw::print2("BORAS QUE FELIS", 12, 17, WHITE, FONT_ZOOM_NONE); + draw::print2("SE PONE!", 15, 19, WHITE, FONT_ZOOM_NONE); + //draw::render(); + break; + } + } + draw::render(); + return true; + } + } +} \ No newline at end of file diff --git a/source/m_prologo_intro.h b/source/m_prologo_intro.h new file mode 100644 index 0000000..d7fa1e6 --- /dev/null +++ b/source/m_prologo_intro.h @@ -0,0 +1,10 @@ +#pragma once + +namespace modules +{ + namespace prologo_intro + { + void init(); + bool loop(); + } +} diff --git a/source/main.cpp b/source/main.cpp index bc341ec..4b402ff 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -28,7 +28,7 @@ #include "m_editor_bitmap_file.h" #include "m_editor_bitmap.h" #include "m_end_sequence.h" - +#include "m_prologo_intro.h" #define M_LOGO 0 #define M_INTRO 1 @@ -46,6 +46,7 @@ #define M_EDITOR_BITMAP_FILE 13 #define M_EDITOR_BITMAP 14 #define M_END 15 +#define M_PROLOGO_INTRO 16 int current_module = M_LOGO; @@ -150,6 +151,9 @@ bool game::loop() case M_INTRO: if (!modules::intro::loop()) { modules::menu::init(); current_module = M_MENU; } break; + case M_PROLOGO_INTRO: + if (!modules::prologo_intro::loop()) { modules::game::init(true); current_module = M_GAME; } + break; case M_END: if (!modules::end_sequence::loop()) { modules::menu::init(); current_module = M_MENU; } break; @@ -157,7 +161,7 @@ bool game::loop() option = modules::menu::loop(); if (option != OPTION_NONE) { if (option == OPTION_EIXIR) return false; - if (option == OPTION_PROLOGO) { modules::game::init(true); current_module = M_GAME; } + if (option == OPTION_PROLOGO) { modules::prologo_intro::init(); current_module = M_PROLOGO_INTRO; } if (option == OPTION_JUGAR) { modules::game::init(); current_module = M_GAME; } if (option == OPTION_TECLES) { modules::menu_tecles::init(); current_module = M_MENU_TECLES; } if (option == OPTION_GAMEPAD) { modules::menu_gamepad::init(); current_module = M_MENU_GAMEPAD; } diff --git a/source/room.cpp b/source/room.cpp index d61933a..76ccb83 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -283,6 +283,17 @@ namespace room actor::remove(act); act = nullptr; } + } else if (act->name[0]=='X') { // Es un objecte del prólogo sense arreplegar + if (!::editor::isDevMode() && actor::hero::getPrologoObjectState(act->name[2]-48)!=PROLOGO_OBJECT_INITIAL) + { + actor::remove(act); + act = nullptr; + } + } else if (act->name[0]=='Y') { // Es un hueco on deixar un objecte del prólogo + if (!::editor::isDevMode() && actor::hero::getPrologoObjectState(act->name[2]-48)==PROLOGO_OBJECT_LEFT) + { + act->name[0] = 'Z'; + } } } if (act) actor::setDirty(act, true);