mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
De-duplicate expressions of actual coordinates for edentities
Previously it copy-pasted this god-awful overcomplicated expression (possibly for cursed ActionScript legacy reasons?) everywhere, instead of putting it in a variable, or even just using a simpler one like the one I replaced it with. Now the obj.createentity() and obj.createblock() calls are much nicer.
This commit is contained in:
parent
34b0e2c812
commit
d591c77088
1 changed files with 22 additions and 20 deletions
|
@ -1686,6 +1686,8 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const int ex = (edentity[edi].x % 40) * 8;
|
||||||
|
const int ey = (edentity[edi].y % 30) * 8;
|
||||||
switch(edentity[edi].t){
|
switch(edentity[edi].t){
|
||||||
case 1: //Enemies
|
case 1: //Enemies
|
||||||
int bx1, by1, bx2, by2;
|
int bx1, by1, bx2, by2;
|
||||||
|
@ -1698,7 +1700,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
if(warpy){ if(by1==0 && by2==240){ by1=-100; by2=340; } }
|
if(warpy){ if(by1==0 && by2==240){ by1=-100; by2=340; } }
|
||||||
|
|
||||||
obj.customenemy=ed.level[tsx+((ed.maxwidth)*tsy)].enemytype;
|
obj.customenemy=ed.level[tsx+((ed.maxwidth)*tsy)].enemytype;
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8),(edentity[edi].y*8)- ((ry-100)*30*8), 56,
|
obj.createentity(ex, ey, 56,
|
||||||
edentity[edi].p1, 4, bx1, by1, bx2, by2);
|
edentity[edi].p1, 4, bx1, by1, bx2, by2);
|
||||||
break;
|
break;
|
||||||
case 2: //Platforms and Threadmills
|
case 2: //Platforms and Threadmills
|
||||||
|
@ -1712,43 +1714,43 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
if(warpx){ if(bx1==0 && bx2==320){ bx1=-100; bx2=420; } }
|
if(warpx){ if(bx1==0 && bx2==320){ bx1=-100; bx2=420; } }
|
||||||
if(warpy){ if(by1==0 && by2==240){ by1=-100; by2=340; } }
|
if(warpy){ if(by1==0 && by2==240){ by1=-100; by2=340; } }
|
||||||
|
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8),(edentity[edi].y*8)- ((ry-100)*30*8), 2,
|
obj.createentity(ex, ey, 2,
|
||||||
edentity[edi].p1, ed.level[rx-100+((ry-100)*ed.mapwidth)].platv, bx1, by1, bx2, by2);
|
edentity[edi].p1, ed.level[rx-100+((ry-100)*ed.mapwidth)].platv, bx1, by1, bx2, by2);
|
||||||
}else if(edentity[edi].p1>=5 && edentity[edi].p1<=8){ //Threadmill
|
}else if(edentity[edi].p1>=5 && edentity[edi].p1<=8){ //Threadmill
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8),(edentity[edi].y*8)- ((ry-100)*30*8), 2,
|
obj.createentity(ex, ey, 2,
|
||||||
edentity[edi].p1+3, 4);
|
edentity[edi].p1+3, 4);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: //Disappearing platforms
|
case 3: //Disappearing platforms
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8),(edentity[edi].y*8)- ((ry-100)*30*8), 3);
|
obj.createentity(ex, ey, 3);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8),(edentity[edi].y*8)- ((ry-100)*30*8), 9, ed.findtrinket(edi));
|
obj.createentity(ex, ey, 9, ed.findtrinket(edi));
|
||||||
break;
|
break;
|
||||||
case 10: //Checkpoints
|
case 10: //Checkpoints
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8),(edentity[edi].y*8)- ((ry-100)*30*8), 10,
|
obj.createentity(ex, ey, 10,
|
||||||
edentity[edi].p1,((rx+(ry*100))*20)+tempcheckpoints);
|
edentity[edi].p1,((rx+(ry*100))*20)+tempcheckpoints);
|
||||||
tempcheckpoints++;
|
tempcheckpoints++;
|
||||||
break;
|
break;
|
||||||
case 11: //Gravity Lines
|
case 11: //Gravity Lines
|
||||||
if(edentity[edi].p1==0){ //Horizontal
|
if(edentity[edi].p1==0){ //Horizontal
|
||||||
obj.createentity((edentity[edi].p2*8),(edentity[edi].y*8)- ((ry-100)*30*8)+4, 11, edentity[edi].p3);
|
obj.createentity((edentity[edi].p2*8), ey + 4, 11, edentity[edi].p3);
|
||||||
}else{ //Vertical
|
}else{ //Vertical
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8)+3,(edentity[edi].p2*8), 12, edentity[edi].p3);
|
obj.createentity(ex + 3,(edentity[edi].p2*8), 12, edentity[edi].p3);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 13: //Warp Tokens
|
case 13: //Warp Tokens
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8),(edentity[edi].y*8)- ((ry-100)*30*8), 13, edentity[edi].p1, edentity[edi].p2);
|
obj.createentity(ex, ey, 13, edentity[edi].p1, edentity[edi].p2);
|
||||||
break;
|
break;
|
||||||
case 15: //Collectable crewmate
|
case 15: //Collectable crewmate
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8)-4,(edentity[edi].y*8)- ((ry-100)*30*8)+1, 55, ed.findcrewmate(edi), edentity[edi].p1, edentity[edi].p2);
|
obj.createentity(ex - 4, ey + 1, 55, ed.findcrewmate(edi), edentity[edi].p1, edentity[edi].p2);
|
||||||
break;
|
break;
|
||||||
case 17: //Roomtext!
|
case 17: //Roomtext!
|
||||||
{
|
{
|
||||||
roomtexton = true;
|
roomtexton = true;
|
||||||
Roomtext text;
|
Roomtext text;
|
||||||
text.x = edentity[edi].x - ((rx-100)*40);
|
text.x = ex / 8;
|
||||||
text.y = edentity[edi].y - ((ry-100)*30);
|
text.y = ey / 8;
|
||||||
text.text = edentity[edi].scriptname;
|
text.text = edentity[edi].scriptname;
|
||||||
roomtext.push_back(text);
|
roomtext.push_back(text);
|
||||||
break;
|
break;
|
||||||
|
@ -1758,7 +1760,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
obj.customscript=edentity[edi].scriptname;
|
obj.customscript=edentity[edi].scriptname;
|
||||||
|
|
||||||
int usethistile = edentity[edi].p1;
|
int usethistile = edentity[edi].p1;
|
||||||
int usethisy = (edentity[edi].y*8)- ((ry-100)*30*8);
|
int usethisy = ey;
|
||||||
|
|
||||||
// This isn't a boolean: we just swap 0 and 1 around and leave the rest alone
|
// This isn't a boolean: we just swap 0 and 1 around and leave the rest alone
|
||||||
if (usethistile == 0)
|
if (usethistile == 0)
|
||||||
|
@ -1771,8 +1773,8 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
usethisy -= 8;
|
usethisy -= 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8), usethisy+8, 20, usethistile);
|
obj.createentity(ex, usethisy + 8, 20, usethistile);
|
||||||
obj.createblock(5, (edentity[edi].x*8)- ((rx-100)*40*8)-8, usethisy+8, 20, 16, 35);
|
obj.createblock(5, ex - 8, usethisy + 8, 20, 16, 35);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 19: //Script Box
|
case 19: //Script Box
|
||||||
|
@ -1780,20 +1782,20 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
{
|
{
|
||||||
game.customscript[tempscriptbox]=edentity[edi].scriptname;
|
game.customscript[tempscriptbox]=edentity[edi].scriptname;
|
||||||
}
|
}
|
||||||
obj.createblock(1, (edentity[edi].x*8)- ((rx-100)*40*8), (edentity[edi].y*8)- ((ry-100)*30*8),
|
obj.createblock(1, ex, ey,
|
||||||
edentity[edi].p1*8, edentity[edi].p2*8, 300+tempscriptbox, "custom_" + edentity[edi].scriptname);
|
edentity[edi].p1*8, edentity[edi].p2*8, 300+tempscriptbox, "custom_" + edentity[edi].scriptname);
|
||||||
tempscriptbox++;
|
tempscriptbox++;
|
||||||
break;
|
break;
|
||||||
case 50: //Warp Lines
|
case 50: //Warp Lines
|
||||||
obj.customwarpmode=true;
|
obj.customwarpmode=true;
|
||||||
if(edentity[edi].p1==0){ //
|
if(edentity[edi].p1==0){ //
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8)+4,(edentity[edi].p2*8), 51, edentity[edi].p3);
|
obj.createentity(ex + 4,(edentity[edi].p2*8), 51, edentity[edi].p3);
|
||||||
}else if(edentity[edi].p1==1){ //Horizontal, right
|
}else if(edentity[edi].p1==1){ //Horizontal, right
|
||||||
obj.createentity((edentity[edi].x*8)- ((rx-100)*40*8)+4,(edentity[edi].p2*8), 52, edentity[edi].p3);
|
obj.createentity(ex + 4,(edentity[edi].p2*8), 52, edentity[edi].p3);
|
||||||
}else if(edentity[edi].p1==2){ //Vertical, top
|
}else if(edentity[edi].p1==2){ //Vertical, top
|
||||||
obj.createentity((edentity[edi].p2*8),(edentity[edi].y*8)- ((ry-100)*30*8)+7, 53, edentity[edi].p3);
|
obj.createentity((edentity[edi].p2*8), ey + 7, 53, edentity[edi].p3);
|
||||||
}else if(edentity[edi].p1==3){
|
}else if(edentity[edi].p1==3){
|
||||||
obj.createentity((edentity[edi].p2*8),(edentity[edi].y*8)- ((ry-100)*30*8), 54, edentity[edi].p3);
|
obj.createentity((edentity[edi].p2*8), ey, 54, edentity[edi].p3);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue