parkm / oldbpm

A JavaScript game where you shoot at bubbles.
0 stars 1 forks source link

Fire Chance Does Not Work with Floats #51

Closed parkm closed 10 years ago

parkm commented 10 years ago

We check for fire spread each frame so we really need small percentages, but it only really works with integers.

dgpt commented 10 years ago

Hmm, this is a predicament. Here's a snippet of how it works currently:

                var chance = randomInt(0, 100);
                if (chance <= this.fireConfig.applyChance) {

So, applyChance is an int from 0 to 100 in terms of percentage. We can do this differently, but we have a few options. I'm thinking instead of generating a randomInt, we can generate a random float rounded to the nearest x decim. places, but how much precision do we really need?

parkm commented 10 years ago

Yeah random float should work. I think two decimal places should be enough but we don't really need to round it off.