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(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();
|
||||
}
|
||||
else
|
||||
|
@ -1970,7 +1970,7 @@ void Game::updatestate()
|
|||
#if !defined(NO_CUSTOM_LEVELS)
|
||||
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();
|
||||
}
|
||||
else
|
||||
|
@ -2095,7 +2095,7 @@ void Game::updatestate()
|
|||
if(ed.numcrewmates-crewmates()==0)
|
||||
{
|
||||
//Finished level
|
||||
if(ed.numtrinkets-trinkets()==0)
|
||||
if(ed.numtrinkets()-trinkets()==0)
|
||||
{
|
||||
//and got all the trinkets!
|
||||
updatecustomlevelstats(customlevelfilename, 3);
|
||||
|
|
|
@ -2251,7 +2251,7 @@ void maprender()
|
|||
if (graphics.flipmode)
|
||||
{
|
||||
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, 102,help.String(game.deathcounts), 96,96,96, true);
|
||||
|
@ -2262,7 +2262,7 @@ void maprender()
|
|||
else
|
||||
{
|
||||
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, 114,help.String(game.deathcounts), 96,96,96, true);
|
||||
|
|
|
@ -1890,7 +1890,7 @@ void scriptclass::run()
|
|||
#if !defined(NO_CUSTOM_LEVELS)
|
||||
if (map.custommode)
|
||||
{
|
||||
usethisnum = help.number(ed.numtrinkets);
|
||||
usethisnum = help.number(ed.numtrinkets());
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
|
@ -285,7 +285,6 @@ void editorclass::reset()
|
|||
entframe=0;
|
||||
entframedelay=0;
|
||||
|
||||
numtrinkets=0;
|
||||
numcrewmates=0;
|
||||
edentity.clear();
|
||||
levmusic=0;
|
||||
|
@ -1622,11 +1621,9 @@ int editorclass::findwarptoken(int t)
|
|||
|
||||
void editorclass::countstuff()
|
||||
{
|
||||
numtrinkets=0;
|
||||
numcrewmates=0;
|
||||
for(size_t i=0; i<edentity.size(); i++)
|
||||
{
|
||||
if(edentity[i].t==9) numtrinkets++;
|
||||
if(edentity[i].t==15) numcrewmates++;
|
||||
}
|
||||
}
|
||||
|
@ -4828,11 +4825,10 @@ void editorinput()
|
|||
{
|
||||
if(ed.drawmode==3)
|
||||
{
|
||||
if(ed.numtrinkets<100)
|
||||
if(ed.numtrinkets()<100)
|
||||
{
|
||||
addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),9);
|
||||
ed.lclickdelay=1;
|
||||
ed.numtrinkets++;
|
||||
}
|
||||
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].t==9) ed.numtrinkets--;
|
||||
if(edentity[i].t==15) ed.numcrewmates--;
|
||||
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 */
|
||||
|
|
|
@ -151,7 +151,7 @@ class editorclass{
|
|||
std::vector <int> swapmap;
|
||||
std::vector <int> contents;
|
||||
std::vector <int> vmult;
|
||||
int numtrinkets;
|
||||
int numtrinkets();
|
||||
int numcrewmates;
|
||||
edlevelclass level[400]; //Maxwidth*maxheight
|
||||
int kludgewarpdir[400]; //Also maxwidth*maxheight
|
||||
|
|
Loading…
Reference in a new issue