Smooth progress bar and strange numbers

0 favourites
  • 3 posts
From the Asset Store
Strange Game Ambient Loops 3 - This is the third volume in the Strange Game series.
  • Hey all,

    Making a simple HP and damage system, ran into a few issues

    Running release 178 (64bit) and tried this on node-webkit, chrome and phonegap

    PROGRESS BARS

    • Ignore Z-Order and Layers, Always show on top
    • CSS Style wont work, setting colour or color to red is ignored
    • Some CSS Style properties will default the progress bar to a green and grey CSS style

    I am also making a DPS (Damage Per Second) System, and want the HP bar to decline smoothly, instead of just having a chunk of it disappear every second.

    To do this I created a system event so that every 0.1 seconds it will subtract 1/10th of the DPS from the Health

    This works fine but it gives strange numbers to the HP, instead of being:

    99.9, 99.8, 99.7 etc, it is showing numbers like

    99.90000000054, 99.80000000023, 99.7000000064 etc

    I could just hide the number using floor, ceil or round but it is causing issues with timing, I calculated it to take 10 seconds to kill an enemy of a certain HP with my level of DPS, and it took an extra 6 seconds because of the strange fractions.

    And if i set the DPS timer to fire every 0.01 seconds and subtract (DPS / 100) it looks even smoother but the time calculation becomes even more unreliable and HP shows numbers like 99.999999999999754

    Heres the CAPX

    http://s000.tinyupload.com/index.php?fi ... 2955337379

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Didnt realise i was using an outdated version

    Upgraded to 184 X64 but it didnt fix anything

    EDIT:

    Got more time to read into it all after work

    [quote:3ilaue2t]Form controls are actual HTML elements floating above the game canvas in the HTML page. Therefore, nothing can be displayed on top of a form control, apart from other form controls.

    So that answers them ignoring z-order and layers, looks like they are pretty useless for the most part so ill just use this tutorial

    https://www.scirra.com/tutorials/449/cr ... -healthbar

    As for the strange numbers appearing, I found this example to remove the unwanted numbers past decimal points instead of just hiding them by rounding off to a whole number, so hopefully that will help

    https://www.scirra.com/tutorials/179/de ... in-a-float

    Hopefully one day the progress bar gets better customizability instead of the need to manually create your own, and the ability to round off numbers and keep numbers past the decimal would be great.

  • These are standard floating point rounding errors for working with computers. You have to round our truncate on your own. It is not a C2 problem, and you should be triggering runs based on ranges instead of exact values. If progress is greater than our equal to whatever, for instance.

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