TGC Codebase Backup



Real Fire by Richard Davey

25th Sep 2003 19:45
Summary

Coded by S. Lintula (sasu@dpoy.vip.fi) and optimised by R. Davey. Based on the fire code from Snippets Vol 3, this is a very nice piece of work indeed! Change the number of flames/



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `	------------------------------------------------------------------------
`	Real Fire                                 DarkForge Snippet (11/10/2000)
`	------------------------------------------------------------------------
`	Coded by S. Lintula (sasu@dpoy.vip.fi) and optimised by R. Davey
`	Based on the fire code from Snippets Vol 3, this is a very nice piece of
`	work indeed! Change the number of flames/sparks created per frame.

set display mode 320,240,16

hide mouse
sync rate 0
sync on 

create bitmap 1,320,60 

`	Number of flames to create per frame

flames = 50
sparks = 6

do

	for n=0 to flames

`		Draw the flame

`		Traditional red flames
		ink rgb(255,63,0),0

`		Green flames
`		ink rgb(64,255,0),0

`		Blue vapour
`		ink rgb(0,64,255),0

		x=rnd(319)
		line x,59,x+rnd(4),59 
	
`		Draw hole between flames 
	
		ink 0,0
		x=rnd(319) 
		line x,59,x+rnd(1),59 

	next n

`	Draw the sparks

	ink rgb(255,255,255),0
	for n=0 to sparks

		dot rnd(319),59-rnd(2)

	next n

	blur bitmap 1,1

`	The following code addresses an issue with the blur command shifting
`	the blur effect to the right each time. This repositions the flame.

	if frame = 1
		copy bitmap 1,1,0,319,59,1,0,0,318,59
		frame = 0
	else
		inc frame 
	endif
	
	copy bitmap 1,0,1,319,59,1,0,0,319,58
	copy bitmap 1,0,0,319,55,0,0,60,319,239

	sync

loop