1
0
Fork 0
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:
Misa 2020-06-13 18:13:04 -07:00 committed by Ethan Lee
parent 4f50883d58
commit a922420066

View file

@ -4582,6 +4582,8 @@ void entityclass::customwarplinecheck(int i) {
void entityclass::entitycollisioncheck()
{
std::vector<SDL_Surface*>& spritesvec = graphics.flipmode ? graphics.flipsprites : graphics.sprites;
for (size_t i = 0; i < entities.size(); i++)
{
//We test entity to entity
@ -4601,26 +4603,14 @@ void entityclass::entitycollisioncheck()
colpoint1.y = entities[i].yp;
colpoint2.x = entities[j].xp;
colpoint2.y = entities[j].yp;
if (graphics.flipmode)
{
if (graphics.Hitest(graphics.flipsprites[entities[i].drawframe],
colpoint1, graphics.flipsprites[entities[j].drawframe], colpoint2))
if (graphics.Hitest(spritesvec[entities[i].drawframe],
colpoint1, spritesvec[entities[j].drawframe], colpoint2))
{
//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
{
//Ok, then we just assume a normal bounding box collision
game.deathseq = 30;
@ -4713,10 +4703,8 @@ void entityclass::entitycollisioncheck()
colpoint1.y = entities[i].yp;
colpoint2.x = entities[j].xp;
colpoint2.y = entities[j].yp;
if (graphics.flipmode)
{
if (graphics.Hitest(graphics.flipsprites[entities[i].drawframe],
colpoint1, graphics.flipsprites[entities[j].drawframe], colpoint2))
if (graphics.Hitest(spritesvec[entities[i].drawframe],
colpoint1, spritesvec[entities[j].drawframe], colpoint2))
{
//Do the collision stuff
game.deathseq = 30;
@ -4724,17 +4712,6 @@ void entityclass::entitycollisioncheck()
}
}
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
{
//Ok, then we just assume a normal bounding box collision
game.deathseq = 30;