Анимация горящих колец

Очень простой пример симуляции пламени.
Платформы: Windows , Linux.
Автор: неизвестен.

Эффект пламени

Dim As Integer c,i,n,r,x,p(255)
Dim As Ubyte Ptr a,b
Dim As Double t,d

' flame palette
For i = 0 To 63                         
    p(i) = Int(i/4) + Int(i/4) Shl 8 + Int(i/4) Shl 16  ' smoke
    p(i+64) = 16+int(3*i/4) + (16+int(i/4)) Shl 8 + 16 Shl 16

    p(i+128) = 63 + (32+int(i/2)) Shl 8 + 16 Shl 16

    p(i+192) = 63 + 63 Shl 8 + (16+int(3*i/4)) Shl 16

Next


Screen 13

Palette Using p(0)
a = Imagecreate(320,200)
b = Imagecreate(320,200)

Circle a,(92,90),40,1

Circle a,(160,90),40,1

Circle a,(228,90),40,1

Circle a,(126,140),40,1

Circle a,(194,140),40,1


t = Timer : d = t
While inkey$ = ""
    For i = 4+320*50 To 4+320*180

        If a[i] = 1 Then

            b[i] = rnd*200+56

        End If

    Next


    x = 10*320+54

    For r = 0 To 170

        For i = x To x+250

            c = ((b[i-1]+b[i]+b[i+1] + b[i-320])/4)
            If c>2 Then c = c - 3 Else c = 0 End If

            b[i-320] = c
        Next

        x = x+320 
    Next

    Put (0,0),b,Pset

    n += 1

    While Timer - t < 0.02 : Wend       ' 50 fps
    t = Timer

Wend


Locate 2,2 : Color 255

Print Int(n/(timer-d)+0.5); " fps"
Sleep