mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-24 17:54:59 +01:00
De-duplicate stuck prevention for the player/SCM
Stuck prevention (pushing the player/supercrewmate out if they are inside a wall) has been factored out into its own function, so it's no longer copy-pasted but slightly tweaked just for the supercrewmate.
This commit is contained in:
parent
5e29d676e9
commit
fae14f4e98
2 changed files with 29 additions and 33 deletions
|
@ -4603,43 +4603,12 @@ void entityclass::entitycollisioncheck()
|
||||||
}
|
}
|
||||||
|
|
||||||
//can't have the player being stuck...
|
//can't have the player being stuck...
|
||||||
int j = getplayer();
|
stuckprevention(getplayer());
|
||||||
skipdirblocks = true;
|
|
||||||
if (j > -1 && !testwallsx(j, entities[j].xp, entities[j].yp))
|
|
||||||
{
|
|
||||||
//Let's try to get out...
|
|
||||||
if (entities[j].rule == 0)
|
|
||||||
{
|
|
||||||
if(game.gravitycontrol==0)
|
|
||||||
{
|
|
||||||
entities[j].yp -= 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entities[j].yp += 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
skipdirblocks = false;
|
|
||||||
|
|
||||||
//Can't have the supercrewmate getting stuck either!
|
//Can't have the supercrewmate getting stuck either!
|
||||||
if (game.supercrewmate)
|
if (game.supercrewmate)
|
||||||
{
|
{
|
||||||
j = getscm();
|
stuckprevention(getscm());
|
||||||
skipdirblocks = true;
|
|
||||||
if (!testwallsx(j, entities[j].xp, entities[j].yp))
|
|
||||||
{
|
|
||||||
//Let's try to get out...
|
|
||||||
if(game.gravitycontrol==0)
|
|
||||||
{
|
|
||||||
entities[j].yp -= 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entities[j].yp += 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
skipdirblocks = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Is the player colliding with any damageblocks?
|
//Is the player colliding with any damageblocks?
|
||||||
|
@ -4802,3 +4771,28 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void entityclass::stuckprevention(int t)
|
||||||
|
{
|
||||||
|
if (!INBOUNDS(t, entities))
|
||||||
|
{
|
||||||
|
puts("stuckprevention() out-of-bounds!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
skipdirblocks = true;
|
||||||
|
// Can't have this entity (player or supercrewmate) being stuck...
|
||||||
|
if (!testwallsx(t, entities[t].xp, entities[t].yp))
|
||||||
|
{
|
||||||
|
// Let's try to get out...
|
||||||
|
if (game.gravitycontrol == 0)
|
||||||
|
{
|
||||||
|
entities[t].yp -= 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entities[t].yp += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skipdirblocks = false;
|
||||||
|
}
|
||||||
|
|
|
@ -160,6 +160,8 @@ public:
|
||||||
|
|
||||||
void collisioncheck(int i, int j, bool scm = false);
|
void collisioncheck(int i, int j, bool scm = false);
|
||||||
|
|
||||||
|
void stuckprevention(int t);
|
||||||
|
|
||||||
|
|
||||||
std::vector<entclass> entities;
|
std::vector<entclass> entities;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue