Problems with creating a high-score.

0 favourites
  • 7 posts
From the Asset Store
Create the right kind of drama with Film Scoring Tools sound library!
  • Hey everyone,

    I've been working with construct for the past couple of days and suffice to say that I am thrilled with the progress I've made. My project started as this small "man i'm bored" thingy and evolved into a potential playstore/appstore game! WOW.

    However, I still face some problems that I can't seem to solve. The biggest issue I have at this point is setting up the high score. I have followed and did everything the tutor said, but no luck. Instead of a high-score I am getting a 0 every time.

    I guess the problem lies in one of the global variables I have and the way the game controls them. For instance, the score in my game is determined in seconds. The longer the player survives the bigger the score he gets. This is determined by a global variable which is TotalTime. At the moment the player dies, another global variable, called EndTime kick in. This global variable adds TotalTime to 0, thus detecting the moment the player died. Of course, it is followed by set text EndTime.

    So, as you may see, my scoring system works, every time a player dies, he gets a small you failed - score 10,3 screen. The problem is, I can't seem to get the game to recognize the biggest value and create a high score to pursue. Any ideas?

    Thank you for all the ideas and help you guys offer, this is probably the most helpful forum I have ever seen :)

  • Not 100% sure I understand exactly what you want to do. But if I got it correct, the player have to survive for as long as possible, and the time that he survived will be the score, next game, this score should be the high score if it was higher than the former high score and so on?

    If that's the case, you need to make sure that each time you start a new game, you don't do a reset layout that reset the high score to 0. This can happen if the global variable are in the same event sheet as the game, so when you reset it, it will be whatever it was when the layout was started the first time.

    A simple way to solve this, would be to just make a object where you store the high score, and the current score that the player just made. And make the object global.

    Then after each game, you just check these values against each other, and write the high score from this object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for such a swift response.

    What type of object should this be. Any examples on how to do this? Possibly a capx?

  • It should just be a sprite, that you place outside the screen on another layout.

    Alternative, you can also just add another event sheet and include it in the current one, and just add the high score and current score as global variables there.

  • Resetting the layout is fine as long as you first store your current score in a global variable. Then at the end of the level BEFORE calling restart layout, etc... compare the CurrentScore variable to the HighScore Variable and if it is greater, store CurrentScore in HighScore. Then reset the layout.

  • Run the game in debug mode and watch your global variables.

  • Hey Everyone, sorry for the late reply.

    I think that the problem lies somewhere in the WebStorage object. I am going to literally write down what I have put into the event sheet.

    Local Key "HighScore" exists - set HighScore to int(WebStorage.LocalValue(HighScore))


    System - Set HighScore to 0

    moving further down the event sheet.

    If player collides with the enemy

    player - destroy

    Txt(score) - destroy

    set EndTime to 0 + Total Time

    Wait 1.5 secs

    Create object txt(result)(basically your score for that game)

    set txt(result) to EndTime

    Wait 0.3 sec

    Create txt(Try Again)

    Txt(Try Again) set text to "Tap here to try again"

    SubEvent to this event.

    System - If EndTime > HighScore then WebStorage set local key to "HighScore"

    Set text(HS) to HighScore

    This is basically it. Every time I play it I get the score of 0. Any ideas?

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