- Prologo quasi acabat

This commit is contained in:
2024-10-08 13:59:04 +02:00
parent 119136332b
commit 9827865e9c
16 changed files with 332 additions and 113 deletions

View File

@@ -22,6 +22,8 @@ mapa.gif
objectes.gif
obrer.gif
piscina.gif
prologo1.gif
prologo2.gif
roomaux.gif
sam.gif
test.gif

BIN
data/prologo1.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
data/prologo2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -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

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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);
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");

View File

@@ -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();
}

View File

@@ -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,6 +398,8 @@ namespace modules
draw::print2("no", 4, 25, col3, FONT_ZOOM_NONE);
draw::print2(actor::hero::getLives(), 2, 4, 26, col1, FONT_ZOOM_VERTICAL);
if (!actor::hero::isPrologo())
{
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);
@@ -439,6 +441,23 @@ namespace modules
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);
}
}
}

View File

@@ -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);
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);

View File

@@ -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 <SDL2/SDL.h>
#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;
}
}
}

10
source/m_prologo_intro.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
namespace modules
{
namespace prologo_intro
{
void init();
bool loop();
}
}

View File

@@ -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; }

View File

@@ -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);