Skip to main content
GameDev.net gamedev.net
🔒 Locked

Math related question

Started by luxm Dec 26, 2006 at 3:53 PM 3 replies 850+ views
Original Post
luxm
luxm
Hi , i've just finished my 2nd game (its a 2d sooter) , and i have a question. I want to give a little bonus score to player based on the time spend. For example: Player #1 completes the 1st level in 40". The average score is :1200 Now , i want to give a little bonus based on time spend (less time will give higher score). final_score = average_score *..something_goes_here..*; Any ideas how to do this? keywords : score,less time = greater bonus
Driv3MeFar
Driv3MeFar
Off the top of my head, you could do something like this:

const int maxSeconds = 180;//assuming totalTime is the number of seconds the level was completed inint timeBonus = (maxSeconds - totalTime > 0) ? maxSeconds - totalTime : 0;score += timeBonus * pointPerSecond;
lone_ranger
lone_ranger
something like a:

final_score = average_score * a^(1/(kt))

choose (a,k) where a>1 && k >0 accordingly

you can have a "break point" where you set the bonus to zero,i put this function as an idea to have a non-linear bonus.
Virtus junxit, mors non separabit
mikeman
mikeman
Are the levels time-limited? If yes, you can just give the bonus according to the remaining time. If, for example, the limit for level 1 is 60'', you can do:

final_score=average_score+bonus_for_each_second*(60-player_time).

If they're not time-limited, I guess you'll have to set a limit after which the player gets no bonus. Or you can divide by the time spend like so:

final_score=average_score+max_bonus/(1+player_time)

but I'm not sure I really like this solution.
luxm
luxm
Thanks all.
This one worked for me:
final_score=average_score+max_bonus/(1+player_time)
since the levels arent time limited.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.