I have a game where there are levels and a certain amount of time to complete the level. If they finish in a certain amount of time they get 5 stars and the longer it takes the less stars they get. How is the best way to program this. I have looked into to Ego some, but I dont really understand it. I appreciate anyone who can help! [import]uid: 82872 topic_id: 28960 reply_id: 328960[/import]
Hello there. I would help you further in how to do scoring… just email me at sebitttas[@]gmail.com
I can help you understand ego, and how to use it for scores

S [import]uid: 17058 topic_id: 28960 reply_id: 116600[/import]
Take the minimum time to complete the level and the maximum amount of time to complete the level and determine the difference. Divide that difference by the number of stars and you could do something like:
maxtime = 60
mintime = 30
difftime = maxtime - mintime
maxstars = 5
timestep = difftime / maxstars
if levelPlayTime \> mintime+timestep then
numstars = 5
elseif levelPlayTime \> mintime+(timestep\*2) then
numstars = 4
elseif levelPlayTime \> mintime+(timestep\*3) then
numstars = 3
elseif levelPlayTime \> mintime+(timestep\*4) then
numstars = 2
else
numstars = 1
end
Of course that’s a lot of code, but it demonstrates what you want to do. Let’s now do it with just math.
maxtime = 60
mintime = 30
maxstars = 5
timestep = math.floor((maxtime - mintime) / maxstars)
numstars = 5 - math.floor((levelPlayTime - mintime) / timestep)
or some such logic. [import]uid: 19626 topic_id: 28960 reply_id: 116614[/import]
use what robmiracle says above to get the amount of stars one, but then use ICE to store that value so it stays on the device, such as if you got 4 stars on level 1 then you go do something else, come back to your device and when you load it it still shows that you have 4 stars on level 1, if you need any help with ice just post a reply on this page and i can help you.
download ICE here - http://developer.coronalabs.com/code/ice
–boxie [import]uid: 113909 topic_id: 28960 reply_id: 116615[/import]
I appreciate everyone who is helping me, I will start coding tonight and I will let you know if I have anymore questions. [import]uid: 82872 topic_id: 28960 reply_id: 116619[/import]