- [NEW] Nou flag per als actors: FLAG_INERTIA

- [NEW] Nou moviment per als actors: RANDV
- [NEW] HUNT implementat
- [NEW] Mentres es prova en l'editor ara es poden donar i llevar skills fent click damutn del seu dibuixet.
- [NEW] en l'editor, els skills i powerups nomes es veuen al estar provant
This commit is contained in:
2024-07-11 09:55:22 +02:00
parent c4cbda9b23
commit c9f41c9635
4 changed files with 168 additions and 97 deletions

View File

@@ -7,7 +7,7 @@ door-texture: 0
under-door-texture: 0 under-door-texture: 0
actor{ actor{
name: BOX name: TAULETA
bmp: caixes.gif bmp: caixes.gif
bmp-rect: 0 64 32 32 bmp-rect: 0 64 32 32
bmp-offset: 0 32 bmp-offset: 0 32
@@ -26,6 +26,26 @@ actor{
movement: CW movement: CW
} }
actor{
name: KALLAX-A
bmp: altres.gif
bmp-rect: 0 48 24 27
bmp-offset: 0 31
pos: 0 8 0
size: 4 8 8
movement: CW
}
actor{
name: KALLAX-A03
bmp: altres.gif
bmp-rect: 72 48 24 27
bmp-offset: 0 31
pos: 0 16 0
size: 4 8 8
movement: CW
}
actor{ actor{
name: KALLAX-A04 name: KALLAX-A04
bmp: altres.gif bmp: altres.gif
@@ -60,6 +80,16 @@ actor{
movement: CW movement: CW
} }
actor{
name: BOX01
bmp: caixes.gif
bmp-rect: 128 32 32 32
bmp-offset: 0 32
pos: 16 24 0
size: 8 8 8
movement: CW
}
actor{ actor{
name: KALLAX-A07 name: KALLAX-A07
bmp: altres.gif bmp: altres.gif
@@ -73,14 +103,13 @@ actor{
} }
actor{ actor{
name: KALLAX-A06 name: BOX02
bmp: altres.gif bmp: caixes.gif
bmp-rect: 72 48 24 27 bmp-rect: 160 32 32 32
bmp-offset: -8 31 bmp-offset: 0 32
pos: 24 0 8 pos: 24 24 0
size: 8 4 8 size: 8 8 8
orient: YP react-push: XP
flags: ORIENTABLE
movement: CW movement: CW
} }
@@ -97,24 +126,13 @@ actor{
} }
actor{ actor{
name: KALLAX-A09 name: BOX
bmp: altres.gif bmp: test.gif
bmp-rect: 0 48 24 27 bmp-rect: 32 0 32 32
bmp-offset: -8 31 bmp-offset: 0 32
pos: 32 0 8 pos: 32 32 0
size: 8 4 8 size: 8 8 8
orient: YP flags: PUSHABLE INERTIA
flags: ORIENTABLE
movement: CW
}
actor{
name: KALLAX-A
bmp: altres.gif
bmp-rect: 0 48 24 27
bmp-offset: 0 31
pos: 0 8 0
size: 4 8 8
movement: CW movement: CW
} }
@@ -128,16 +146,6 @@ actor{
movement: CW movement: CW
} }
actor{
name: KALLAX-A03
bmp: altres.gif
bmp-rect: 72 48 24 27
bmp-offset: 0 31
pos: 0 16 0
size: 4 8 8
movement: CW
}
actor{ actor{
name: KALLAX-A02 name: KALLAX-A02
bmp: altres.gif bmp: altres.gif
@@ -148,16 +156,6 @@ actor{
movement: CW movement: CW
} }
actor{
name: BOX01
bmp: caixes.gif
bmp-rect: 128 32 32 32
bmp-offset: 0 32
pos: 16 24 0
size: 8 8 8
movement: CW
}
actor{ actor{
name: BOX03 name: BOX03
bmp: caixes.gif bmp: caixes.gif
@@ -170,13 +168,14 @@ actor{
} }
actor{ actor{
name: BOX02 name: KALLAX-A06
bmp: caixes.gif bmp: altres.gif
bmp-rect: 160 32 32 32 bmp-rect: 72 48 24 27
bmp-offset: 0 32 bmp-offset: -8 31
pos: 24 24 0 pos: 24 0 8
size: 8 8 8 size: 8 4 8
react-push: XP orient: YP
flags: ORIENTABLE
movement: CW movement: CW
} }
@@ -192,3 +191,15 @@ actor{
react-push: XP react-push: XP
movement: CW movement: CW
} }
actor{
name: KALLAX-A09
bmp: altres.gif
bmp-rect: 0 48 24 27
bmp-offset: -8 31
pos: 32 0 8
size: 8 4 8
orient: YP
flags: ORIENTABLE
movement: CW
}

View File

@@ -140,7 +140,7 @@ namespace actor
} else if (util::strcomp(key, "orient:")) { } else if (util::strcomp(key, "orient:")) {
t->orient = util::stringToInt(file::readString(buffer), {"none", "xp", "xn", "yp", "yn", "zp", "zn"}, {0, 1, 2, 4, 8, 16, 32}); t->orient = util::stringToInt(file::readString(buffer), {"none", "xp", "xn", "yp", "yn", "zp", "zn"}, {0, 1, 2, 4, 8, 16, 32});
} else if (util::strcomp(key, "movement:")) { } else if (util::strcomp(key, "movement:")) {
t->movement = util::stringToInt(file::readString(buffer), {"none", "x", "y", "z", "cw", "ccw", "rand", "hunt"},{MOV_NONE, MOV_X, MOV_Y, MOV_Z, MOV_CW, MOV_CCW, MOV_RAND, MOV_HUNT}); t->movement = util::stringToInt(file::readString(buffer), {"none", "x", "y", "z", "cw", "ccw", "rand", "randv", "hunt"},{MOV_NONE, MOV_X, MOV_Y, MOV_Z, MOV_CW, MOV_CCW, MOV_RAND, MOV_RANDV, MOV_HUNT});
} else if (util::strcomp(key, "anim-cycle:")) { } else if (util::strcomp(key, "anim-cycle:")) {
t->anim_cycle = util::stringToInt(file::readString(buffer), {"walk", "seq", "min"},{0, 1, 2}); t->anim_cycle = util::stringToInt(file::readString(buffer), {"walk", "seq", "min"},{0, 1, 2});
} else if (util::strcomp(key, "anim-wait:")) { } else if (util::strcomp(key, "anim-wait:")) {
@@ -150,7 +150,7 @@ namespace actor
int value = 0; int value = 0;
while (str) while (str)
{ {
value |= util::stringToInt(str, { "none", "hero", "pushable", "reactive", "moving", "animated", "orientable", "deadly", "gravity", "pickable", "special", "noeditor" },{ FLAG_NONE, FLAG_HERO, FLAG_PUSHABLE, FLAG_REACTIVE, FLAG_MOVING, FLAG_ANIMATED, FLAG_ORIENTABLE, FLAG_DEADLY, FLAG_GRAVITY, FLAG_PICKABLE, FLAG_SPECIAL, FLAG_NOEDITOR }); value |= util::stringToInt(str, { "none", "hero", "pushable", "reactive", "moving", "animated", "orientable", "deadly", "gravity", "pickable", "special", "noeditor", "inertia" },{ FLAG_NONE, FLAG_HERO, FLAG_PUSHABLE, FLAG_REACTIVE, FLAG_MOVING, FLAG_ANIMATED, FLAG_ORIENTABLE, FLAG_DEADLY, FLAG_GRAVITY, FLAG_PICKABLE, FLAG_SPECIAL, FLAG_NOEDITOR, FLAG_INERTIA });
str = file::readString(buffer, true); str = file::readString(buffer, true);
} }
t->flags = value; t->flags = value;
@@ -234,15 +234,16 @@ namespace actor
{ {
tmp[0]=0; tmp[0]=0;
if (value==0) return "NONE"; if (value==0) return "NONE";
if (value&256) strcat(tmp, "PICKABLE "); if (value & FLAG_PICKABLE) strcat(tmp, "PICKABLE ");
if (value&2) strcat(tmp, "PUSHABLE "); if (value & FLAG_PUSHABLE) strcat(tmp, "PUSHABLE ");
if (value&4) strcat(tmp, "REACTIVE "); if (value & FLAG_REACTIVE) strcat(tmp, "REACTIVE ");
if (value&8) strcat(tmp, "MOVING "); if (value & FLAG_MOVING) strcat(tmp, "MOVING ");
if (value&16) strcat(tmp, "ANIMATED "); if (value & FLAG_ANIMATED) strcat(tmp, "ANIMATED ");
if (value&32) strcat(tmp, "ORIENTABLE "); if (value & FLAG_ORIENTABLE) strcat(tmp, "ORIENTABLE ");
if (value&64) strcat(tmp, "DEADLY "); if (value & FLAG_DEADLY) strcat(tmp, "DEADLY ");
if (value&128) strcat(tmp, "GRAVITY "); if (value & FLAG_GRAVITY) strcat(tmp, "GRAVITY ");
if (value&512) strcat(tmp, "SPECIAL "); if (value & FLAG_SPECIAL) strcat(tmp, "SPECIAL ");
if (value & FLAG_INERTIA) strcat(tmp, "INERTIA ");
return tmp; return tmp;
} }
@@ -255,7 +256,8 @@ namespace actor
if (value==4) return "CW"; if (value==4) return "CW";
if (value==5) return "CCW"; if (value==5) return "CCW";
if (value==6) return "RAND"; if (value==6) return "RAND";
if (value==7) return "HUNT"; if (value==7) return "RANDV";
if (value==8) return "HUNT";
return "NONE"; return "NONE";
} }
@@ -663,8 +665,25 @@ namespace actor
case 3: act->mov_push=PUSH_XP; break; case 3: act->mov_push=PUSH_XP; break;
} }
break; break;
case MOV_RANDV:
switch (rand()%8)
{
case 0: act->mov_push=PUSH_YP; break;
case 1: act->mov_push=PUSH_XN; break;
case 2: act->mov_push=PUSH_YN; break;
case 3: act->mov_push=PUSH_XP; break;
case 4: act->mov_push=PUSH_YP; act->mov_push=PUSH_XN; break;
case 5: act->mov_push=PUSH_XN; act->mov_push=PUSH_YN; break;
case 6: act->mov_push=PUSH_YN; act->mov_push=PUSH_XP; break;
case 7: act->mov_push=PUSH_XP; act->mov_push=PUSH_YP; break;
}
break;
case MOV_HUNT: case MOV_HUNT:
// TODO actor_t *heroi = find("HERO");
if (heroi->pos.x < act->pos.x) act->mov_push=PUSH_XN;
if (heroi->pos.x > act->pos.x) act->mov_push=PUSH_XP;
if (heroi->pos.y < act->pos.y) act->mov_push=PUSH_YN;
if (heroi->pos.y > act->pos.y) act->mov_push=PUSH_YP;
break; break;
} }
if (act->flags & FLAG_ORIENTABLE) act->orient = act->mov_push; if (act->flags & FLAG_ORIENTABLE) act->orient = act->mov_push;
@@ -732,6 +751,7 @@ namespace actor
if (other) act->push |= push(act, other, PUSH_XN); if (other) act->push |= push(act, other, PUSH_XN);
act->pos.x+=vel; act->pos.x+=vel;
if (act->flags & FLAG_MOVING) changeMoving(act); if (act->flags & FLAG_MOVING) changeMoving(act);
if (act->flags & FLAG_INERTIA) act->push = PUSH_NONE;
} }
else else
{ {
@@ -750,7 +770,7 @@ namespace actor
actor::setDirty(act); actor::setDirty(act);
} }
act->push &= ~PUSH_XN; if ( !(act->flags & FLAG_INERTIA) ) act->push &= ~PUSH_XN;
} }
if (act->push & PUSH_XP) { if (act->push & PUSH_XP) {
@@ -761,6 +781,7 @@ namespace actor
if (other) act->push |= push(act, other, PUSH_XP); if (other) act->push |= push(act, other, PUSH_XP);
act->pos.x-=vel; act->pos.x-=vel;
if (act->flags & FLAG_MOVING) changeMoving(act); if (act->flags & FLAG_MOVING) changeMoving(act);
if (act->flags & FLAG_INERTIA) act->push = PUSH_NONE;
} }
else else
{ {
@@ -777,7 +798,7 @@ namespace actor
actor::setDirty(act); actor::setDirty(act);
} }
act->push &= ~PUSH_XP; if ( !(act->flags & FLAG_INERTIA) ) act->push &= ~PUSH_XP;
} }
if (act->push & PUSH_YN) { if (act->push & PUSH_YN) {
@@ -788,6 +809,7 @@ namespace actor
if (other) act->push |= push(act, other, PUSH_YN); if (other) act->push |= push(act, other, PUSH_YN);
act->pos.y+=vel; act->pos.y+=vel;
if (act->flags & FLAG_MOVING) changeMoving(act); if (act->flags & FLAG_MOVING) changeMoving(act);
if (act->flags & FLAG_INERTIA) act->push = PUSH_NONE;
} }
else else
{ {
@@ -804,7 +826,7 @@ namespace actor
actor::setDirty(act); actor::setDirty(act);
} }
act->push &= ~PUSH_YN; if ( !(act->flags & FLAG_INERTIA) ) act->push &= ~PUSH_YN;
} }
if (act->push & PUSH_YP) { if (act->push & PUSH_YP) {
@@ -815,6 +837,7 @@ namespace actor
if (other) act->push |= push(act, other, PUSH_YP); if (other) act->push |= push(act, other, PUSH_YP);
act->pos.y-=vel; act->pos.y-=vel;
if (act->flags & FLAG_MOVING) changeMoving(act); if (act->flags & FLAG_MOVING) changeMoving(act);
if (act->flags & FLAG_INERTIA) act->push = PUSH_NONE;
} }
else else
{ {
@@ -831,7 +854,7 @@ namespace actor
actor::setDirty(act); actor::setDirty(act);
} }
act->push &= ~PUSH_YP; if ( !(act->flags & FLAG_INERTIA) ) act->push &= ~PUSH_YP;
} }
if (act->push & PUSH_ZN) { if (act->push & PUSH_ZN) {
@@ -1369,18 +1392,26 @@ namespace actor
return 0; return 0;
} }
bool giveSkill(int skill)
{
skills |= skill;
return skill!=0;
}
bool giveSkill(char *skill) bool giveSkill(char *skill)
{ {
const int value = getSkillFromString(skill); return giveSkill(getSkillFromString(skill));
skills |= value; }
return value!=0;
bool dropSkill(int skill)
{
skills &= ~skill;
return skill!=0;
} }
bool dropSkill(char *skill) bool dropSkill(char *skill)
{ {
const int value = getSkillFromString(skill); return dropSkill(getSkillFromString(skill));
skills &= ~value;
return value!=0;
} }
bool wasSkillCollected(char *skill) bool wasSkillCollected(char *skill)

View File

@@ -18,6 +18,7 @@
#define FLAG_PICKABLE 256 // Es pot agafar #define FLAG_PICKABLE 256 // Es pot agafar
#define FLAG_SPECIAL 512 // Especial (habilitats, poders temporals i parts de l'excavadora) #define FLAG_SPECIAL 512 // Especial (habilitats, poders temporals i parts de l'excavadora)
#define FLAG_NOEDITOR 1024 // No es seleccionable a l'editor (son les portes) #define FLAG_NOEDITOR 1024 // No es seleccionable a l'editor (son les portes)
#define FLAG_INERTIA 2048 // Al rebre una espenta, continua fins tropesar en algo
#define FLAG_SENSIBLE 6 // PUSHABLE or REACTIVE #define FLAG_SENSIBLE 6 // PUSHABLE or REACTIVE
#define FLAG_IGNORE 1025 // HERO or NOEDITOR #define FLAG_IGNORE 1025 // HERO or NOEDITOR
@@ -40,7 +41,8 @@
#define MOV_CW 4 // Es mou en sentit de les agulles del rellotge #define MOV_CW 4 // Es mou en sentit de les agulles del rellotge
#define MOV_CCW 5 // Es mou en sentit contrari a les agulles del rellotge #define MOV_CCW 5 // Es mou en sentit contrari a les agulles del rellotge
#define MOV_RAND 6 // Es mou en direcció aleatòria #define MOV_RAND 6 // Es mou en direcció aleatòria
#define MOV_HUNT 7 // Persegueix al heroi #define MOV_RANDV 7 // Es mou en direcció aleatòria, diagonals incloses
#define MOV_HUNT 8 // Persegueix al heroi
// Boosters // Boosters
#define BOOST_NONE 0 #define BOOST_NONE 0
@@ -187,7 +189,9 @@ namespace actor
void useBoostRun(); void useBoostRun();
void useBoostJump(); void useBoostJump();
bool giveSkill(int skill);
bool giveSkill(char *skill); bool giveSkill(char *skill);
bool dropSkill(int skill);
bool dropSkill(char *skill); bool dropSkill(char *skill);
bool wasSkillCollected(char *skill); bool wasSkillCollected(char *skill);
int getSkills(); int getSkills();

View File

@@ -307,26 +307,50 @@ namespace modules
} }
} }
const int col1 = room::getColor(1); if (!editor::isEditing())
const int col2 = room::getColor(2); {
const int col3 = room::getColor(3); const int col1 = room::getColor(1);
draw::print2("a", 4, 26, col1, FONT_ZOOM_NONE); const int col2 = room::getColor(2);
draw::print2("b", 7, 26, col2, FONT_ZOOM_NONE); const int col3 = room::getColor(3);
draw::print2("c", 10, 26, col3, FONT_ZOOM_NONE); draw::print2("a", 4, 26, col1, FONT_ZOOM_NONE);
draw::print2("b", 7, 26, col2, FONT_ZOOM_NONE);
draw::print2(actor::hero::getBoostJump(), 2, 3, 27, col3, FONT_ZOOM_NONE); draw::print2("c", 10, 26, col3, FONT_ZOOM_NONE);
draw::print2(actor::hero::getBoostGod()/2, 2, 6, 27, col1, FONT_ZOOM_NONE);
draw::print2(actor::hero::getBoostRun()/2, 2, 9, 27, col2, FONT_ZOOM_NONE); draw::print2(actor::hero::getBoostJump(), 2, 3, 27, col3, FONT_ZOOM_NONE);
draw::print2(actor::hero::getBoostGod()/2, 2, 6, 27, col1, FONT_ZOOM_NONE);
draw::print2(actor::hero::getBoostRun()/2, 2, 9, 27, col2, FONT_ZOOM_NONE);
draw::setSource(draw::getSurface("objectes.gif")); draw::stencil::enable();
draw::swapcol(1, actor::hero::getSkills()&SKILL_SHOES ? col1 : col3); draw::stencil::clear(255);
draw::draw(276,166, 28, 22, 162, 0);
draw::swapcol(1, actor::hero::getSkills()&SKILL_PANTS ? col1 : col3); draw::setSource(draw::getSurface("objectes.gif"));
draw::draw(250,183, 18, 23, 167, 22); draw::stencil::set(SKILL_SHOES);
draw::swapcol(1, actor::hero::getSkills()&SKILL_GLOVES ? col1 : col3); draw::swapcol(1, actor::hero::getSkills()&SKILL_SHOES ? col1 : col3);
draw::draw(222,200, 21, 22, 165, 45); draw::draw(276,166, 28, 22, 162, 0);
draw::swapcol(1, actor::hero::getSkills()&SKILL_BAG ? col1 : col3); draw::stencil::set(SKILL_PANTS);
draw::draw(279,200, 20, 25, 145, 41); 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();
if (editor::isDevMode() && input::mouseClk(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);
}
}
}
/* /*
print(0,0,input::mouseX()); print(0,0,input::mouseX());
print(0,20,input::mouseY()); print(0,20,input::mouseY());
@@ -618,6 +642,7 @@ namespace modules
line+=10; line+=10;
ui::label("FLAGS", 2, line, 96, 11, GRAY); ui::label("FLAGS", 2, line, 96, 11, GRAY);
changed |= btn_check(50, line, "INER", act->flags, FLAG_INERTIA);
changed |= btn_check(74, line, "SPEC", act->flags, FLAG_SPECIAL); changed |= btn_check(74, line, "SPEC", act->flags, FLAG_SPECIAL);
line+=10; line+=10;