playMaker

Author Topic: Score Format  (Read 754 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Score Format
« on: June 03, 2017, 03:16:21 PM »
Hi!
My score has this formating: 000, 000, 000, but I don't want to have all the zeros there. My question is: Is there a way to get the score format like this.

Score: 0
Score: 100
Score: 500
Score: 1, 000
Score: 10, 000
Score: 100, 000
Score: 1, 000, 000
And so on.

I don't want to have the score like this:
Score: 000, 000, 000
Score: 000, 000, 100
Score: 000, 000, 500
Score: 000, 001, 000
Score: 000, 010, 000
Score: 000, 100, 000
Score: 001, 000, 000

Or not even this:
Score: 0
Score: 100
Score: 500
Score: 1000
Score: 10000
Score: 100000
Score: 1000000

So the first example is the one I want. Any ideas how to do this?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Score Format
« Reply #1 on: June 04, 2017, 03:47:19 AM »
I found it out by myself. You need to use the string format 0,0, then it will add comma automatically. The only thing is that the format will start with 00, so it will be 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, but it's not a problem if you get minimum points higher than 10. The score format will be like this:
0
100
1,000
10,000
100,000
1,000,000
10,000,000
100,000,000
1,000,000,000.

But I just discovered one very important thing using Integer on the score.
It looks like it has a max value. If you get over 2,100,000,000 points, it doesn't get higher, but add a minus before the score and start to subtract. So, using Float instead of Int is the solution.

Maybe this can be good to know for many people. :)
So, if you make a game where you get a lot of points, then you should use Float.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 987
    • View Profile
    • Fat Pug Studio
Re: Score Format
« Reply #2 on: June 04, 2017, 04:16:37 AM »
Yeah, max integer is actually 2,147,483,647. It's a really interesting question, i would have done it with an array, where every figure from the string would be an array item. I would compare the leftmost number first, if it is zero, i would go to the next one until i get to one that contains the number different than zero, i would display it, and then go on to the next set of get next loops which would fetch all numbers and commas and display them.

Of course, your solution is tons better. Btw, thanks for the max integer reminder, i forgot about that, i need to have it in mind. You can use long instead.

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • View Profile
    • Homepage
Re: Score Format
« Reply #3 on: June 04, 2017, 05:11:30 AM »
Quote
Of course, your solution is tons better. Btw, thanks for the max integer reminder, i forgot about that, i need to have it in mind. You can use long instead.

You're welcome! :)

I'm very happy that I discovered this so early in the development, so I don't have to change that much. :D
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no