mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-03 15:39:46 +01:00
Don't use separate variable for number of trinkets in level
Same principle as removing the separate variable to track number of collected trinkets. This means it's less error-prone as we're no longer tracking number of trinkets separately. In the function that counts the number of trinkets, I would've liked to have used std::count_if(). However, the most optimal way would require using a lambda, and lambdas are too new for the C++ standard we're using. So I just bit the bullet and counted them manually.
This commit is contained in:
parent
5661f46a52
commit
0047dc8d81
5 changed files with 21 additions and 13 deletions
|
@ -1950,7 +1950,7 @@ void Game::updatestate()
|
||||||
#if !defined(NO_CUSTOM_LEVELS)
|
#if !defined(NO_CUSTOM_LEVELS)
|
||||||
if(map.custommode)
|
if(map.custommode)
|
||||||
{
|
{
|
||||||
graphics.createtextbox(" " + help.number(trinkets()) + " out of " + help.number(ed.numtrinkets)+ " ", 50, 65, 174, 174, 174);
|
graphics.createtextbox(" " + help.number(trinkets()) + " out of " + help.number(ed.numtrinkets())+ " ", 50, 65, 174, 174, 174);
|
||||||
graphics.textboxcenterx();
|
graphics.textboxcenterx();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1970,7 +1970,7 @@ void Game::updatestate()
|
||||||
#if !defined(NO_CUSTOM_LEVELS)
|
#if !defined(NO_CUSTOM_LEVELS)
|
||||||
if(map.custommode)
|
if(map.custommode)
|
||||||
{
|
{
|
||||||
graphics.createtextbox(" " + help.number(trinkets()) + " out of " + help.number(ed.numtrinkets)+ " ", 50, 135, 174, 174, 174);
|
graphics.createtextbox(" " + help.number(trinkets()) + " out of " + help.number(ed.numtrinkets())+ " ", 50, 135, 174, 174, 174);
|
||||||
graphics.textboxcenterx();
|
graphics.textboxcenterx();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2095,7 +2095,7 @@ void Game::updatestate()
|
||||||
if(ed.numcrewmates-crewmates()==0)
|
if(ed.numcrewmates-crewmates()==0)
|
||||||
{
|
{
|
||||||
//Finished level
|
//Finished level
|
||||||
if(ed.numtrinkets-trinkets()==0)
|
if(ed.numtrinkets()-trinkets()==0)
|
||||||
{
|
{
|
||||||
//and got all the trinkets!
|
//and got all the trinkets!
|
||||||
updatecustomlevelstats(customlevelfilename, 3);
|
updatecustomlevelstats(customlevelfilename, 3);
|
||||||
|
|
|
@ -2251,7 +2251,7 @@ void maprender()
|
||||||
if (graphics.flipmode)
|
if (graphics.flipmode)
|
||||||
{
|
{
|
||||||
graphics.Print(0, 164, "[Trinkets found]", 196, 196, 255 - help.glow, true);
|
graphics.Print(0, 164, "[Trinkets found]", 196, 196, 255 - help.glow, true);
|
||||||
graphics.Print(0, 152, help.number(game.trinkets()) + " out of " + help.number(ed.numtrinkets), 96,96,96, true);
|
graphics.Print(0, 152, help.number(game.trinkets()) + " out of " + help.number(ed.numtrinkets()), 96,96,96, true);
|
||||||
|
|
||||||
graphics.Print(0, 114, "[Number of Deaths]", 196, 196, 255 - help.glow, true);
|
graphics.Print(0, 114, "[Number of Deaths]", 196, 196, 255 - help.glow, true);
|
||||||
graphics.Print(0, 102,help.String(game.deathcounts), 96,96,96, true);
|
graphics.Print(0, 102,help.String(game.deathcounts), 96,96,96, true);
|
||||||
|
@ -2262,7 +2262,7 @@ void maprender()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphics.Print(0, 52, "[Trinkets found]", 196, 196, 255 - help.glow, true);
|
graphics.Print(0, 52, "[Trinkets found]", 196, 196, 255 - help.glow, true);
|
||||||
graphics.Print(0, 64, help.number(game.trinkets()) + " out of "+help.number(ed.numtrinkets), 96,96,96, true);
|
graphics.Print(0, 64, help.number(game.trinkets()) + " out of "+help.number(ed.numtrinkets()), 96,96,96, true);
|
||||||
|
|
||||||
graphics.Print(0, 102, "[Number of Deaths]", 196, 196, 255 - help.glow, true);
|
graphics.Print(0, 102, "[Number of Deaths]", 196, 196, 255 - help.glow, true);
|
||||||
graphics.Print(0, 114,help.String(game.deathcounts), 96,96,96, true);
|
graphics.Print(0, 114,help.String(game.deathcounts), 96,96,96, true);
|
||||||
|
|
|
@ -1890,7 +1890,7 @@ void scriptclass::run()
|
||||||
#if !defined(NO_CUSTOM_LEVELS)
|
#if !defined(NO_CUSTOM_LEVELS)
|
||||||
if (map.custommode)
|
if (map.custommode)
|
||||||
{
|
{
|
||||||
usethisnum = help.number(ed.numtrinkets);
|
usethisnum = help.number(ed.numtrinkets());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -285,7 +285,6 @@ void editorclass::reset()
|
||||||
entframe=0;
|
entframe=0;
|
||||||
entframedelay=0;
|
entframedelay=0;
|
||||||
|
|
||||||
numtrinkets=0;
|
|
||||||
numcrewmates=0;
|
numcrewmates=0;
|
||||||
edentity.clear();
|
edentity.clear();
|
||||||
levmusic=0;
|
levmusic=0;
|
||||||
|
@ -1622,11 +1621,9 @@ int editorclass::findwarptoken(int t)
|
||||||
|
|
||||||
void editorclass::countstuff()
|
void editorclass::countstuff()
|
||||||
{
|
{
|
||||||
numtrinkets=0;
|
|
||||||
numcrewmates=0;
|
numcrewmates=0;
|
||||||
for(size_t i=0; i<edentity.size(); i++)
|
for(size_t i=0; i<edentity.size(); i++)
|
||||||
{
|
{
|
||||||
if(edentity[i].t==9) numtrinkets++;
|
|
||||||
if(edentity[i].t==15) numcrewmates++;
|
if(edentity[i].t==15) numcrewmates++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4828,11 +4825,10 @@ void editorinput()
|
||||||
{
|
{
|
||||||
if(ed.drawmode==3)
|
if(ed.drawmode==3)
|
||||||
{
|
{
|
||||||
if(ed.numtrinkets<100)
|
if(ed.numtrinkets()<100)
|
||||||
{
|
{
|
||||||
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),9);
|
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),9);
|
||||||
ed.lclickdelay=1;
|
ed.lclickdelay=1;
|
||||||
ed.numtrinkets++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5051,7 +5047,6 @@ void editorinput()
|
||||||
{
|
{
|
||||||
if(edentity[i].x==ed.tilex + (ed.levx*40)&& edentity[i].y==ed.tiley+ (ed.levy*30))
|
if(edentity[i].x==ed.tilex + (ed.levx*40)&& edentity[i].y==ed.tiley+ (ed.levy*30))
|
||||||
{
|
{
|
||||||
if(edentity[i].t==9) ed.numtrinkets--;
|
|
||||||
if(edentity[i].t==15) ed.numcrewmates--;
|
if(edentity[i].t==15) ed.numcrewmates--;
|
||||||
removeedentity(i);
|
removeedentity(i);
|
||||||
}
|
}
|
||||||
|
@ -5206,4 +5201,17 @@ void editorinput()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int editorclass::numtrinkets()
|
||||||
|
{
|
||||||
|
int temp = 0;
|
||||||
|
for (size_t i = 0; i < edentity.size(); i++)
|
||||||
|
{
|
||||||
|
if (edentity[i].t == 9)
|
||||||
|
{
|
||||||
|
temp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* NO_CUSTOM_LEVELS */
|
#endif /* NO_CUSTOM_LEVELS */
|
||||||
|
|
|
@ -151,7 +151,7 @@ class editorclass{
|
||||||
std::vector <int> swapmap;
|
std::vector <int> swapmap;
|
||||||
std::vector <int> contents;
|
std::vector <int> contents;
|
||||||
std::vector <int> vmult;
|
std::vector <int> vmult;
|
||||||
int numtrinkets;
|
int numtrinkets();
|
||||||
int numcrewmates;
|
int numcrewmates;
|
||||||
edlevelclass level[400]; //Maxwidth*maxheight
|
edlevelclass level[400]; //Maxwidth*maxheight
|
||||||
int kludgewarpdir[400]; //Also maxwidth*maxheight
|
int kludgewarpdir[400]; //Also maxwidth*maxheight
|
||||||
|
|
Loading…
Reference in a new issue