Final Score

Hello Guys, I’m almost finally my first game in corona sdk, but I have a little problem,I dont know how I can do a final score, In my game I have several levels and in all the level have a score, but I want to do a final score with the result of all the levels.

Please If anybody can help me with this I’ll be very grateful.

Thanks

myGlobals.finalScore = myGlobals.finalScore + level.score on each level perhaps?

funkyvisions’ way is perfectly acceptable, but if the user is allowed to replay a level then you need to account for that, otherwise the score added repeatedly for that single level.

Another way would be to have a table, and keep the scores in that. This way you can also only overwrite a level’s score if they get a higher score.

At the start of the game, set the score for each level to zero:

levelScores = {} for i = 1, numberOfLevels do levelScores[i] = 0 end

Then at the end of a level, see if the score can be stored:

if thisLevelScore \> levelScores[levelNumber] then levelScores[levelNumber] = thisLevelScore end

Then at the end of the game, add all of the scores up:

local endScore = 0 for i = 1, #levelScores do endScore = endScore + levelScores[i] end

As I say, nothing wrong with funkyvisions’ way of doing it, but this is another way to do it if you need to repeat levels (or store scores for individual levels).

Hello thanks for your help, this method works for the director class?

myGlobals.finalScore = myGlobals.finalScore + level.score on each level perhaps?

funkyvisions’ way is perfectly acceptable, but if the user is allowed to replay a level then you need to account for that, otherwise the score added repeatedly for that single level.

Another way would be to have a table, and keep the scores in that. This way you can also only overwrite a level’s score if they get a higher score.

At the start of the game, set the score for each level to zero:

levelScores = {} for i = 1, numberOfLevels do levelScores[i] = 0 end

Then at the end of a level, see if the score can be stored:

if thisLevelScore \> levelScores[levelNumber] then levelScores[levelNumber] = thisLevelScore end

Then at the end of the game, add all of the scores up:

local endScore = 0 for i = 1, #levelScores do endScore = endScore + levelScores[i] end

As I say, nothing wrong with funkyvisions’ way of doing it, but this is another way to do it if you need to repeat levels (or store scores for individual levels).

Hello thanks for your help, this method works for the director class?