- [NEW] Jump booster implementat

- [NEW] God booster implementat
- [NEW] Contadors dels boosters, ja no son infinits.
- [FIX] Al botar si topeta en algo, no ho atravesa (bueno, algunes vegades encara...)
This commit is contained in:
2024-07-01 20:02:26 +02:00
parent 8789bea813
commit 8b1cf9a405
4 changed files with 103 additions and 29 deletions

View File

@@ -22,18 +22,6 @@ actor{
movement: CW movement: CW
} }
actor{
name: LIFT
bmp: caixes.gif
bmp-rect: 32 32 32 24
bmp-offset: 0 24
pos: 56 0 0
size: 8 8 4
orient: ZP
flags: MOVING
movement: Z
}
actor{ actor{
name: YONKI name: YONKI
bmp: caixes.gif bmp: caixes.gif
@@ -47,6 +35,31 @@ actor{
movement: CW movement: CW
} }
actor{
name: B2
bmp: objectes.gif
bmp-rect: 114 78 15 18
bmp-offset: -8 22
pos: 16 32 0
size: 4 4 4
anim-cycle: SEQ
anim-wait: 2
flags: ANIMATED SPECIAL
movement: CW
}
actor{
name: LIFT
bmp: caixes.gif
bmp-rect: 32 32 32 24
bmp-offset: 0 24
pos: 56 0 0
size: 8 8 4
orient: ZP
flags: MOVING
movement: Z
}
actor{ actor{
name: BARREL name: BARREL
bmp: caixes.gif bmp: caixes.gif
@@ -79,3 +92,16 @@ actor{
size: 8 8 8 size: 8 8 8
movement: CW movement: CW
} }
actor{
name: B4
bmp: objectes.gif
bmp-rect: 114 78 15 18
bmp-offset: -8 22
pos: 0 40 0
size: 4 4 4
anim-cycle: SEQ
anim-wait: 2
flags: ANIMATED SPECIAL
movement: CW
}

View File

@@ -433,7 +433,7 @@ namespace actor
{ {
if (act->name[0]=='B') // Es un booster if (act->name[0]=='B') // Es un booster
{ {
hero::setBooster(act->name[1]-48); hero::collectBooster(act->name[1]-48);
actor::remove(act); actor::remove(act);
} }
} }
@@ -449,6 +449,7 @@ namespace actor
bool moving = false; bool moving = false;
if ( input::keyDown(SDL_SCANCODE_LEFT) ) if ( input::keyDown(SDL_SCANCODE_LEFT) )
{ {
hero::useBoostRun();
act->orient=PUSH_XN; act->orient=PUSH_XN;
if ( (act->pos.x>min.x && act->pos.y>=min.y && (act->pos.y+act->size.y)<=max.y) || ( (room::getDoors()&DOOR_XN) && (act->pos.y>=24) && (act->pos.y<=32) ) ) if ( (act->pos.x>min.x && act->pos.y>=min.y && (act->pos.y+act->size.y)<=max.y) || ( (room::getDoors()&DOOR_XN) && (act->pos.y>=24) && (act->pos.y<=32) ) )
{ {
@@ -466,6 +467,7 @@ namespace actor
} }
else if ( input::keyDown(SDL_SCANCODE_RIGHT) ) else if ( input::keyDown(SDL_SCANCODE_RIGHT) )
{ {
hero::useBoostRun();
act->orient=PUSH_XP; act->orient=PUSH_XP;
if ( ((act->pos.x+act->size.x)<max.x && act->pos.y>=min.y && (act->pos.y+act->size.y)<=max.y) || ( (room::getDoors()&DOOR_XP) && (act->pos.y>=24) && (act->pos.y<=32) ) ) if ( ((act->pos.x+act->size.x)<max.x && act->pos.y>=min.y && (act->pos.y+act->size.y)<=max.y) || ( (room::getDoors()&DOOR_XP) && (act->pos.y>=24) && (act->pos.y<=32) ) )
{ {
@@ -483,6 +485,7 @@ namespace actor
} }
else if ( input::keyDown(SDL_SCANCODE_UP) ) else if ( input::keyDown(SDL_SCANCODE_UP) )
{ {
hero::useBoostRun();
act->orient=PUSH_YN; act->orient=PUSH_YN;
if ( (act->pos.y>min.y && act->pos.x>=min.x && (act->pos.x+act->size.x)<=max.x) || ( (room::getDoors()&DOOR_YN) && (act->pos.x>=24) && (act->pos.x<=32) ) ) if ( (act->pos.y>min.y && act->pos.x>=min.x && (act->pos.x+act->size.x)<=max.x) || ( (room::getDoors()&DOOR_YN) && (act->pos.x>=24) && (act->pos.x<=32) ) )
{ {
@@ -500,6 +503,7 @@ namespace actor
} }
else if ( input::keyDown(SDL_SCANCODE_DOWN) ) else if ( input::keyDown(SDL_SCANCODE_DOWN) )
{ {
hero::useBoostRun();
act->orient=PUSH_YP; act->orient=PUSH_YP;
if ( ((act->pos.y+act->size.y)<max.y && act->pos.x>=min.x && (act->pos.x+act->size.x)<=max.x) || ( (room::getDoors()&DOOR_YP) && (act->pos.x>=24) && (act->pos.x<=32) ) ) if ( ((act->pos.y+act->size.y)<max.y && act->pos.x>=min.x && (act->pos.x+act->size.x)<=max.x) || ( (room::getDoors()&DOOR_YP) && (act->pos.x>=24) && (act->pos.x<=32) ) )
{ {
@@ -546,14 +550,16 @@ namespace actor
if ( input::keyDown(SDL_SCANCODE_SPACE) && (act->pos.y+act->size.y)<=max.y && act->pos.y>=min.y && (act->pos.x+act->size.x)<=max.x && act->pos.x>=min.x && act->react_mask==0 && (act->pos.z==0 || act->below)) if ( input::keyDown(SDL_SCANCODE_SPACE) && (act->pos.y+act->size.y)<=max.y && act->pos.y>=min.y && (act->pos.x+act->size.x)<=max.x && act->pos.x>=min.x && act->react_mask==0 && (act->pos.z==0 || act->below))
{ {
// [RZC 14/05/2024] hack usant react_mask i react_push del heroi. Llegir més avall. // [RZC 14/05/2024] hack usant react_mask i react_push del heroi. Llegir més avall.
act->react_mask=1; // =1 estic botant (anant cap amunt) act->react_mask=hero::getBoostJump()>0 ? 2 : 1; // =1 estic botant (anant cap amunt)
act->react_push=0; // es el comptador de botant, seguirà pujant mentres siga < 8 act->react_push=8; // es el comptador de botant, seguirà pujant mentres siga > 0
//act->react_push=hero::getBoostJump()>0?16:8; // es el comptador de botant, seguirà pujant mentres siga > 0
act->flags &= uint8_t(~FLAG_GRAVITY); act->flags &= uint8_t(~FLAG_GRAVITY);
if (act->below) if (act->below)
{ {
act->below->above = nullptr; act->below->above = nullptr;
act->below = nullptr; act->below = nullptr;
} }
hero::useBoostJump();
} }
if (input::keyDown(SDL_SCANCODE_Z) && act->pos.z>0) { act->push |= PUSH_ZN; moving = true; } if (input::keyDown(SDL_SCANCODE_Z) && act->pos.z>0) { act->push |= PUSH_ZN; moving = true; }
if (input::keyDown(SDL_SCANCODE_A) && act->pos.z<max.z) { act->push |= PUSH_ZP; moving = true; } if (input::keyDown(SDL_SCANCODE_A) && act->pos.z<max.z) { act->push |= PUSH_ZP; moving = true; }
@@ -567,11 +573,12 @@ namespace actor
// Si topetem en una vora de l'habitació, s'acabat el bot // Si topetem en una vora de l'habitació, s'acabat el bot
if ((act->pos.x+act->size.x)>max.x || act->pos.x<min.x || (act->pos.y+act->size.y)>max.y || act->pos.y<min.y) act->react_push=9; if ((act->pos.x+act->size.x)>max.x || act->pos.x<min.x || (act->pos.y+act->size.y)>max.y || act->pos.y<min.y) act->react_push=9;
// Si encara està botant (react_push < 8)... // Si encara està botant (react_push > 0)...
if (act->react_push<9) if (act->react_push>0)
{ {
act->pos.z++; // seguim pujant const int vel = act->react_mask;
act->react_push++; // augmentem el comptador de bot if (!actor::any_above_me(act)) act->pos.z+=vel; // seguim pujant
act->react_push--; // augmentem el comptador de bot
} }
else // Si ja ha acabat de botar... else // Si ja ha acabat de botar...
{ {
@@ -651,7 +658,7 @@ namespace actor
//if ((act->flags&FLAG_HERO) && (act->pos.x>max.x || act->pos.x<min.x || act->pos.y>max.y || act->pos.y<min.y) ) //if ((act->flags&FLAG_HERO) && (act->pos.x>max.x || act->pos.x<min.x || act->pos.y>max.y || act->pos.y<min.y) )
//return; //return;
int vel = (act->flags&FLAG_HERO) && (hero::getBooster()==BOOST_RUN) ? 2 : 1; int vel = (act->flags&FLAG_HERO) && (hero::getBoostRun()>0) ? 2 : 1;
if (act->push & PUSH_ZP) { if (act->push & PUSH_ZP) {
if (act->pos.z>=max.z) if (act->pos.z>=max.z)
@@ -1230,19 +1237,52 @@ namespace actor
namespace hero namespace hero
{ {
int boosters = BOOST_NONE; int boost_jumps = 0;
int boost_steps = 0;
int boost_god = 0;
int skills = SKILL_NONE; int skills = SKILL_NONE;
int parts = PART_NONE; int parts = PART_NONE;
void setBooster(int booster) void collectBooster(int booster)
{ {
boosters = booster; switch (booster)
{
case BOOST_GOD: boost_god = 99*2; break;
case BOOST_RUN: boost_steps = 99*2; break;
case BOOST_JUMP: boost_jumps = 10; break;
}
} }
int getBooster() int getBoostGod()
{ {
return boosters; return boost_god;
} }
int getBoostRun()
{
return boost_steps;
}
int getBoostJump()
{
return boost_jumps;
}
void useBoostGod()
{
if (boost_god > 0) boost_god--;
}
void useBoostRun()
{
if (boost_steps > 0) boost_steps--;
}
void useBoostJump()
{
if (boost_jumps > 0) boost_jumps--;
}
void giveSkill(int skill) void giveSkill(int skill)
{ {

View File

@@ -46,8 +46,7 @@
#define BOOST_NONE 0 #define BOOST_NONE 0
#define BOOST_RUN 1 #define BOOST_RUN 1
#define BOOST_GOD 2 #define BOOST_GOD 2
#define BOOST_LONG_JUMP 3 #define BOOST_JUMP 4
#define BOOST_TALL_JUMP 4
// Skills // Skills
#define SKILL_NONE 0 #define SKILL_NONE 0
@@ -167,8 +166,13 @@ namespace actor
namespace hero namespace hero
{ {
void setBooster(int booster); void collectBooster(int booster);
int getBooster(); int getBoostGod();
int getBoostRun();
int getBoostJump();
void useBoostGod();
void useBoostRun();
void useBoostJump();
void giveSkill(int skill); void giveSkill(int skill);
int getSkills(); int getSkills();

View File

@@ -354,6 +354,7 @@ bool game::loop()
else else
{ {
actor::update(actor::getFirst()); actor::update(actor::getFirst());
actor::hero::useBoostGod();
} }
draw::resetViewport(); draw::resetViewport();
@@ -369,6 +370,9 @@ bool game::loop()
room::draw2(); room::draw2();
draw::swapcol(1, WHITE+LIGHT); draw::swapcol(1, WHITE+LIGHT);
actor::draw(actor::getPicked(), false); actor::draw(actor::getPicked(), false);
print(10, 200, actor::hero::getBoostJump());
print(30, 200, actor::hero::getBoostGod()/2);
print(50, 200, actor::hero::getBoostRun()/2);
//draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0); //draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0);
/* /*