QB64 Flame On
#1
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!


Attached Files Thumbnail(s)

B += x
Reply
#2
nice effect!
I like to program in BASIC
With code that is simple and slick
I learnt it in school
And it is still cool
So it is my number one pick
Reply
#3
As I mentioned in the post under the smallbasic thread, this really brings back memories. I remember creating many versions of this fire in pure assembly language using TASM.

Anyway, this is a really cool demo and I have always loved this effect, but let me do one-up on you Bplus by sharing a modified version.

Here is a screenshot:



Since this demo contains an image, I compressed the image and code together in their own folder. So you will have to download it.


Attached Files .zip   BurningCity-v1.zip (Size: 535.59 KB / Downloads: 9)
Dedicated to empowering computer programming hobbyists, tinkerers, amateurs, and enthusiasts.
profile for Walter Whitman at Stack Overflow, Q&A for professional and enthusiast programmers


Reply
#4
Hi Walter, Very nice application! Thumbs Up

Ha, just figured out from where the graphic came, by the letters on the globe. Also something very odd about those "cracks"? in street.
B += x
Reply