mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-08 18:09: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;
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
if(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)
|
||||
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;
|
||||
|
@ -4880,7 +4855,7 @@ void entityclass::entitycollisioncheck()
|
|||
//how about the supercrewmate?
|
||||
if (game.supercrewmate)
|
||||
{
|
||||
if (scmcheckdamage() && !map.invincibility)
|
||||
if (checkdamage(true) && !map.invincibility)
|
||||
{
|
||||
//usual player dead stuff
|
||||
game.scmhurt = true;
|
||||
|
|
|
@ -100,9 +100,7 @@ public:
|
|||
|
||||
bool entitycollide(int a, int b);
|
||||
|
||||
bool checkdamage();
|
||||
|
||||
bool scmcheckdamage();
|
||||
bool checkdamage(bool scm = false);
|
||||
|
||||
void settemprect(int t);
|
||||
|
||||
|
|
Loading…
Reference in a new issue