mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
De-duplicate flipmode check in entityclass::entitycollisioncheck()
To deal with using a different image file for Flip Mode, it looks like copy-paste was used. This isn't exactly maintainable code. So I'm replacing it with a reference that changes depending on if the game is in Flip Mode or not, instead.
This commit is contained in:
parent
4f50883d58
commit
a922420066
1 changed files with 11 additions and 34 deletions
|
@ -4582,6 +4582,8 @@ void entityclass::customwarplinecheck(int i) {
|
||||||
|
|
||||||
void entityclass::entitycollisioncheck()
|
void entityclass::entitycollisioncheck()
|
||||||
{
|
{
|
||||||
|
std::vector<SDL_Surface*>& spritesvec = graphics.flipmode ? graphics.flipsprites : graphics.sprites;
|
||||||
|
|
||||||
for (size_t i = 0; i < entities.size(); i++)
|
for (size_t i = 0; i < entities.size(); i++)
|
||||||
{
|
{
|
||||||
//We test entity to entity
|
//We test entity to entity
|
||||||
|
@ -4601,23 +4603,11 @@ void entityclass::entitycollisioncheck()
|
||||||
colpoint1.y = entities[i].yp;
|
colpoint1.y = entities[i].yp;
|
||||||
colpoint2.x = entities[j].xp;
|
colpoint2.x = entities[j].xp;
|
||||||
colpoint2.y = entities[j].yp;
|
colpoint2.y = entities[j].yp;
|
||||||
if (graphics.flipmode)
|
if (graphics.Hitest(spritesvec[entities[i].drawframe],
|
||||||
|
colpoint1, spritesvec[entities[j].drawframe], colpoint2))
|
||||||
{
|
{
|
||||||
if (graphics.Hitest(graphics.flipsprites[entities[i].drawframe],
|
//Do the collision stuff
|
||||||
colpoint1, graphics.flipsprites[entities[j].drawframe], colpoint2))
|
game.deathseq = 30;
|
||||||
{
|
|
||||||
//Do the collision stuff
|
|
||||||
game.deathseq = 30;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (graphics.Hitest(graphics.sprites[entities[i].drawframe],
|
|
||||||
colpoint1, graphics.sprites[entities[j].drawframe], colpoint2) )
|
|
||||||
{
|
|
||||||
//Do the collision stuff
|
|
||||||
game.deathseq = 30;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -4713,25 +4703,12 @@ void entityclass::entitycollisioncheck()
|
||||||
colpoint1.y = entities[i].yp;
|
colpoint1.y = entities[i].yp;
|
||||||
colpoint2.x = entities[j].xp;
|
colpoint2.x = entities[j].xp;
|
||||||
colpoint2.y = entities[j].yp;
|
colpoint2.y = entities[j].yp;
|
||||||
if (graphics.flipmode)
|
if (graphics.Hitest(spritesvec[entities[i].drawframe],
|
||||||
|
colpoint1, spritesvec[entities[j].drawframe], colpoint2))
|
||||||
{
|
{
|
||||||
if (graphics.Hitest(graphics.flipsprites[entities[i].drawframe],
|
//Do the collision stuff
|
||||||
colpoint1, graphics.flipsprites[entities[j].drawframe], colpoint2))
|
game.deathseq = 30;
|
||||||
{
|
game.scmhurt = true;
|
||||||
//Do the collision stuff
|
|
||||||
game.deathseq = 30;
|
|
||||||
game.scmhurt = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (graphics.Hitest(graphics.sprites[entities[i].drawframe],
|
|
||||||
colpoint1, graphics.sprites[entities[j].drawframe], colpoint2))
|
|
||||||
{
|
|
||||||
//Do the collision stuff
|
|
||||||
game.deathseq = 30;
|
|
||||||
game.scmhurt = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue