How do I make a high score system?

Hi all,

I'm adding a high score system to my game, sort of a leaderboard. I know how to save attributes and all that, and I can save the High Score easily, but here is my issue:
How do I replace a the 2nd place score with the old high score?

Example:
I have scored 120 points on my first run, now the high score is 120. On my second run I score 130 points, now my high score is 130, but my 2nd place score will not reflect 120, the previous high score.

Does anyone know how to make a leaderboard?

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    I think @uptimistik‌ made a demo for this. Or he used some that mechanic in Epic Linkage.

  • BBEnkBBEnk Member Posts: 1,764

    go to this thread and scroll down a bit you will see screen shots of my game and how I set up a high score system should help get you started.

    http://forums.gamesalad.com/discussion/62423/show-leaderboard-showing-no-items-in-adhoc-ios-7-should-show-the-leaderboard#latest

  • t.henstrand@gmail.comt.henstrand@gmail.com Member Posts: 14
    edited March 2014

    Well I'm not sure what you're doing with the yahoo.com leaderboards, but I don't want to have it externally saved, I want it to be a simple top 5 scores. I don't want the user to have to leave my app to see scores.

    EDIT: Never mind, you seem to be using game center leaderboards? I'm new to this type of thing. Any additional info would be appreciated.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2014

    Let's say game.highScore1 is your top score and game.highScore5 is your lowest high score.

    When game.score ≥ game.highScore1 change game.highScore1 to game.score Otherwise When game.score ≥ game.highScore2 change game.highScore2 to game.score Otherwise When game.score ≥ game.highScore3 change game.highScore3 to game.score Otherwise When game.score ≥ game.highScore4 change game.highScore4 to game.score Otherwise When game.score ≥ game.highScore5 change game.highScore5 to game.score

    That will change the correct high score but it won't bump the other scores down. That would take quite a bit more coding. Personally, I'd use a table for this and just bump scores down a row to fit in the new row.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • BBEnkBBEnk Member Posts: 1,764

    The example I sent you too would be the same just remove the yahoo.com thing which is actually Game Center leader boards and replace that with your saves.

  • Tatiang, how would I go about using tables to do that? Right now I basically have done what you said, but scores need to be bumped down. I've looked into the game center thing, but even if I have game center enabled, I would want a basic leaderboard built into my game.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2014

    To notify another member, be sure to include the '@' symbol before their username, like this: @tatiang.

    It's easiest done with the Release Candidate (http://forums.gamesalad.com/discussion/65354/release-candidate-0-11-0-1-is-available/p1) because of the ability to place table expressions on either side of a rule condition and the Loop over Table behavior, but without it, you would do something like this, assuming that row 1 holds the top score and row 5 the lowest in a 6 row table of integers:

    When game.score ≥ tableCellValue(tableName,1,1) Change Table Value row:6 col:1 value:tableCellValue(tableName,5,1) Change Table Value row:5 col:1 value:tableCellValue(tableName,4,1) Change Table Value row:4 col:1 value:tableCellValue(tableName,3,1) Change Table Value row:3 col:1 value:tableCellValue(tableName,2,1) Change Table Value row:2 col:1 value:tableCellValue(tableName,1,1) Change Table Value row:1 col:1 value:game.score Otherwise When game.score ≥ tableCellValue(tableName,2,1) Change Table Value row:6 col:1 value:tableCellValue(tableName,5,1) Change Table Value row:5 col:1 value:tableCellValue(tableName,4,1) Change Table Value row:4 col:1 value:tableCellValue(tableName,3,1) Change Table Value row:3 col:1 value:tableCellValue(tableName,2,1) Change Table Value row:2 col:1 value:game.score
    ...and so on.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.