Oldschool fire effect from processing

BlitzMax Forums/BlitzMax Programming/Oldschool fire effect from processing

TWH(Posted 2009) [#1]
Hi. Im having some trouble converting a sample from processing (www.processing.org) for creating the old school pixel fire effect.

My fire just doesnt travel up the screen more that 3 pixels. Ok 6 pixels it is.

The code looks correct to me, but the result is different.



Below:
My Bmax code and luis2048's FireCube (without the cube) and with a HSB to RGB function:








Edit: Updated my code. Thanks Merx!


Arowx(Posted 2009) [#2]
First guess would be that there is a rounding error going on here, this can happen when you do calculations with integers and floats or doubles, you could try:

1, making sure all variables are float or double
2. extending any values used to be float e.g. 10 -> 10.0


Arowx(Posted 2009) [#3]
Had a mess and altering the 129.0 value on this line chanes the effect...

+ fire[ calc1[x], calc5[y] ]  *32) / 129) 


For me values under 40 and greater than 35 seemed to work best!


TWH(Posted 2009) [#4]
Great! It works now. Still its very different from the processing version, maybe its because processing uses OpenGL...


Arowx(Posted 2009) [#5]
In theory they should not be although it depends on how the pixels are formatted e.g. how the bits correspond to colours RGBA ect.

Other than that it could be something to do with the calculations, e.g. a rouding error of some kind.

To really check you would have to build and run both versions for a cycle with a full debug printout and compare the values!