How to make a high score table?

This forum is currently in read-only mode.
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • After many long sessions and hours of tedious debugging, I'm being screwed by the simple problem of creating a high score table. I don't even want to get into details about how to move the landed troopers because it's an insane headache of (probably) sloppy code that somehow *just* manages to work.

    I found a tutorial high-score table somewhere in the forums, and although it's rudimentary it pretty much works. The trouble is when I try to adapt it to be a little slicker. Eg. If the player doesn't put any text into the input box - play a "deny" sound.

    On top of that, having the enter key pressed *while* the cursor is inside the input box (instead of only being able to press a submit button). And then there's the loading from disk and sorting the table. Ideally, I'd like to use something a little prettier than the listbox. Being no kind of game programmer, I simply do not understand hashtables and arrays (yet) but a tutorial would make for an excellent primer on how to accomplish this.

    For once, I'd like something in Construct to be actually as easy as it seems.

  • For once, I'd like something in Construct to be actually as easy as it seems.

    This one probably IS actually as easy as it seems

    Which high score table did you find on the forums? I've seen at least one, but I don't recall it working the way you're describing it, with a submit button and all. (It doesn't matter really; this is mostly for my own curiosity)

    In any case, you can check for the length of a string; something like len(EditBox.Text) might suit you well here (assuming you're using an EditBox), and simply not do anything with it if the length is equal to 0.

    As for the submit button vs. enter key issue, there's nothing stopping you from using a MouseKeyboard object to redirect the enter key. By setting the value in your high score table to left(EditBox.Text, len(EditBox.Text) - 1) when you're doing this via the enter key, you should be able to strip out the extraneous newline that would be attached to it otherwise.

    Arrays are just a collection of values, which are referenced by number. For a 1-dimensional array (an array in which only one of X, Y, or Z is greater than 1 - and this is almost always X for ease of use), think of it like a row of numbers. For example, let's say you had an array of dimensions 6,1,1. Somehow it has values assigned to it of (10, 1000, 45, 23, 9999, 2). You ask the array to return the value at position 3, and it returns "45". It's basically just counting through the list.

    For a 2-dimensional array (one in which 2 of X,Y,Z are greater than 1 - almost always just X and Y) think of it like a grid, or a chess board, or something. You ask for a value at (4,5), and it counts 4 spaces over and 5 spaces down and tells you what number's sitting in that space.

    A 3-dimensional array's just a stack of those grids or chess boards, and the Z value picks which board.

    Arrays are especially convenient, because you can simply save their current set of values to a file any time you like. Or, you can load to the array from a file, as needed. For a high score table, I'd recommend saving immediately after getting the new score on the list, and loading the array whenever you load the game (make it a global object).

    Does this answer everything?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the speedy reply.

    I've actually been toiling with arrays and through a combination of determination and experimentation have worked them out and created an actual working table.

    I'm sure if I didn't post here it would have never happened.

    Anyway. Even if my approach is probably messy and needlessly complex, it works nicely. I'll post a tutorial in a few days, if I can make it legible (especially to newcomers).

    The next trick is somehow applying some obfuscation to the saved file, such as encryption.

  • Saved arrays aren't exactly human-readable. I mean, text is, but numbers are kept as hex-values. Most people won't bother, I'd guess.

    If you're very worried, something as simple as subtracting them from an arbitrarily large number might work well.

  • I just used an ini file.

    Top 5 scores stored as

    [5]

    name="asdf"

    score=10

    [4]

    ...

    etc...

  • I just used an ini file.

    Top 5 scores stored as

    [5]

    name="asdf"

    score=10

    [4]

    ...

    etc...

    If you don't mind, could you please provide an example .cap file on how you did this? Thanks.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)