Leaderboards

Working on leaderboard(s) for all of the current and upcoming games…I was originally storing the (5) high scores in a text file on the server. It felt more portable to me. And since I was only needing to hang on to a few scores at a time, it was pretty easy to implement in this way. But now with all-time leaderboards, I’m moving to keep them in a database. Makes for easier retrieval and sorting.

And more importantly, the scores that are fed into the machines are “reset” each month. Selfishly, I wanted to be able to get my own high scores to show up on the machines (hey, I built these damn games, you’d think I would be good enough to regularly do it, but there are some people who are consistently better than I am – I’m looking at you MAT and AAA…) But I think it’ll also keep things fresh, by allowing new people to see their scores/initials in the game high scores.

So the pseudo-query looks something like this:

SELECT
  score, name
FROM
  game
WHERE
  MONTH(datetime) = [current month] AND YEAR(datetime) = [current year]
ORDER BY
  score DESC
LIMIT
  5

Leave a Reply

Your email address will not be published. Required fields are marked *