'=========================================================================== ' Subject: FAST FIRE EFFECT Date: 06-29-98 (00:08) ' Author: Matt Gulden Code: QB, QBasic, PDS ' Origin: www.thrillhaus.com/basic.html Packet: GRAPHICS.ABC '=========================================================================== ' QBFiRE.BAS by Matt Gulden (aka Folter) -- mattg@thrillhaus.com ' This file originated at www.THRILLHAUS.com ' Fastest QB fire! Probably... ' Compile to EXE and it's like 5 times faster. The EXE should be included in ' the zip. If not, grab it at www.THRILLHAUS.com/source/qbfire.zip ' My favorite, at least :) ' ' A couple of reasons of why it's so fast: ' ' 1) Doesn't PSET, it POKEs to video memory ' To do this you only need to DEF SEG = &HA000, then to draw the ' pixel, just do POKE Y * 320 + X, COLOUR. ' 2) Doesn't read from the screen. Instead it stores the fire in an ' array and reads from that. Reading from the screen is SLOW. ' 3) Uses integer division... Use a backslash instead of a frontslash ' 4) Screen is modified to 320x100 so the fire looks bigger. ' ' This is PUBLIC DOMAIN! But pleace give me credit if you ' modify and redistribute this or make a demo out of it or whatever! DEFINT A-Z DECLARE SUB pal (a, r, g, b) DEF SEG = &HA000 CONST StartX = 0 CONST EndX = 319 CONST StartY = 40 CONST EndY = 105 DIM fire(StartX TO EndX, StartY TO EndY) AS INTEGER SCREEN 13 ' Modify screen to 320x100 OUT &H3D4, 9 OUT &H3D5, 3 ' Set kewl fire colors FOR num = 0 TO 63: pal num, num, num \ 2, 0: NEXT FOR num = 64 TO 127: pal num, 63, num \ 2, 0: NEXT FOR num = 128 TO 191: pal num, 63, 63, num \ 2 + 31: NEXT FOR num = 192 TO 255: pal num, 63, 63, 63: NEXT COLOR 191 LOCATE 2, 13: PRINT "Folter's QBFiRE" WHILE INKEY$ = "" ' Creates line of randomly colored pixels on bottom of screen. ' This will be our "seed" line. x = 0 DO x = x + RND * 10 IF x > 319 THEN x = 319 fire(x, EndY - 1) = (RND * 250) + 50 LOOP UNTIL x = 319 FOR x = StartX TO EndX FOR y = StartY TO EndY - 2 ' Gets the average of 3 pixels and decrements, and plots pixel IF x > 0 AND x < 319 THEN PixelColor = (fire(x - 1, y + 1) + fire(x, y + 1) + fire(x + 1, y + 1) + fire(x + 1, y + 2)) \ 4 - 3 ELSEIF x = 0 THEN PixelColor = fire(x + 1, y) ELSEIF x = 319 THEN PixelColor = fire(x - 1, y) END IF IF PixelColor < 0 THEN PixelColor = 0 fire(x, y) = PixelColor IF y < 100 THEN POKE y * 320 + x, PixelColor END IF NEXT NEXT WEND DEF SEG SCREEN 0 WIDTH 80 PRINT "QBFiRE by Folter" PRINT "Have you ever seen a better fire effect done in QuickBasic?" PRINT "I'll answer that for you... No, you haven't ;)" PRINT PRINT "Hehe..." PRINT PRINT "QBFiRE by" PRINT "Matt Gulden (aka Folter) -- mattg@thrillhaus.com" END SUB pal (a, r, g, b) OUT 968, a OUT 969, r OUT 969, g OUT 969, b END SUB