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

@@ -433,7 +433,7 @@ namespace actor
{
if (act->name[0]=='B') // Es un booster
{
hero::setBooster(act->name[1]-48);
hero::collectBooster(act->name[1]-48);
actor::remove(act);
}
}
@@ -449,6 +449,7 @@ namespace actor
bool moving = false;
if ( input::keyDown(SDL_SCANCODE_LEFT) )
{
hero::useBoostRun();
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) ) )
{
@@ -466,6 +467,7 @@ namespace actor
}
else if ( input::keyDown(SDL_SCANCODE_RIGHT) )
{
hero::useBoostRun();
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) ) )
{
@@ -483,6 +485,7 @@ namespace actor
}
else if ( input::keyDown(SDL_SCANCODE_UP) )
{
hero::useBoostRun();
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) ) )
{
@@ -500,6 +503,7 @@ namespace actor
}
else if ( input::keyDown(SDL_SCANCODE_DOWN) )
{
hero::useBoostRun();
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) ) )
{
@@ -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))
{
// [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_push=0; // es el comptador de botant, seguirà pujant mentres siga < 8
act->react_mask=hero::getBoostJump()>0 ? 2 : 1; // =1 estic botant (anant cap amunt)
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);
if (act->below)
{
act->below->above = 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_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
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)...
if (act->react_push<9)
// Si encara està botant (react_push > 0)...
if (act->react_push>0)
{
act->pos.z++; // seguim pujant
act->react_push++; // augmentem el comptador de bot
const int vel = act->react_mask;
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...
{
@@ -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) )
//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->pos.z>=max.z)
@@ -1230,19 +1237,52 @@ namespace actor
namespace hero
{
int boosters = BOOST_NONE;
int boost_jumps = 0;
int boost_steps = 0;
int boost_god = 0;
int skills = SKILL_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)
{

View File

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

View File

@@ -354,6 +354,7 @@ bool game::loop()
else
{
actor::update(actor::getFirst());
actor::hero::useBoostGod();
}
draw::resetViewport();
@@ -369,6 +370,9 @@ bool game::loop()
room::draw2();
draw::swapcol(1, WHITE+LIGHT);
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);
/*