mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-22 08:49:46 +01:00
De-duplicate enemy/platform bounding box logic
It was basically being copy-pasted twice, which isn't good.
This commit is contained in:
parent
0ec38ad0f8
commit
a2f20e7e49
1 changed files with 23 additions and 18 deletions
|
@ -1701,32 +1701,37 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
const int ex = (ent.x % 40) * 8;
|
const int ex = (ent.x % 40) * 8;
|
||||||
const int ey = (ent.y % 30) * 8;
|
const int ey = (ent.y % 30) * 8;
|
||||||
|
|
||||||
|
// Platform and enemy bounding boxes
|
||||||
|
int bx1, by1, bx2, by2;
|
||||||
|
|
||||||
|
if (ent.t == 1 || (ent.t == 2 && ent.p1 <= 4))
|
||||||
|
{
|
||||||
|
bx1 = room.platx1;
|
||||||
|
by1 = room.platy1;
|
||||||
|
bx2 = room.platx2;
|
||||||
|
by2 = room.platy2;
|
||||||
|
|
||||||
|
// Enlarge bounding boxes to fix warping entities
|
||||||
|
if (warpx && bx1 == 0 && bx2 == 320)
|
||||||
|
{
|
||||||
|
bx1 -= 100;
|
||||||
|
bx2 += 100;
|
||||||
|
}
|
||||||
|
if (warpy && by1 == 0 && by2 == 240)
|
||||||
|
{
|
||||||
|
by1 -= 100;
|
||||||
|
by2 += 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch(ent.t){
|
switch(ent.t){
|
||||||
case 1: //Enemies
|
case 1: //Enemies
|
||||||
int bx1, by1, bx2, by2;
|
|
||||||
bx1=room.enemyx1;
|
|
||||||
by1=room.enemyy1;
|
|
||||||
bx2=room.enemyx2;
|
|
||||||
by2=room.enemyy2;
|
|
||||||
|
|
||||||
if(warpx){ if(bx1==0 && bx2==320){ bx1=-100; bx2=420; } }
|
|
||||||
if(warpy){ if(by1==0 && by2==240){ by1=-100; by2=340; } }
|
|
||||||
|
|
||||||
obj.customenemy=room.enemytype;
|
obj.customenemy=room.enemytype;
|
||||||
obj.createentity(ex, ey, 56,
|
obj.createentity(ex, ey, 56,
|
||||||
ent.p1, 4, bx1, by1, bx2, by2);
|
ent.p1, 4, bx1, by1, bx2, by2);
|
||||||
break;
|
break;
|
||||||
case 2: //Platforms and Threadmills
|
case 2: //Platforms and Threadmills
|
||||||
if(ent.p1<=4){
|
if(ent.p1<=4){
|
||||||
int bx1, by1, bx2, by2;
|
|
||||||
bx1=room.platx1;
|
|
||||||
by1=room.platy1;
|
|
||||||
bx2=room.platx2;
|
|
||||||
by2=room.platy2;
|
|
||||||
|
|
||||||
if(warpx){ if(bx1==0 && bx2==320){ bx1=-100; bx2=420; } }
|
|
||||||
if(warpy){ if(by1==0 && by2==240){ by1=-100; by2=340; } }
|
|
||||||
|
|
||||||
obj.createentity(ex, ey, 2,
|
obj.createentity(ex, ey, 2,
|
||||||
ent.p1, room.platv, bx1, by1, bx2, by2);
|
ent.p1, room.platv, bx1, by1, bx2, by2);
|
||||||
}else if(ent.p1 >= 5 && ent.p1 <= 8){ //Threadmill
|
}else if(ent.p1 >= 5 && ent.p1 <= 8){ //Threadmill
|
||||||
|
|
Loading…
Reference in a new issue