The QBasic Site

[ HOME | PROGRAMS | MY PROGRAMS | UPHO | TIPS | TUTORIALS | SUBMIT | LINKS | E-MAIL ]

My programs

The source code, and explanation to Big flame


Here is the whole source code to Big flame. I will not explain in detail what every line does. If there is something you don't understand or something you want me to describe more, e-mail me.

RANDOMIZE TIMER - Randomize the timer so it doesn't choose the same number as before
SCREEN 13 - Change the screen mode to 320 x 200, 256 color
FOR b = 1 TO 63 - Makes the variable b increase by one until it's 63
OUT 968, b - Defines the palette number to change (from 1 to 63)
OUT 969, b - Change the red value (from 0 to 63)
OUT 969, b - Change the green value (from 0 to 63)
OUT 969, b - Change the blue value (from 0 to 63)
OUT 968, b + 63 - Defines the palette number to change (from 64 to 126)
OUT 969, 63 - Change the red value (from 0 to 63)
OUT 969, b - Change the green value (from 0 to 63)
OUT 969, 0 - Change the blue value (from 0 to 63)
OUT 968, b + 126 - Defines the palette number to change (from 127 to 189)
OUT 969, 64 - b - Change the red value (from 0 to 63)
OUT 969, 64 - b - Change the green value (from 0 to 63)
OUT 969, b - Change the blue value (from 0 to 63)
OUT 968, b + 189 - Defines the palette number to change (from 190 to 252)
OUT 969, 63 - Change the red value (from 0 to 63)
OUT 969, 0 - Change the green value (from 0 to 63)
OUT 969, 63 - Change the blue value (from 0 to 63)
NEXT b - Jumps up to the FOR command until it's 63
DIM SHARED flame(64, 40) AS INTEGER - Makes a matrix that is in x-length 64 and in y-length 40. And it's also sets the matrix as an integer.
DO - Makes a loop
FOR x = 1 TO 62 - Makes the variable x increase by one until it's 62
flame(x, 40) = CINT(RND * 251) - Puts a randomized integer number (max 251) in the flame matrix
NEXT x - Jumps up to the FOR command until it's 62
FOR x = 1 TO 63 - Makes the variable x increase by one until it's 63
FOR y = 39 TO 0 STEP -1 - Makes the variable y decrease by one until it's 0
IF flame(x, y + 1) > 5 THEN flame(x, y) = (flame(x - 1, y) + flame(x, y + 1) + flame(x + 1, y + 1)) / 3 - 2.2 - This part makes the flame effect: If the flame matrix is over 5 then take the left, down and rightdown pixels and make a medium number and also decrease this medium with 2.2
NEXT y - Jumps up to the FOR command until it's 0
NEXT x - Jumps up to the FOR command until it's 63
FOR y = 0 TO 38 - Makes the variable y decrease by one until it's 38
FOR x = 0 TO 63 - Makes the variable x decrease by one until it's 63
IF flame(x, y) < 0 THEN flame(x, y) = 0 - If flame matrix less then zero then flame matrix is zero
LINE (x * 5, y * 5)-(x * 5 + 4, y * 5 + 4), flame(x, y), BF - This is the secret code to make the flame to a BIGFLAME: It makes a filled box (BF) with the flame color and it's 5*5 pixels big. So, the flame matrix is in x-length 64 and in y-length 40. That makes the x-length 64 * 5 = 320 and in y-length 40 * 5 = 200.
NEXT x - Jumps up to the FOR command until it's 63
NEXT y - Jumps up to the FOR command until it's 38
WAIT &H3DA, 8 - Waits for electronbeam (verticle retrace)
WAIT &H3DA, 8, 8 - Waits for electronbeam (verticle retrace)
LOOP UNTIL INKEY$ <> "" - Loops from DO until any key is pressed
ner = 252 - Sets the ner variable to 252
DO - Makes a loop
FOR x = 1 TO 62 - Makes the variable x increase by one until it's 62
flame(x, 40) = CINT(RND * ner) - Puts a randomized integer number (max ner) in the flame matrix
NEXT x - Jumps up to the FOR command until it's 62
ner = ner - 10 - Decreases the ner variable with 10
IF ner <= 0 THEN ner = 0 - If the ner variable is less then zero then ner variable is zero
FOR x = 1 TO 63 - Makes the variable x increase by one until it's 63
FOR y = 39 TO 0 STEP -1 - Makes the variable y decrease by one until it's 0
flame(x, y) = (flame(x - 1, y) + flame(x, y + 1) + flame(x + 1, y + 1)) / 3 - 2.2 - This part makes the flame effect: If the flame matrix is over 5 then take the left, down and rightdown pixels and make a medium number and also decrease this medium with 2.2
NEXT y - Jumps up to the FOR command until it's 0
NEXT x - Jumps up to the FOR command until it's 63
FOR y = 0 TO 38 - Makes the variable y increase by one until it's 38
FOR x = 0 TO 63 - Makes the variable x increase by one until it's 63
IF flame(x, y) < 0 THEN flame(x, y) = 0 - If flame matrix less then zero then flame matrix is zero
LINE (x * 5, y * 5)-(x * 5 + 4, y * 5 + 4), flame(x,y), BF - This is the secret code to make the flame to a BIGFLAME: It makes a filled box (BF) with the flame color and it's 5*5 pixels big. So, the flame matrix is in x-length 64 and in y-length 40. That makes the x-length 64 * 5 = 320 and in y-length 40 * 5 = 200.
NEXT x - Jumps up to the FOR command until it's 63
NEXT y - Jumps up to the FOR command until it's 38
WAIT &H3DA, 8 - Waits for electronbeam (verticle retrace)
WAIT &H3DA, 8, 8 - Waits for electronbeam (verticle retrace)
f = 0 - Sets the f variable to zero
FOR x = 1 TO 63 - Makes the variable x increase by one until it's 63
FOR y = 39 TO 0 STEP -1 - Makes the variable y decrease by one until it's 0
IF flame(x, y) <= 0 THEN f = f + 1 - If flame matrix is/less then zero then increase f variable by one
NEXT y - Jumps up to the FOR command until it's 0
NEXT x - Jumps up to the FOR command until it's 63
LOOP UNTIL f > 2400 - Loops from DO until the f variable is over 2400
SCREEN 0 - Sets the screen to mode 0 (text)
WIDTH 80 - Makes the width of the text 80 columns
CLS - Clear the screen
PRINT "By: Daniel Hedsén (Quant)" - Prints the text
PRINT "E-mail: dh@dataphone.se" - Prints the text
PRINT - Jump one row
PRINT "Visit: The Qbasic Site" - Prints the text
PRINT "http://hem.passagen.se/hedsen" - Prints the text
END - Ends the program

Back



This page is made by Daniel Hedsén (Quant)
Updated: 97.11.05