0

I am developing a game where I need to sort the score based on both how many coins the player collected and how long did it take. Higher number of coins and lower time taken are better. Also number of coins has higher precedence than time.

For example, suppose player A scored 7 coins in 15.26 seconds, player B scored 5 coins in 9.73 seconds and player C scored 7 coins in 13.87 seconds. Then the leaderboard scores should be like this:

  1. player C: 7 coins in 13.87 seconds
  2. player A: 7 coins in 15.26 seconds
  3. player B: 5 coins in 9.73 seconds

How to achieve this? My personal solution is this:

  1. Multiply number of coins by a large number (>= 100,000) to get X
  2. Multiply time value by 100 to convert it to an integer Y
  3. Then calculate final score = X - Y

Is this the correct way to do this?

user3164248
  • 155
  • 3
  • 8
  • If there is nr coins = 0, you also get points? – E-Riddie Apr 24 '14 at 09:49
  • No. you must get at least 1 coin to upload score in leaderboard. – user3164248 Apr 24 '14 at 10:01
  • I am giving you a simple logic, the factor that increases points is n-nr of coins, and the factor that decreases them is t-time elapsed. So what you do is, set a specific number of score for a coin/sec, suppose 1000. Then the final score would be (1000*n)/t. – E-Riddie Apr 24 '14 at 10:14

0 Answers0