11-23-2017, 05:01 PM

Code:

`_TITLE "Flame on by bplus 2017-11-23"`

' flame on.bas SmallBASIC 0.12.9 (B+=MGA) 2017-11-22

CONST xmax = 800

CONST ymax = 600

SCREEN _NEWIMAGE(xmax, ymax, 32)

_SCREENMOVE 360, 60 'adjust as needed _MIDDLE needs a delay .5 or more for me

xxmax = 200: yymax = 75 'pixels too slow

xstep = xmax / xxmax: ystep = ymax / yymax

DIM p&(300) 'pallette

FOR i = 1 TO 100

fr = 240 * i / 100 + 15

p&(i) = _RGB(fr, 0, 0)

p&(i + 100) = _RGB(255, fr, 0)

p&(i + 200) = _RGB(255, 255, fr)

NEXT

DIM f(xxmax, yymax + 2) 'fire array and seed

FOR x = 0 TO xxmax

f(x, yymax + 1) = INT(RND * 2) * 300

f(x, yymax + 2) = 300

NEXT

WHILE 1 'main fire

CLS

FOR x = 1 TO xxmax - 1 'shift fire seed a bit

r = RND

IF r < .15 THEN

f(x, yymax + 1) = f(x - 1, yymax + 1)

ELSEIF r < .3 THEN

f(x, yymax + 1) = f(x + 1, yymax + 1)

ELSEIF r < .35 THEN

f(x, yymax + 1) = INT(RND * 2) * 300

END IF

NEXT

FOR y = 0 TO yymax 'fire based literally on 4 pixels below it like cellular automata

FOR x = 1 TO xxmax - 1

f(x, y) = max((f(x - 1, y + 1) + f(x, y + 1) + f(x + 1, y + 1) + f(x - 1, y + 2)) / 4 - 5, 0)

LINE (x * xstep, y * ystep)-STEP(xstep, ystep), p&(f(x, y)), BF

NEXT

NEXT

_DISPLAY

WEND

FUNCTION max (a, b)

IF a > b THEN max = a ELSE max = b

END FUNCTION

OK ready for the turkey!

B += x