Game Development Community

Large scores > 1million

by Hitesh Patel · in iTorque 2D · 06/28/2012 (3:18 pm) · 6 replies

How can I display score that are more than 1million. At the moment it displays as 1e+006.

#1
07/01/2012 (4:24 am)
Any help? I am sure its something simple.
#2
07/01/2012 (6:44 am)
Check if your score is about to go over 999,999. If it is, store the 'millions' in one variable and the remainder in a second variable. Then you just re-combine them to display the score.
#3
07/02/2012 (1:08 am)
Lol...so simple, thanks.
#4
07/03/2012 (8:39 am)
The suggestion by Conor works for displaying the score but I also need to compare and submit score on the leaderboards. Isn't there anythign we can change in the source code to enable scores larger than 1million.
#5
07/07/2012 (9:41 am)
Anyone has suggestion to change the source code to enable scores larger than 1 million?
#6
07/09/2012 (7:48 am)
Thanks to Peter Simard (www.garagegames.com/community/forums/viewthread/31425/2#comments ) i solved my problem by implementing the following:

ConsoleFunction( MathAdd, const char*, 3, 3, "Add 2 large numbers" )
{
   S32 v1 = dAtoi(argv[1]);
   S32 v2 = dAtoi(argv[2]);

   S32 res = v1 + v2;
   char* ret = Con::getReturnBuffer(64);
   dSprintf(ret, 64, "%i", res);

   return ret;
}

ConsoleFunction( MathSub, const char*, 3, 3, "Subtract 2 large numbers" )
{
   S32 v1 = dAtoi(argv[1]);
   S32 v2 = dAtoi(argv[2]);

   S32 res = v1 - v2;
   char* ret = Con::getReturnBuffer(64);
   dSprintf(ret, 64, "%i", res);

   return ret;
}

ConsoleFunction( MathMul, const char*, 3, 3, "Multiply 2 large numbers" )
{
   S32 v1 = dAtoi(argv[1]);
   S32 v2 = dAtoi(argv[2]);

   S32 res = v1 * v2;
   char* ret = Con::getReturnBuffer(64);
   dSprintf(ret, 64, "%i", res);

   return ret;
}

ConsoleFunction( MathDiv, const char*, 3, 3, "Divide 2 large numbers" )
{
   S32 v1 = dAtoi(argv[1]);
   S32 v2 = dAtoi(argv[2]);

   S32 res = v1 / v2;
   char* ret = Con::getReturnBuffer(64);
   dSprintf(ret, 64, "%i", res);

   return ret;
}