How do I Associate 3 Letter Names with High scores

0 favourites
  • 14 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • So Following a tutorial I found I managed to set up local storage and an array. I also Have implemented a way for the user to select three letters for their name, akin to old arcade games.

    So now I need a way to associate each name with their respective score.

    I would imagine I need to increase the array to a height of 2. But at that point I'm lost I don't know how to make sure the name stays with their respective score.

    http://i.imgur.com/GvWXRUG.png

  • 2 things comments i like to give.

    1/

    Localstorage needs time to upload en download things. You can use downloaded data AFTER they are downloaded. Not during or so. Meaning: after a 'get item' you need a condition 'on get complete'. Then you can use the data.

    I am sure that step was also in the tut. Look for it.

    2/

    You can simplify the whole thing by using a dictionary. Store the username in a key (check first for existing). Store de score in the value that goes with the key. Easy to handle. Easy to debug, the contents of the dictionary show in the debugger. And they always wil be a not seperatable pair.

    Now, instead of adding a million keys to the local storage, you add just 1 key to it, give it a name you like, and store the json of the dictionary in its value.

    You can ofcourse also write the array you use the same way in the local storage. (1 key, 1 value as json) But the array is in your case (only 1 text + just 1 number) just that little to complicated for what it is.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 2 things comments i like to give.

    1/

    Localstorage needs time to upload en download things. You can use downloaded data AFTER they are downloaded. Not during or so. Meaning: after a 'get item' you need a condition 'on get complete'. Then you can use the data.

    I am sure that step was also in the tut. Look for it.

    2/

    You can simplify the whole thing by using a dictionary. Store the username in a key (check first for existing). Store de score in the value that goes with the key. Easy to handle. Easy to debug, the contents of the dictionary show in the debugger. And they always wil be a not seperatable pair.

    Now, instead of adding a million keys to the local storage, you add just 1 key to it, give it a name you like, and store the json of the dictionary in its value.

    You can ofcourse also write the array you use the same way in the local storage. (1 key, 1 value as json) But the array is in your case (only 1 text + just 1 number) just that little to complicated for what it is.

    Thanks for the reply, Unfortunately I've never worked with a dictionary in construct 2 before. I'm not sure how it works.

    The only reason I made it this far with the array was due to a video tutorial lol

  • How do I add a high score onto game over screen?

    example2.capx

    Thank you so much, However When I import this into my Construct 2 and Hit play I can increase the score but the name portion is not working at all It just shows a full line of 0's

    I havent changed the code at all I just wanted to see it in action but somethings going screwy on my end

  • Okay So I figure I'll upload shots of the entire page so you guys can see what I'm working with.

    Event Sheet

    http://i.imgur.com/KyOKA7O.png

    http://i.imgur.com/2Tmbb47.png

    http://i.imgur.com/sXiuuh5.png

    (A Note on the second and third screenshot)

    To do my letter selection I have 3 sprites one for each letter space.

    Then for each letter I have a code that checks which animation frame its on and corresponds that frame to a letter of the alphabet.

    So I probably made that WAY harder then it needed to be. so if there's a way to make that whole section of 78 lines of code shorter please. I feel really dumb for only being able to come up with this monstrosity.

    Layout

    http://i.imgur.com/U6MEbor.png

    I apologize as I can not upload the capx Although I know it would make this much easier. I'm working with someone who really doesn't want this on the internet until it's done

  • example3.capx

  • example3.capx

    Almost Perfect I noticed a bug this created in my game and also found it present in yours.

    If two scores on the high score board are the same it edits them both

    And also For whatever reason even though (As far as I can tell) I followed the code exactly. My Names erase every time i get to the high score board are replaced with 0's

  • If two scores on the high score board are the same it edits them both..

    fixed.capx

    And also For whatever reason even though (As far as I can tell) I followed the code exactly. My Names erase every time i get to the high score board are replaced with 0's

    I can not help you without capx...just delete all unnecessary parts of code,replace sprites.. or incorporate

    your code in my capx...

  • > If two scores on the high score board are the same it edits them both..

    >

    fixed.capx

    > And also For whatever reason even though (As far as I can tell) I followed the code exactly. My Names erase every time i get to the high score board are replaced with 0's

    >

    I can not help you without capx...just delete all unnecessary parts of code,replace sprites.. or incorporate

    your code in my capx...

    Alright Here's the Capx

    Thanks again for your help

    Capx

  • I followed the code exactly. My Names erase every time i get to the high score board are replaced...

    almost

    On start of "Score" Layout you save Array to "hiScore" LocalStorage...

    On pressed "Space" you save Array to "hiscore" LocalStorage...

    "hiScore"?"hiscore"

    also you need loop..Array for each X element...to set curX(on "Start" Layout)

    version 0.41.capx

  • > I followed the code exactly. My Names erase every time i get to the high score board are replaced...

    >

    almost

    On start of "Score" Layout you save Array to "hiScore" LocalStorage...

    On pressed "Space" you save Array to "hiscore" LocalStorage...

    "hiScore"?"hiscore"

    also you need loop..Array for each X element...to set curX(on "Start" Layout)

    version 0.41.capx

    I must of missed that haha. and thanks for the fixed Capx Weirdly enough though even the one you sent me is changing all of the names to 0.

  • Woop never mind I managed to fix it by clearing the array and starting the game over once cleared

  • > I followed the code exactly. My Names erase every time i get to the high score board are replaced...

    >

    almost

    On start of "Score" Layout you save Array to "hiScore" LocalStorage...

    On pressed "Space" you save Array to "hiscore" LocalStorage...

    "hiScore"?"hiscore"

    also you need loop..Array for each X element...to set curX(on "Start" Layout)

    version 0.41.capx

    Hey there so everything seems to be going swimmingly minus one thing say top score is 500, and second score is 200 If someone scores 300-400 it does not prompt them for their name

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