DECLARE SUB fire () DECLARE SUB makeforest () DECLARE SUB treeload () RANDOMIZE TIMER ON ERROR GOTO erro DIM SHARED tree(10 * 10) ' live tree DIM SHARED tree2(10 * 10) ' burnt tree DIM SHARED tree3(10 * 10) ' fire tree 1 DIM SHARED tree4(10 * 10) ' fire tree 2 DIM SHARED forest(16, 10) CLS PRINT " FOREST.BAS by HUR(1999)" PRINT "=========================" PRINT PRINT " This program was made by HUR in Euskal Herria for the" PRINT "BASIX fanzine contest, it's a emulation of a burning forest, as this:" PRINT : COLOR 15 PRINT " the fire should spread and grow" PRINT " - each tree within 1 away from the fire, will catch fire" PRINT " - after one generation, the fire burn out, and turn to soil" PRINT " - in the next genereation it turns to a tree" PRINT " - if already a tree it stays a tree" PRINT " redraw the forest" PRINT " NOTE: With this rules the fire never ends" PRINT : COLOR 7 PRINT " Email: h20ur@yahoo.com" PRINT " WEB: http:www.geocities.com/siliconvalley/campus/9647/" PRINT PRINT " HUR has been programing in BASIC since he was 10 years" PRINT "in his old MSX (Z80 based micro). And making this program took" PRINT "to him about 2 hours, in his 486 where the mouse it doesn't work." PRINT PRINT "To exit the program press (ESC) when you get bored, OK!" PRINT PRINT "Press any key to start..."; SLEEP SCREEN 13 PALETTE 0, 65536 * 20 + 256 * 20 + 1 ' make the grass color treeload FOR x = 1 TO 320 STEP 3 ' this makes the graund leafs FOR y = 1 TO 200 STEP 2 IF INT(RND * 2) THEN PSET (x, y), INT(RND * 5) + 40 NEXT y, x makeforest LOCATE 25, 1: PRINT " ... a storm begins on the forest. "; FOR c = 1 TO 3 FOR i = 1 TO 63 PALETTE 0, 65536 * i + 256 * 20 + 1 ' make the ligthing A = INT(RND * 400) SOUND A * c + 37 + i, .05 NEXT i, c PALETTE 0, 65536 * 20 + 256 * 20 + 1 ' make the grass color forest(8, 5) = 1 LOCATE 25, 1: PRINT " now a tree is on fire... "; DO time = TIMER DO fire A$ = INKEY$ LOOP UNTIL TIMER - time > 1 OR A$ = CHR$(27)' Each generation will take 1'' IF A$ = CHR$(27) THEN SYSTEM ge = ge + 1 LOCATE 25, 1: PRINT "HUR(1999) h20ur@yahoo.com | Frame:"; ge; makeforest LOOP SLEEP erro: RESUME NEXT SUB fire FOR x = 0 TO 310 STEP 20 FOR y = 0 TO 190 STEP 20 IF forest((x + 20) / 20, (y + 20) / 20) = 1 THEN num = INT(RND * 2) + 1 IF num = 1 THEN PUT (x, y), tree3, PSET IF num = 2 THEN PUT (x, y), tree4, PSET END IF NEXT y, x END SUB SUB makeforest FOR x = 0 TO 310 STEP 20 FOR y = 0 TO 190 STEP 20 xf = (x + 20) / 20 yf = (y + 20) / 20 IF forest(xf, yf) = 1 THEN ' if the tree is burning look beside PUT (x, y), tree2, PSET: forest(xf, yf) = 4 'the burnt is dead rand = INT(RND * 8) + 1 ' which of the four will survive IF rand <> 1 AND forest(xf - 1, yf) = 0 THEN forest(xf - 1, yf) = 3 IF rand <> 2 AND forest(xf + 1, yf) = 0 THEN forest(xf + 1, yf) = 3 IF rand <> 3 AND forest(xf, yf - 1) = 0 THEN forest(xf, yf - 1) = 3 IF rand <> 4 AND forest(xf, yf + 1) = 0 THEN forest(xf, yf + 1) = 3 IF rand <> 5 AND forest(xf - 1, yf + 1) = 0 THEN forest(xf - 1, yf + 1) = 3 IF rand <> 6 AND forest(xf + 1, yf + 1) = 0 THEN forest(xf + 1, yf + 1) = 3 IF rand <> 7 AND forest(xf - 1, yf - 1) = 0 THEN forest(xf - 1, yf - 1) = 3 IF rand <> 8 AND forest(xf + 1, yf - 1) = 0 THEN forest(xf + 1, yf - 1) = 3 GOTO final END IF IF forest(xf, yf) = 0 THEN 'if the tree is live live PUT (x, y), tree, PSET END IF final: NEXT y, x FOR x = 1 TO 16 FOR y = 1 TO 10 IF forest(x, y) = 2 THEN ' if the tree is burnt live it PUT ((x - 1) * 20, (y - 1) * 20), tree, PSET forest(x, y) = 0 END IF IF forest(x, y) = 3 THEN forest(x, y) = 1 IF forest(x, y) = 4 THEN forest(x, y) = 2 NEXT y, x END SUB SUB treeload 'this makes the tree LINE (4, 0)-(0, 4), 14 LINE (4, 0)-(8, 4), 14 LINE (0, 4)-(8, 4), 14 PAINT (4, 3), 14 LINE (3, 5)-(5, 9), 15, BF FOR x = 0 TO 9 FOR y = 0 TO 4 IF POINT(x, y) = 14 THEN PSET (x, y), 46 + x IF POINT(x, y + 5) = 15 THEN PSET (x, y + 5), 39 + x NEXT y, x ' this loads the tree into a array GET (0, 0)-(9, 9), tree CLS 'this makes the burnt tree LINE (4, 0)-(0, 4), 14 LINE (4, 0)-(8, 4), 14 LINE (0, 4)-(8, 4), 14 PAINT (4, 3), 14 LINE (3, 5)-(5, 9), 15, BF FOR x = 0 TO 9 FOR y = 0 TO 4 IF POINT(x, y) = 14 THEN PSET (x, y), 16 + x IF POINT(x, y + 5) = 15 THEN PSET (x, y + 5), 18 + x NEXT y, x ' this loads the tree into a array GET (0, 0)-(9, 9), tree2 CLS 'this makes the tree burning 1 LINE (4, 0)-(0, 4), 14 LINE (4, 0)-(8, 4), 14 LINE (0, 4)-(8, 4), 14 PAINT (4, 3), 14 LINE (3, 5)-(5, 9), 15, BF FOR x = 0 TO 9 FOR y = 0 TO 4 IF POINT(x, y) = 14 THEN PSET (x, y), 37 + x IF POINT(x, y + 5) = 15 THEN PSET (x, y + 5), 39 + x NEXT y, x ' this loads the tree into a array GET (0, 0)-(9, 9), tree3 CLS 'this makes the tree burning 2 LINE (4, 0)-(0, 4), 14 LINE (4, 0)-(8, 4), 14 LINE (0, 4)-(8, 4), 14 PAINT (4, 3), 14 LINE (3, 5)-(5, 9), 15, BF FOR x = 0 TO 9 FOR y = 0 TO 4 IF POINT(x, y) = 14 THEN PSET (x, y), 39 + x IF POINT(x, y + 5) = 15 THEN PSET (x, y + 5), 37 + x NEXT y, x ' this loads the tree into a array GET (0, 0)-(9, 9), tree4 CLS END SUB