mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 10:29:45 +01:00
De-duplicate spike hitbox checks for player/SCM
The spike hitbox check is now one function for both the player and the supercrewmate, instead of being two separate functions.
This commit is contained in:
parent
46049705f4
commit
1c5b72410a
2 changed files with 5 additions and 32 deletions
|
@ -3859,37 +3859,12 @@ bool entityclass::entitycollide( int a, int b )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool entityclass::checkdamage()
|
bool entityclass::checkdamage(bool scm /*= false*/)
|
||||||
{
|
{
|
||||||
//Returns true if player entity (rule 0) collides with a damagepoint
|
//Returns true if player (or supercrewmate) collides with a damagepoint
|
||||||
for(size_t i=0; i < entities.size(); i++)
|
for(size_t i=0; i < entities.size(); i++)
|
||||||
{
|
{
|
||||||
if(entities[i].rule==0)
|
if((scm && entities[i].type == 14) || (!scm && entities[i].rule == 0))
|
||||||
{
|
|
||||||
tempx = entities[i].xp + entities[i].cx;
|
|
||||||
tempy = entities[i].yp + entities[i].cy;
|
|
||||||
tempw = entities[i].w;
|
|
||||||
temph = entities[i].h;
|
|
||||||
rectset(tempx, tempy, tempw, temph);
|
|
||||||
|
|
||||||
for (size_t j=0; j<blocks.size(); j++)
|
|
||||||
{
|
|
||||||
if (blocks[j].type == DAMAGE && help.intersects(blocks[j].rect, temprect))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool entityclass::scmcheckdamage()
|
|
||||||
{
|
|
||||||
//Returns true if supercrewmate collides with a damagepoint
|
|
||||||
for(size_t i=0; i < entities.size(); i++)
|
|
||||||
{
|
|
||||||
if(entities[i].type==14)
|
|
||||||
{
|
{
|
||||||
tempx = entities[i].xp + entities[i].cx;
|
tempx = entities[i].xp + entities[i].cx;
|
||||||
tempy = entities[i].yp + entities[i].cy;
|
tempy = entities[i].yp + entities[i].cy;
|
||||||
|
@ -4880,7 +4855,7 @@ void entityclass::entitycollisioncheck()
|
||||||
//how about the supercrewmate?
|
//how about the supercrewmate?
|
||||||
if (game.supercrewmate)
|
if (game.supercrewmate)
|
||||||
{
|
{
|
||||||
if (scmcheckdamage() && !map.invincibility)
|
if (checkdamage(true) && !map.invincibility)
|
||||||
{
|
{
|
||||||
//usual player dead stuff
|
//usual player dead stuff
|
||||||
game.scmhurt = true;
|
game.scmhurt = true;
|
||||||
|
|
|
@ -100,9 +100,7 @@ public:
|
||||||
|
|
||||||
bool entitycollide(int a, int b);
|
bool entitycollide(int a, int b);
|
||||||
|
|
||||||
bool checkdamage();
|
bool checkdamage(bool scm = false);
|
||||||
|
|
||||||
bool scmcheckdamage();
|
|
||||||
|
|
||||||
void settemprect(int t);
|
void settemprect(int t);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue