- [CHG] Ja no se perden vides al jugar des de l'editor

- [NEW] Funcions per a obtindre el nom dels boosters, skills i parts, segons el seu numero
- [NEW] El minimapa mostra on estàn els boosts, skills i parts
- Més habitacions
This commit is contained in:
2024-09-25 13:48:36 +02:00
parent c49684981c
commit 1b9dfddc94
14 changed files with 496 additions and 41 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -11,6 +11,17 @@ exit-xn: 12
exit-yn: 14 exit-yn: 14
exit-zn: 18 exit-zn: 18
actor{
name: LIFT
bmp: altres.gif
bmp-rect: 160 56 32 24
bmp-offset: 0 24
pos: 24 48 0
size: 8 8 4
orient: ZP
movement: Z
}
actor{ actor{
name: LIFT13 name: LIFT13
bmp: caixes.gif bmp: caixes.gif

View File

@@ -10,3 +10,37 @@ under-door-texture: 0
exit-xn: 21 exit-xn: 21
exit-yn: 19 exit-yn: 19
exit-zp: 13 exit-zp: 13
actor{
name: BOX-A
bmp: caixes.gif
bmp-rect: 0 0 32 32
bmp-offset: 0 32
pos: 8 24 0
size: 8 8 8
flags: PUSHABLE
movement: CW
}
actor{
name: BOX-C
bmp: caixes.gif
bmp-rect: 64 0 32 32
bmp-offset: 0 32
pos: 13 32 0
size: 8 8 8
flags: PUSHABLE
movement: CW
}
actor{
name: LIFT
bmp: altres.gif
bmp-rect: 160 56 32 24
bmp-offset: 0 24
pos: 24 48 0
size: 8 8 4
orient: ZP
flags: MOVING
movement: Z
}

View File

@@ -40,7 +40,7 @@ actor{
pos: 24 24 8 pos: 24 24 8
size: 8 2 8 size: 8 2 8
orient: ZN orient: ZN
flags: MOVING flags: MOVING DEADLY
movement: Z movement: Z
} }
@@ -52,7 +52,7 @@ actor{
pos: 16 24 10 pos: 16 24 10
size: 8 2 8 size: 8 2 8
orient: ZN orient: ZN
flags: MOVING flags: MOVING DEADLY
movement: Z movement: Z
} }
@@ -64,18 +64,6 @@ actor{
pos: 8 24 12 pos: 8 24 12
size: 8 2 8 size: 8 2 8
orient: ZN orient: ZN
flags: MOVING
movement: Z
}
actor{
name: CUADRO-03
bmp: altres.gif
bmp-rect: 101 108 17 24
bmp-offset: -11 29
pos: 0 24 14
size: 8 2 8
orient: ZN
flags: MOVING DEADLY flags: MOVING DEADLY
movement: Z movement: Z
} }
@@ -88,7 +76,7 @@ actor{
pos: 32 24 6 pos: 32 24 6
size: 8 2 8 size: 8 2 8
orient: ZN orient: ZN
flags: MOVING flags: MOVING DEADLY
movement: Z movement: Z
} }
@@ -100,7 +88,7 @@ actor{
pos: 40 24 4 pos: 40 24 4
size: 8 2 8 size: 8 2 8
orient: ZN orient: ZN
flags: MOVING flags: MOVING DEADLY
movement: Z movement: Z
} }
@@ -112,7 +100,7 @@ actor{
pos: 48 24 2 pos: 48 24 2
size: 8 2 8 size: 8 2 8
orient: ZN orient: ZN
flags: MOVING flags: MOVING DEADLY
movement: Z movement: Z
} }
@@ -124,7 +112,7 @@ actor{
pos: 56 24 0 pos: 56 24 0
size: 8 2 8 size: 8 2 8
orient: ZN orient: ZN
flags: MOVING flags: MOVING DEADLY
movement: Z movement: Z
} }
@@ -208,6 +196,18 @@ actor{
movement: CW movement: CW
} }
actor{
name: REIXA-Y
bmp: altres.gif
bmp-rect: 101 108 17 24
bmp-offset: -11 29
pos: 0 24 14
size: 8 2 8
orient: ZN
flags: MOVING DEADLY
movement: Z
}
actor{ actor{
name: TRANSPA-00 name: TRANSPA-00
bmp: altres.gif bmp: altres.gif

View File

@@ -1,9 +1,272 @@
width: 2 width: 1
height: 2 height: 3
door-height-yp: 0 door-height-yp: 0
color: CYAN color: CYAN
floor-texture: 0 floor-texture: 3
wall-texture: 0 wall-texture: 6
door-texture: 0 door-texture: 6
under-door-texture: 0 under-door-texture: 0
exit-yp: 19 exit-yp: 19
actor{
name: CONV-XP-01
bmp: caixes.gif
bmp-rect: 0 128 32 32
bmp-offset: 0 32
pos: 16 24 0
size: 8 8 4
orient: XP
anim-cycle: MIN
flags: REACTIVE ANIMATED ORIENTABLE
react-mask: ZN
react-push: XP
}
actor{
name: GAT-ROBIN
bmp: gat2.gif
bmp-rect: 0 0 24 28
bmp-offset: -4 32
pos: 16 0 0
size: 8 8 8
orient: XP
anim-wait: 1
flags: PUSHABLE REACTIVE MOVING ANIMATED ORIENTABLE DEADLY
react-mask: XP XN YP YN ZP ZN
movement: X
}
actor{
name: INVISI-00
bmp: caixes.gif
bmp-rect: 128 0 16 13
bmp-offset: 0 32
pos: 24 16 30
size: 8 8 8
movement: CW
}
actor{
name: INVISI-01
bmp: caixes.gif
bmp-rect: 128 0 16 13
bmp-offset: 0 32
pos: 24 32 30
size: 8 8 8
movement: CW
}
actor{
name: INVISI-02
bmp: caixes.gif
bmp-rect: 128 0 16 13
bmp-offset: 0 32
pos: 32 16 30
size: 8 8 8
movement: CW
}
actor{
name: INVISI-03
bmp: caixes.gif
bmp-rect: 128 0 16 13
bmp-offset: 0 32
pos: 32 32 30
size: 8 8 8
movement: CW
}
actor{
name: OBRER-00
bmp: obrer.gif
bmp-rect: 0 0 24 32
bmp-offset: -4 37
pos: 24 24 0
size: 8 8 8
orient: YP
anim-wait: 1
flags: REACTIVE MOVING ANIMATED ORIENTABLE DEADLY
react-mask: XP XN YP YN ZP ZN
movement: Y
}
actor{
name: OBRER-01
bmp: obrer.gif
bmp-rect: 0 0 24 32
bmp-offset: -4 37
pos: 32 48 0
size: 8 8 8
orient: YN
anim-wait: 1
flags: REACTIVE MOVING ANIMATED ORIENTABLE DEADLY
react-mask: XP XN YP YN ZP ZN
movement: Y
}
actor{
name: P-TIMER
bmp: objectes.gif
bmp-rect: 96 0 24 32
bmp-offset: -4 34
pos: 16 0 8
size: 4 4 4
anim-cycle: SEQ
anim-wait: 2
flags: PUSHABLE GRAVITY SPECIAL
movement: CW
}
actor{
name: PLATF
bmp: caixes.gif
bmp-rect: 96 160 32 32
bmp-offset: 0 32
pos: 40 8 0
size: 8 8 8
orient: ZP
movement: Z
}
actor{
name: PLATF-00
bmp: caixes.gif
bmp-rect: 96 160 32 32
bmp-offset: 0 32
pos: 16 16 0
size: 8 8 8
orient: ZP
movement: Z
}
actor{
name: PLATF-01
bmp: caixes.gif
bmp-rect: 96 160 32 32
bmp-offset: 0 32
pos: 16 32 0
size: 8 8 8
orient: ZP
movement: Z
}
actor{
name: PLATF-02
bmp: caixes.gif
bmp-rect: 96 160 32 32
bmp-offset: 0 32
pos: 40 16 0
size: 8 8 8
orient: ZP
movement: Z
}
actor{
name: PLATF-03
bmp: caixes.gif
bmp-rect: 96 160 32 32
bmp-offset: 0 32
pos: 40 32 0
size: 8 8 8
orient: ZP
movement: Z
}
actor{
name: PLATH-00
bmp: caixes.gif
bmp-rect: 160 128 32 32
bmp-offset: 0 32
pos: 16 8 0
size: 8 8 4
orient: ZP
movement: Z
}
actor{
name: REIXA-Y-00
bmp: altres.gif
bmp-rect: 83 108 18 25
bmp-offset: -11 29
pos: 24 16 14
size: 8 2 8
orient: ZN
flags: MOVING DEADLY
movement: Z
}
actor{
name: REIXA-Y-01
bmp: altres.gif
bmp-rect: 83 108 18 25
bmp-offset: -11 29
pos: 24 32 5
size: 8 2 8
orient: ZN
flags: MOVING DEADLY
movement: Z
}
actor{
name: REIXA-Y-02
bmp: altres.gif
bmp-rect: 83 108 18 25
bmp-offset: -11 29
pos: 32 16 14
size: 8 2 8
orient: ZN
flags: MOVING DEADLY
movement: Z
}
actor{
name: REIXA-Y-03
bmp: altres.gif
bmp-rect: 83 108 18 25
bmp-offset: -11 29
pos: 32 32 5
size: 8 2 8
orient: ZN
flags: MOVING DEADLY
movement: Z
}
actor{
name: TRANSPA-00
bmp: altres.gif
bmp-rect: 0 160 32 32
bmp-offset: 0 32
pos: 40 32 8
size: 8 8 6
movement: CW
}
actor{
name: TRANSPA-01
bmp: altres.gif
bmp-rect: 0 160 32 32
bmp-offset: 0 32
pos: 40 16 8
size: 8 8 6
movement: CW
}
actor{
name: TRANSPA-02
bmp: altres.gif
bmp-rect: 0 160 32 32
bmp-offset: 0 32
pos: 16 16 8
size: 8 8 6
movement: CW
}
actor{
name: TRANSPA-03
bmp: altres.gif
bmp-rect: 0 160 32 32
bmp-offset: 0 32
pos: 16 32 8
size: 8 8 6
movement: CW
}

View File

@@ -3,7 +3,7 @@ height: 2
door-height-xp: 1 door-height-xp: 1
door-height-xn: 1 door-height-xn: 1
door-height-yp: 1 door-height-yp: 1
color: CYAN color: WHITE
floor-texture: 0 floor-texture: 0
wall-texture: 0 wall-texture: 0
door-texture: 0 door-texture: 0

View File

@@ -2,10 +2,10 @@ width: 2
height: 2 height: 2
door-height-xp: 0 door-height-xp: 0
door-height-yp: 0 door-height-yp: 0
color: CYAN color: GREEN
floor-texture: 0 floor-texture: 1
wall-texture: 0 wall-texture: 13
door-texture: 0 door-texture: 7
under-door-texture: 0 under-door-texture: 13
exit-xp: 21 exit-xp: 21
exit-yp: 23 exit-yp: 23

View File

@@ -1,7 +1,7 @@
width: 2 width: 2
height: 2 height: 2
door-height-yn: 0 door-height-yn: 0
color: CYAN color: WHITE
floor-texture: 0 floor-texture: 0
wall-texture: 0 wall-texture: 0
door-texture: 0 door-texture: 0

View File

@@ -3,7 +3,7 @@ height: 2
door-height-xp: 0 door-height-xp: 0
door-height-yp: 0 door-height-yp: 0
door-height-yn: 4 door-height-yn: 4
color: CYAN color: YELLOW
floor-texture: 0 floor-texture: 0
wall-texture: 0 wall-texture: 0
door-texture: 0 door-texture: 0

View File

@@ -1,10 +1,54 @@
width: 2 width: 2
height: 2 height: 2
door-height-xn: 4 door-height-xn: 4
color: CYAN color: PURPLE
floor-texture: 0 floor-texture: 0
wall-texture: 0 wall-texture: 0
door-texture: 0 door-texture: 0
under-door-texture: 0 under-door-texture: 0
exit-xn: 24 exit-xn: 24
exit-zp: 21 exit-zp: 21
actor{
name: BOX-B-00
bmp: caixes.gif
bmp-rect: 32 0 32 32
bmp-offset: 0 32
pos: 16 48 0
size: 8 8 8
flags: PUSHABLE
movement: CW
}
actor{
name: BOX-B-01
bmp: caixes.gif
bmp-rect: 32 0 32 32
bmp-offset: 0 32
pos: 32 8 0
size: 8 8 8
flags: PUSHABLE
movement: CW
}
actor{
name: PILOTA
bmp: altres.gif
bmp-rect: 0 108 21 21
bmp-offset: -6 26
pos: 32 24 0
size: 8 8 8
flags: PUSHABLE INERTIA
movement: CW
}
actor{
name: PLATF
bmp: caixes.gif
bmp-rect: 96 160 32 32
bmp-offset: 0 32
pos: 40 24 0
size: 8 8 8
orient: ZP
movement: Z
}

View File

@@ -466,6 +466,18 @@ category{
movement: Y movement: Y
} }
actor{
name: REIXA-Y
bmp: altres.gif
bmp-rect: 101 108 17 24
bmp-offset: -11 29
pos: 0 24 14
size: 8 2 8
orient: ZN
flags: MOVING DEADLY
movement: Z
}
} }
category{ category{

View File

@@ -797,9 +797,12 @@ namespace actor
vec3_t max = room::getMax(); vec3_t max = room::getMax();
if ( (act->push & PUSH_KILL) && (act->flags & FLAG_HERO) ) { if ( (act->push & PUSH_KILL) && (act->flags & FLAG_HERO) ) {
const int lives = hero::getLives()-1; if (!editor::isDevMode())
hero::setLives(lives); {
stats::loseLive(); const int lives = hero::getLives()-1;
hero::setLives(lives);
stats::loseLive();
}
// [TODO] If lives == 0 anar a la pantalla de game-over o cat's life // [TODO] If lives == 0 anar a la pantalla de game-over o cat's life
actor_t *act = actor::find("HERO"); actor_t *act = actor::find("HERO");
act = actor::replaceWithTemplate(act, "EXPLOSION"); act = actor::replaceWithTemplate(act, "EXPLOSION");
@@ -1585,6 +1588,17 @@ namespace actor
} }
return 0; return 0;
} }
const char *getBoosterName(int booster)
{
switch (booster)
{
case 1: return "RUN";
case 2: return "GOD";
case 4: return "JUMP";
case 8: return "LIVE";
default: return "";
}
}
bool giveBooster(char *booster) bool giveBooster(char *booster)
{ {
@@ -1660,6 +1674,18 @@ namespace actor
return 0; return 0;
} }
const char *getSkillName(int skill)
{
switch (skill)
{
case 1: return "SHOES";
case 2: return "GLOVES";
case 4: return "PANTS";
case 8: return "BAG";
default: return "";
}
}
bool giveSkill(int skill) bool giveSkill(int skill)
{ {
skills |= skill; skills |= skill;
@@ -1705,6 +1731,20 @@ namespace actor
return PART_NONE; return PART_NONE;
} }
const char *getPartName(int part)
{
switch (part)
{
case 1: return "FILTER";
case 2: return "PUMP";
case 4: return "TIMER";
case 8: return "SALT";
case 16: return "PIPE";
case 32: return "ELBOW";
default: return "";
}
}
bool pickPart(char *part) bool pickPart(char *part)
{ {
const int value = getPartFromString(part); const int value = getPartFromString(part);

View File

@@ -202,6 +202,8 @@ namespace actor
void die(); void die();
bool isDead(); bool isDead();
const int getBoosterFromString(char *booster);
const char *getBoosterName(int booster);
bool giveBooster(char *booster); bool giveBooster(char *booster);
void collectBooster(int booster, int id); void collectBooster(int booster, int id);
bool wasBoosterCollected(int id); bool wasBoosterCollected(int id);
@@ -212,6 +214,8 @@ namespace actor
void useBoostRun(); void useBoostRun();
void useBoostJump(); void useBoostJump();
const int getSkillFromString(char *skill);
const char *getSkillName(int skill);
bool giveSkill(int skill); bool giveSkill(int skill);
bool giveSkill(char *skill); bool giveSkill(char *skill);
bool dropSkill(int skill); bool dropSkill(int skill);
@@ -219,6 +223,8 @@ namespace actor
bool wasSkillCollected(char *skill); bool wasSkillCollected(char *skill);
int getSkills(); int getSkills();
const int getPartFromString(char *part);
const char *getPartName(int part);
bool pickPart(char *part); bool pickPart(char *part);
bool dropPart(char *part); bool dropPart(char *part);
bool wasPartCollected(char *part); bool wasPartCollected(char *part);

View File

@@ -4,6 +4,7 @@
#include "misc.h" #include "misc.h"
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "room.h" #include "room.h"
#include "actor.h"
namespace modules namespace modules
{ {
@@ -20,6 +21,7 @@ namespace modules
uint8_t h; uint8_t h;
uint8_t color; uint8_t color;
uint8_t exits[6]; uint8_t exits[6];
uint32_t specials;
}; };
miniroom_t minirooms[64]; miniroom_t minirooms[64];
@@ -34,8 +36,8 @@ namespace modules
if (minirooms[room].exits[YN] != 255) { draw::isoline(x,y,+1,-1,14); /*draw::isoline(x,y-1,+1,-1,14);*/ draw::isoline(x,y+1,+1,-1,14); } if (minirooms[room].exits[YN] != 255) { draw::isoline(x,y,+1,-1,14); /*draw::isoline(x,y-1,+1,-1,14);*/ draw::isoline(x,y+1,+1,-1,14); }
if (minirooms[room].exits[XP] != 255) { draw::isoline(x,y,+1,+1,14); /*draw::isoline(x,y-1,+1,+1,14);*/ draw::isoline(x,y+1,+1,+1,14); } if (minirooms[room].exits[XP] != 255) { draw::isoline(x,y,+1,+1,14); /*draw::isoline(x,y-1,+1,+1,14);*/ draw::isoline(x,y+1,+1,+1,14); }
if (minirooms[room].exits[YP] != 255) { draw::isoline(x,y,-1,+1,14); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::isoline(x,y+1,-1,+1,14); } if (minirooms[room].exits[YP] != 255) { draw::isoline(x,y,-1,+1,14); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::isoline(x,y+1,-1,+1,14); }
if (minirooms[room].exits[ZN] != 255) { draw::vline(x,y,24); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::vline(x+1,y,24); } if (minirooms[room].exits[ZN] != 255) { draw::vline(x-1,y,24); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::vline(x,y,24); }
if (minirooms[room].exits[ZP] != 255) { draw::vline(x,y-24,24); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::vline(x+1,y-24,24); } if (minirooms[room].exits[ZP] != 255) { draw::vline(x-1,y-24,24); /*draw::isoline(x,y-1,-1,+1,14);*/ draw::vline(x,y-24,24); }
} }
if (minirooms[room].exits[XN] != 255) drawLines(minirooms[room].exits[XN], x-24, y-12); if (minirooms[room].exits[XN] != 255) drawLines(minirooms[room].exits[XN], x-24, y-12);
if (minirooms[room].exits[XP] != 255) drawLines(minirooms[room].exits[XP], x+24, y+12); if (minirooms[room].exits[XP] != 255) drawLines(minirooms[room].exits[XP], x+24, y+12);
@@ -59,6 +61,10 @@ namespace modules
{ {
char num[] = "00"; num[0] = 48+(room/10); num[1] = 48+(room%10); char num[] = "00"; num[0] = 48+(room/10); num[1] = 48+(room%10);
draw::print(num, x-4, y-3, LIGHT+(room==current_room?YELLOW:WHITE), BLACK); draw::print(num, x-4, y-3, LIGHT+(room==current_room?YELLOW:WHITE), BLACK);
if (minirooms[room].specials&0x000000ff) { draw::color(BLACK); draw::rect(x+3, y-4, 3, 3); draw::color(BLUE); draw::fillrect(x+4, y-3, 1, 1); }
if (minirooms[room].specials&0x0000ff00) { draw::color(BLACK); draw::rect(x+3, y-2, 3, 3); draw::color(GREEN); draw::fillrect(x+4, y-1, 1, 1); }
if (minirooms[room].specials&0x00ff0000) { draw::color(BLACK); draw::rect(x+3, y, 3, 3); draw::color(YELLOW); draw::fillrect(x+4, y+1, 1, 1); }
if (minirooms[room].specials&0xff000000) { draw::color(RED); draw::fillrect(x+4, y-3, 1, 5); }
} }
} }
if (minirooms[room].exits[XN] != 255) drawRoom(minirooms[room].exits[XN], x-24, y-12, shadow); if (minirooms[room].exits[XN] != 255) drawRoom(minirooms[room].exits[XN], x-24, y-12, shadow);
@@ -78,6 +84,27 @@ namespace modules
minirooms[room].color = room::getColor(0); minirooms[room].color = room::getColor(0);
minirooms[room].w = (room::getSize().x >> 1)-1; minirooms[room].w = (room::getSize().x >> 1)-1;
minirooms[room].h = (room::getSize().y >> 1)-1; minirooms[room].h = (room::getSize().y >> 1)-1;
minirooms[room].specials = 0;
// Recolectem els especials de l'habitació per a mostrar-los
actor::actor_t *act = actor::getFirst();
while (act)
{
if (act->flags & FLAG_SPECIAL)
{
if (act->name[0]=='B') { // Es un booster
minirooms[room].specials |= actor::hero::getBoosterFromString(&act->name[2]);
} else if (act->name[0]=='S') { // Es un skill
minirooms[room].specials |= (actor::hero::getSkillFromString(&act->name[2])<<8);
} else if (act->name[0]=='P') { // Es una part
minirooms[room].specials |= (actor::hero::getPartFromString(&act->name[2])<<16);
} else {
minirooms[room].specials |= (1<<24); // Es algo invalid
}
}
act = act->next;
}
for (int i=0; i<=ZN; ++i) minirooms[room].exits[i] = room::getExit(i); for (int i=0; i<=ZN; ++i) minirooms[room].exits[i] = room::getExit(i);
for (int i=0; i<=ZN; ++i) { for (int i=0; i<=ZN; ++i) {
@@ -113,6 +140,13 @@ namespace modules
drawRoom(room::getCurrent(), scroll.x+x, scroll.y+y, true); drawRoom(room::getCurrent(), scroll.x+x, scroll.y+y, true);
} }
draw::stencil::enable();
draw::stencil::clear(255);
for (int i=0;i<64;++i) drawn[i]=false;
drawRoom(room::getCurrent(), scroll.x, scroll.y);
draw::render();
} }
@@ -120,11 +154,22 @@ namespace modules
{ {
if (input::keyPressed(SDL_SCANCODE_ESCAPE) || input::keyPressed(SDL_SCANCODE_TAB)) return false; if (input::keyPressed(SDL_SCANCODE_ESCAPE) || input::keyPressed(SDL_SCANCODE_TAB)) return false;
draw::stencil::enable(); //draw::stencil::enable();
draw::stencil::clear(255); //draw::stencil::clear(255);
//for (int i=0;i<64;++i) drawn[i]=false;
//drawRoom(room::getCurrent(), scroll.x, scroll.y);
const int hover = draw::stencil::query(input::mouseX(), input::mouseY());
if (hover!=255) {
draw::color(BLACK); draw::fillrect(0,0,60,60);
int line = 4;
draw::print2(hover, -2, 1, 1, WHITE, FONT_ZOOM_VERTICAL);
if (minirooms[hover].specials & 0x000000ff) draw::print2(actor::hero::getBoosterName(minirooms[hover].specials & 0xff), 1, line++, BLUE, FONT_ZOOM_NONE);
if (minirooms[hover].specials & 0x0000ff00) draw::print2(actor::hero::getSkillName((minirooms[hover].specials>>8) & 0xff), 1, line++, GREEN, FONT_ZOOM_NONE);
if (minirooms[hover].specials & 0x00ff0000) draw::print2(actor::hero::getPartName((minirooms[hover].specials>>16) & 0xff), 1, line++, YELLOW, FONT_ZOOM_NONE);
}
for (int i=0;i<64;++i) drawn[i]=false;
drawRoom(room::getCurrent(), scroll.x, scroll.y);
draw::render(); draw::render();
if (input::mouseClk(1)) { if (input::mouseClk(1)) {