Decimal WebStorage High-Score

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

    I finally managed to make my game keep the highscore. Alas, now I am facing a different problem. The point of the game is to survive as long as you can. Because of this, the score is measured by time being alive. So your score is your time. The problem arises when the player's time is 4.8 secs and the HighScore only captures 4. In a fast paced game like mine, these 0.8 seconds can mean a lot and I would like to know a way to make the highscore show the decimal aside from the round number.

    Any ideas will do

    thanks!

  • Multiply by 10 -> SAVE -> LOAD -> divide by 10 -> display.

  • I know this will sound like a silly question but, have you tried NOT rounding the number? You're probably using int() to convert from text or something.

    If you want a specific number of decimal places rather than all of them (which is a lot) the formula is round(Num*N)/N, where N is 1 followed by a number of zeroes equal to the numberof decimal places you want to keep (1 for no decimal places, 10 for 1 decimal place, 100 for 2 decimal places, etc)

  • Hey!

    So this is what it says at the moment

    int(WebStorage.LocalValue("HighScore"))

    I tried putting *1)/100 but it underlined the * saying that it's not working. I also tried using round instead of int but no luck there either

  • Read my reply again. When you use int() it will truncate to an integer and integers don't have decimals. What you want is a float

    Use float() instead, so round(float(value)*10)/10 will give you one decimal place, replace the two 10s with 100s for 2 decimal places, etc

  • Tried it out but it created somewhat of chaos. It's showing really low numbers now, 0.03 and 0.04 respectively. It seems like it is actually dividing the results with 100.

    Suggestions?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Post what you have, probably a typo somewhere

  • Sorry! Got it working, i placed 1/100 instead of 100/100

    Thank you so much!

    You rock man!

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