# smoke.bas

I couldn't come up with the perfect algorithm do display smoke, but this I think is my best one, though it looks really bad. As you can see I tried to simulate the way smoke might twist on it's path up. Some day I will improve this by adding more randomization and have the colors get darker at the top like they should.

RANDOMIZE TIMER
SCREEN 9, , 1, 0

FOR i = 0 TO 15
PALETTE i, i
OUT &H3C8, i
OUT &H3C9, j
OUT &H3C9, j
OUT &H3C9, j
j = j + 1
NEXT

DO
LINE (100, 0)-(250, 310), 0, BF

m = m + 1
FOR i = 0 TO 220
y = 309 - i
t = i / 10
x = SIN((t - m) * .3) * (t - (i / 5)) + 205
x1 = COS((t - m) * .3) * (t - (i / 5)) + 205
IF (x1 - x) > 0 THEN
FOR j = 0 TO ((x1 + i / 10) - x + 10) \ 2
LINE ((x - 10) + j, y)-((x1 + i / 10) - j, y), j
NEXT
ELSE
FOR j = 0 TO ((x + i / 10) - x1 + 10) \ 2
LINE ((x1 - 10) + j, y)-((x + i / 10) - j, y), j
NEXT
END IF
x = INT(RND * -i / 7) + 205
x1 = INT(RND * i / 7) + 205
PSET (x, y), 12
PSET (x1, y), 12
NEXT
k = 0
FOR i = 75 TO 160
k = k + i \ 20
LINE (100 + (i AND 1), i + k)-(250, i + k), 0, , &H4444
NEXT

PCOPY 1, 0
WAIT &H3DA, 8, 8
WAIT &H3DA, 8
LOOP UNTIL INP(&H60) = 1

Posted on Mar 17, 2009, 7:32 PM

Respond to this message

Goto Forum Home

 Response Title Author and Date You definitely captured the "cigarette smoke" swirl effect... TheBOB on Mar 17 bravo luka ličina on Mar 21 * Translation: SUPER! Did it take long to code? I add to my tutorial. Clippy on Mar 21 Not what google gave me. Ben on Mar 21