Code archives/Graphics/Particle Text

This code has been declared by its author to be Public Domain code.

Download source code

Particle Text by TWH
(Posted 18 years ago)
Uses code from these (all included in codeboxes below):

'Particle Arrays by bradford6 http://www.blitzbasic.com/codearcs/codearcs.php?code=1572
'Vectorfont by Mark Incitti -- check the Tempest sample
'SplitString function by Perturbatio http://www.blitzbasic.com/codearcs/codearcs.php?code=1890
' Besenham's LineDraw routine (integer math only) by ImaginaryHuman
' http://www.blitzbasic.com/codearcs/codearcs.php?code=1465


Still needs a bit of work ;)

The particles are not spread over the vectortexts lines properly. ->You have to increase the particle count to write a longer string.

.. and the vectortext shouldn't get its size and string from the TParticleControl

Copy paste from these codeboxes or check the 2. post in this thread for a .ZIP

codewiki.no/forum

'Ive split the program into 4 files:
'particle_text.bmx
'tiniparser.bmx
'vectorfont.bmx
'tparticlelinedraw.bmx
It also reads settings from "tweakme.ini" - check the last codebox.

particle_text.bmx

'Particle Arrays by bradford6 <a href="/codearcs/codearcs.php?code=1572" >Particle Arrays</a>
'Vectorfont by Mark Incitti -- check the Tempest sample
'SplitString function by Perturbatio <a href="/codearcs/codearcs.php?code=1890" >Read/Write INI File (BMX)</a>
'Besenham's LineDraw routine (integer math only) by ImaginaryHuman <a href="/codearcs/codearcs.php?code=2287" >Besenham's LineDraw routine</a>
'SuperStrict


Framework BRL.GLmax2d
Import BRL.GLMAX2D
'Framework BRL.D3D7Max2D
'Import BRL.D3D7Max2D
Import BRL.Standardio
Import BRL.TextStream
Import BRL.FileSystem
Import BRL.Map
Import BRL.LinkedList
Import BRL.Retro
Import "tiniparser.bmx"
'Import "tparticlelinedraw.bmx"
Import "vectorfont.bmx"
Global resx:Int = 640, resy:Int = 480
'SetGraphicsDriver D3D7Max2DDriver()
SetGraphicsDriver GLMax2DDriver()
AppTitle = "Particle Text"
Graphics resx,resy,0 
SeedRnd(MilliSecs()) 
AutoMidHandle(True) 

Local control:TParticleControl = TParticleControl.Create(resx, resy)
Local font:TVectorFont = New TVectorFont 



Local sx:Int=0
Local sy:Int=0
Local ex:Int=resX/2
Local ey:Int=resY/2
Local lastSec:Long = MilliSecs()
Local frames:Int = 0
Local fps:Int = 0
' * * * <MAIN_LOOP>
Repeat
	Cls
	If KeyHit(KEY_R) control.loadValues()
	
	If MouseHit(1)
		sx=MouseX()
		sy=MouseY()
	EndIf
	If MouseHit(2)
		ex=MouseX()
		ey=MouseY()
	EndIf
	
	control.spawnx = MouseX()
	control.spawny = MouseY()
	control.draw()
	
	'control.line(sx,sy,ex,ey,2)
	
	font.DrawParticleString(control,control.textline1,resx/2-resx/3, resy/2-resy/3,control.textsize)
	font.DrawParticleString(control,control.textline2,resx/2-resx/3, resy/2,control.textsize)
	
	SetColor 255,255,0 
	DrawText("fps: " +fps,RESX-100,0) 
	DrawText("particles: " +TParticle.pcount,0,0) 
	DrawText("press R to reload tweakme.ini", 0, 30)
	TParticle.pcount = 0
	
	frames:+1
	If lastSec < MilliSecs()
		fps = frames
		frames = 0
		lastSec = MilliSecs()+1000
	EndIf
		
	Flip
	Delay 16
Until KeyDown(KEY_ESCAPE) Or AppTerminate()
End



tiniparser.bmx

Import BRL.Standardio
Import BRL.TextStream
Import BRL.FileSystem
Import BRL.Map
Import BRL.LinkedList
Import BRL.Retro


Type TIniFileParser
	Field filelocation:String 
	Field fileDataStream:TStream
	
	Field mapParsedData:TMap
	
	Method New()
		mapParsedData = CreateMap()
	End Method
	
	'load filename as current dataStream
	Method loadFile(fileLocation:String)
	  Local stream:TStream=ReadFile(fileLocation)
	  If Not stream 
		RuntimeError "could not open file:"+fileLocation
	  Else
		Print "file loaded"
	  EndIf
	
	  fileDataStream = stream
	End Method
	
	'put all variables in a hashmap
	Method parseFile()
		If Not fileDataStream 
			RuntimeError "no file loaded"
		Else
			Local num_lines:Int=0
		  	SeekStream(fileDataStream, 0)
		  	While Not Eof(fileDataStream )
		   		num_lines:+1
		    		Local line:String = ReadLine(fileDataStream )
				Local list:TList = SplitString(line, "=")
				If list <> Null
					Local key:String = String( list.ValueAtIndex(0) )
					Local value:String = String( list.ValueAtIndex(1) )
					MapInsert(mapParsedData, key, value)
				EndIf
			   
			  Wend
		  Print "lines parsed:"+num_lines
		EndIf
		
	End Method
	
	'retrieve variable from hashmap
	Method getVariable:String( varName:String )
	  Local retVal:String =String( MapValueForKey(mapParsedData, varName) )
	  If Not retVal Then Return "null"
	  Return retval
	End Method
	

	'free stream resources
	Method free()
		CloseStream(fileDataStream)
	End Method
End Type


Function SplitString:TList(inString:String, Delim:String)
	Local tempList : TList = New TList
	Local currentChar : String = ""
	Local count : Int = 0
	Local TokenStart : Int = 0
	
	If Len(Delim)<1 Then Return Null
	
	inString = Trim(inString)
	
	For count = 0 Until Len(inString)
		If inString[count..count+1] = delim Then
			tempList.AddLast(inString[TokenStart..Count])
			TokenStart = count + 1
		End If
	Next
	tempList.AddLast(inString[TokenStart..Count])	
	Return tempList
End Function



'vectorfont.bmx
Import brl.Retro
Import "TParticleLineDraw.bmx"

Type bbdigit
	Field x1#,y1#,x2#,y2#
End Type


'Test()

Function Test()
	Local font:TVectorFont = New TVectorFont 
	Graphics 800,600,0
	
	Local sc# = 3.0
	Local dir = 1

	While Not KeyHit(key_escape) 

	Cls
	sc = sc + .1*dir
	If sc > 10 Or sc < 1 Then dir = -dir
	font.DrawString(" !"+Chr$(30)+"#$%&'()*+,-./",400-sc*40,200-sc*15,sc)
	font.DrawString("0123456789:;<=>?",400-sc*40,225-sc*10,sc)
	font.DrawString("@ABCDEFGHIJKLMNO",400-sc*40,250-sc*5,sc)
	font.DrawString("PQRSTUVWXYZ[\]^_",400-sc*40,275+sc*5,sc)
	font.DrawString("`abcdefghijklmno",400-sc*40,300+sc*10,sc)
	font.DrawString("pqrstuvwxyz{|}~~" ,400-sc*40,325+sc*15,sc)
	Flip
	
	Delay 16+sc*5
	Wend

End Function 


Type TVectorFont
	Field letterlen[128]
	Field letters:bbdigit[128,8]
	
	Method New()
		SetUpVectorFont()
	End Method
	
	Method SetUpVectorFont()
		RestoreData letterdata
		
		Local np,t,s
		
		For t = 0 To 127
			letterlen[t] = -1
		Next
		
		For t = 32 To 127
			ReadData np	'number of lines in letter (max 6)  x1,y1, x2,y2
			letterlen[t] = np-1
			For s = 0 To letterlen[t]
				letters[t,s] = New bbdigit
				ReadData letters[t,s].x1 'move basic DATA into an array
				ReadData letters[t,s].y1
				ReadData letters[t,s].x2
				ReadData letters[t,s].y2
			Next
		Next
	End Method 
	
	Method DrawDigit(d,xd,yd,sc#)
		Local t
	'	If d > 32 And d < 128
	'		If letterlen[d] > -1
				For t = 0 To letterlen[d]
					DrawLine letters[d,t].x1*sc+xd,letters[d,t].y1*sc+yd,letters[d,t].x2*sc+xd,letters[d,t].y2*sc+yd
				Next	
	'		EndIf
	'	EndIf
	End Method 
	
	
	Method DrawString(st$,xd,yd,sc#) 'string, x, y, scale
		Local s,d,ln,t
		
		ln = Len(st$)
		For s = 0 To ln-1
			d = Asc(Mid$(st$,s+1,1)) 'get a diget
	'		If d > 32 And d < 128
	'			If letterlen[d] > -1
					For t = 0 To letterlen[d] 'draw all its lines.
						DrawLine letters[d,t].x1*sc+xd+sc*5*s,letters[d,t].y1*sc+yd,letters[d,t].x2*sc+xd+sc*5*s,letters[d,t].y2*sc+yd
					Next	
	'			EndIf
	'		EndIf
		Next
	End Method 
	
	Method DrawParticleString(part_control:TParticleControl, st$,xd,yd,sc#) 'string, x, y, scale
		Local s,d,ln,t
		
		ln = Len(st$)
		For s = 0 To ln-1
			d = Asc(Mid$(st$,s+1,1)) 'get a diget
	'		If d > 32 And d < 128
	'			If letterlen[d] > -1
					For t = 0 To letterlen[d] 'draw all its lines.
						part_control.Line letters[d,t].x1*sc+xd+sc*5*s,letters[d,t].y1*sc+yd,letters[d,t].x2*sc+xd+sc*5*s,letters[d,t].y2*sc+yd,1
					Next	
	'			EndIf
	'		EndIf
		Next
	End Method 
End Type








' **************************  vector text data  *******************************************
' chars 32-127
' spc!"#$%&'()*+`-,/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZÅ[\]^_"

#letterdata
' spc
DefData	0
' !
DefData	2,	2,0, 2,4,	2,5, 2,6
' ""
DefData	2,	1,1, 1,3,	3,1, 3,3
' #
DefData	4,	1,0, 1,6,	3,0, 3,6,	0,2, 4,2,	0,4, 4,4
' $
DefData	6,	0,1, 0,3,	0,3, 4,3,	4,3, 4,5,	4,5, 0,5,	0,1, 4,1,	2,0, 2,6
' %
DefData	3,	3,0, 1,6,	1,1, 1,2,	3,4, 3,5
' &
DefData	6,	0,1, 4,5,	0,1, 1,0,	1,0, 2,1,	2,1, 0,4,	0,4, 2,6,	2,6, 4,4
' '
DefData	1,	3,1, 2,2
' (
DefData	3,	3,0, 1,2,	1,2, 1,4,	1,4, 3,6
' )
DefData	3,	1,0, 3,2,	3,2, 3,4,	3,4, 1,6
' *
DefData	3,	1,1, 3,5,	1,5, 3,1,	0,3, 4,3
' +
DefData	2,	2,2, 2,4,	1,3, 3,3
' ,
DefData	1,	2,5, 2,6
' -
DefData	1,	1,3, 3,3
' .
DefData	1,	2,5, 2,5
' /

DefData	1,	4,0, 0,6
' 0
DefData	4,	0,0, 0,6,	0,6, 4,6,	4,6, 4,0,	4,0, 0,0
' 1
DefData	1,	2,0, 2,6
' 2
DefData	5,	0,0, 4,0,	4,0, 4,3,	4,3, 0,3,	0,3, 0,6,	0,6, 4,6
' 3
DefData	4,	0,0, 4,0,	4,0, 4,6,	4,6, 0,6,	2,3, 4,3
' 4
DefData	3,	0,0, 0,3,	0,3, 4,3,	4,0, 4,6
' 5
DefData	5,	0,0, 4,0,	0,0, 0,3,	0,3, 4,3,	4,3, 4,6,	0,6, 4,6
' 6
DefData	4,	0,0, 0,6,	0,3, 4,3,	4,3, 4,6,	0,6, 4,6
' 7
DefData	2,	0,0, 4,0,	4,0, 4,6
' 8
DefData	5,	0,0, 0,6,	0,6, 4,6,	4,6, 4,0,	4,0, 0,0,	0,3, 4,3
' 9
DefData	4,	0,0, 4,0,	4,0, 4,6,	0,0, 0,3,	0,3, 4,3
' :
DefData	2,	2,1, 2,1,	2,5, 2,5
' ;
DefData	2,	2,1, 2,1,	2,5, 2,6
' <
DefData	2,	4,0, 1,3,	1,3, 4,6
' =
DefData	2,	1,2, 3,2,	1,4, 3,4
' >
DefData	2,	0,0, 3,3,	3,3, 0,6
' ?
DefData	6,	1,1, 1,0,	1,0, 3,0,	3,0, 3,2,	3,2, 2,3,	2,3, 2,4,	2,5, 2,6
' @
DefData	6,	2,2, 2,4,	2,4, 4,4,	4,4, 4,0,	4,0, 0,0,	0,0, 0,6,	0,6, 4,6
' A (65)
DefData	5,	2,0, 0,2,	2,0, 4,2,	0,2, 0,6,	4,2, 4,6,	0,3, 4,3
' B
DefData	6,	0,0, 0,6,	0,6, 4,6,	4,6, 4,3,	4,3, 0,3,	0,0, 3,0,	3,0, 3,3
' C
DefData	3,	0,0, 0,6,	0,6, 4,6,	0,0, 4,0
' D
DefData	6,	0,0, 0,6,	0,6, 2,6,	2,6, 4,4,	4,4, 4,2,	4,2, 2,0,	2,0, 0,0
' E
DefData	4,	0,0, 0,6,	0,6, 4,6,	0,0, 4,0,	0,3, 2,3
' F
DefData	3,	0,0, 0,6,	0,0, 4,0,	0,3, 2,3
' G
DefData	5,	0,0, 0,6,	0,6, 4,6,	0,0, 4,0,	4,6, 4,3,	4,3, 2,3
' H
DefData	3,	0,0, 0,6,	0,3, 4,3,	4,0, 4,6
' I
DefData	3,	0,0, 4,0,	0,6, 4,6,	2,0, 2,6
' J
DefData	4,	3,0, 4,0,	4,0, 4,6,	4,6, 2,6,   2,6, 1,4
' K
DefData	4,	0,0, 0,6,	0,3, 2,3,	2,3, 4,0,	2,3, 4,6
' L
DefData	2,	0,0, 0,6,	0,6, 4,6
' M
DefData	4,	0,0, 0,6,	0,0, 2,3,	2,3, 4,0,	4,0, 4,6
' N
DefData	3,	0,0, 0,6,	0,0, 4,6,	4,6, 4,0
' O
DefData	4,	0,0, 0,6,	0,6, 4,6,	4,6, 4,0,	4,0, 0,0
' P
DefData	4,	0,0, 0,6,	0,0, 4,0,	0,3, 4,3,	4,3, 4,0
' Q
DefData	6,	0,0, 0,6,	0,6, 2,6,	2,6, 4,4,	4,4, 4,0,	4,0, 0,0,   4,6, 2,4
' R
DefData	5,	0,0, 0,6,	0,0, 4,0,	0,3, 4,3,	4,0, 4,3,	2,3, 4,6
' S
DefData	5,	0,0, 0,3,	0,3, 4,3,	4,3, 4,6,	4,6, 0,6,	0,0, 4,0
' T
DefData	2,	0,0, 4,0,	2,0, 2,6
' U
DefData	3,	0,0, 0,6,	0,6, 4,6,	4,6, 4,0
' V
DefData	4,	0,0, 0,3,	0,3, 2,6,	2,6, 4,3,	4,3, 4,0
' W
DefData	4,	0,0, 1,6,	1,6, 2,4,	2,4, 3,6,	3,6, 4,0
' X
DefData	2,	0,0, 4,6,	0,6, 4,0
' Y
DefData	3,	0,0, 2,3,	2,3, 4,0,	2,3, 2,6
' Z
DefData	3,	0,0, 4,0,	4,0, 0,6,	0,6, 4,6
' [ 
DefData	3,	3,0, 1,0, 	1,0, 1,6,   1,6, 3,6
' \
DefData	1,	0,0, 4,6
' ]
DefData	3,	1,0, 3,0,	3,0, 3,6,	3,6, 1,6
' ^
DefData	2,	1,2, 2,0,	2,0, 3,2
' _
DefData	1,	0,7, 4,7
' `
DefData	1,	1,1, 2,2
' a  (97)
DefData	5,	0,2, 4,2,	4,2, 4,6,	4,6, 0,6,	0,6, 0,3,	0,3, 4,3
' b
DefData	4,	0,0, 0,6,	0,6, 4,6,	4,6, 4,2,	4,2, 0,2
' c
DefData	3,	0,2, 0,6,	0,6, 4,6,	0,2, 4,2
' d
DefData	4,	4,0, 4,6,	4,6, 0,6,	0,6, 0,2,	0,2, 4,2
' e
DefData	5,	4,6, 0,6,	0,6, 0,2,	0,2, 4,2,	4,2, 4,3,   4,3, 1,3
' f
DefData	3,	4,0, 2,0,	2,0, 2,6,	1,2, 3,2
' g
DefData	5,	0,7, 4,7,	4,7, 4,2,	4,2, 0,2,	0,2, 0,6,	0,6, 4,6
' h
DefData	3,	0,0, 0,6,	0,2, 4,2,	4,2, 4,6
' i
DefData	2,	2,2, 2,6,	2,1, 2,1
' j
DefData	4,	3,1, 3,1,	3,2, 3,7,	3,7, 0,7,   0,7, 0,5
' k
DefData	3,	0,0, 0,6,	0,4, 3,2,	0,4, 3,6
' l
DefData	1,	2,0, 2,6
' m
DefData	4,	0,6, 0,2,	0,2, 4,2,	2,2, 2,4,	4,2, 4,6
' n
DefData	4,	0,2, 0,6,	0,3, 1,2,	1,2, 4,2,   4,2, 4,6
' o
DefData	4,	0,2, 0,6,	0,6, 4,6,	4,6, 4,2,	4,2, 0,2
' p
DefData	4,	0,2, 0,7,	0,2, 4,2,	0,6, 4,6,	4,2, 4,6
' q
DefData	4,	0,2, 0,6,	0,6, 4,6,	4,2, 4,7,	0,2, 4,2
' r
DefData	3,	0,2, 0,6,	0,3, 1,2,	1,2, 4,2
' s
DefData	5,	4,2, 0,2,	0,2, 0,4,	0,4, 4,4,	4,4, 4,6,	4,6, 0,6
' t
DefData	2,	0,2, 4,2,	2,0, 2,6
' u
DefData	3,	0,2, 0,6,	0,6, 4,6,	4,6, 4,2
' v
DefData	2,	0,2, 2,6,	2,6, 4,2
' w
DefData	4,	0,2, 1,6,	1,6, 2,4,	2,4, 3,6,	3,6, 4,2
' x
DefData	2,	0,2, 4,6,	0,6, 4,2
' y
DefData	2,	0,2, 2,5,	4,2, 1,7
' z
DefData 3, 0, 2, 4, 2, 4, 2, 0, 6, 0, 6, 4, 6
' æ
DefData 5, 0, 2, 4, 2, 4, 2, 4, 6, 4, 6, 0, 6, 0, 6, 0, 3, 0, 3, 4, 3, 2, 1, 2, 1
' {
DefData	4,	3,0, 2,0, 	2,0, 2,6,   2,6, 3,6,   1,3, 2,3
' |
DefData	1,	2,0, 2,6
' }
DefData	4,	1,0, 2,0,	2,0, 2,6,	2,6, 1,6,   2,3, 3,3
' ~  (126) 
DefData	5,	0,3, 0,1,	0,1, 2,1,	2,1, 2,3,   2,3, 4,3,   4,3, 4,1

' <-
DefData	3,	3,1, 0,3,	0,3, 3,5,	0,3, 4,3
' checkmark
DefData	2,	0,4, 2,6,	2,6, 4,0
' ->
DefData	3,	1,1, 4,3,	4,3, 1,5,	0,3, 4,3



'tparticlelinedraw.bmx
Import "tiniparser.bmx"
'-------------------------------------------------------------------

Type Tparticle 
		Global pcount:Int
		Field x:Float,y:Float 		
		Field xrange:Int,yrange:Int		
		Field vel:Float 		
		Field angle:Float 		
		Field image:Timage 		
		Field life:Int 	
		Field is_alive:Int 	
		Field alpha:Float 		
		Field scale:Float 	
		Field pred%,pgreen%,pblue%	
		
		' rgb/min/max = color
		' amin/amax = alpha
		Method Spawn(px#,py#,pvel#,plife%,pscale#,pangle%,pxrange#,pyrange#,rmin%,rmax%,gmin%,gmax%,bmin%,bmax%,amin%,amax%) 	
			is_alive = True 
			x = Rnd(px-(pxrange/2),px+(pxrange/2))
			y = Rnd(py-(pyrange/2),py+(pyrange/2))

			
			vel = pvel 
			xrange = pxrange
			yrange = pyrange
			
			life = plife
			
			scale = pscale 
			
			angle = pangle
			
			alpha = Rnd(amin,amax) 
			pred = Rnd(rmin,rmax) 
			pgreen = Rnd(gmin,gmax) 
			pblue = Rnd(bmin,bmax) 
		End Method 
		
		Method Update() 
			life:-1			
			
			If life <0 Then is_alive = False 			
			
			If is_alive = True 
				pcount:+1
				
				vel:*1.02		
				
				x:+(vel*Sin(angle-90)) 
				y:+(vel*Cos(angle-90)) 				
				
					SetBlend LIGHTBLEND 
					alpha:*.99
				
					scale:*.999
								
				SetAlpha alpha 
				SetColor pred,pgreen,pblue 
				SetRotation angle 
				SetScale(scale,scale) 
				DrawImage image,x,y 							
			EndIf 		
		End Method 
End Type 
'-------------------------------------------------------------------

Type TParticleControl
	Field resX:Int
	Field resY:Int
	
	Field particle_image:timage
	Field part_array:Tparticle[]
	Field spawn_delay:Int 
	Field particlesPerFrame:Int
	Field partMinSize:Float
	Field partMaxSize:Float
	Field partMinLife:Int
	Field partMaxLife:Int
	Field partMinVelocity:Int
	Field partMaxVelocity:Int
	Field partMinAngle:Int
	Field partMaxAngle:Int
	Field partXSpread:Int
	Field partYSpread:Int
	
	Field rmin:Int
	Field rmax:Int
	Field gmin:Int
	Field gmax:Int
	Field bmin:Int
	Field bmax:Int
	
	Field amin:Int
	Field amax:Int
	
	Field part_counter:Int
	Field plength:Int
	Field spawnx:Int
	Field spawny:Int
	
	Field parser:TIniFileParser
	
	Field generateParticleX:Float[resX]
	Field generateParticleY:Float[resY]
	Field generatePartIndex:Int = 0

	Field textsize:Int 'should not be here, should belong to text.
	Field textline1:String
	Field textline2:String
	
	
	Function Create:TParticleControl(resX%, resY%)
		Local tmp:TParticleControl = New TParticleControl
		tmp.resX=resX
		tmp.resY=resY
		tmp.parser = New TIniFileParser
		tmp.loadValues()
		
		Local maxParticles:Int = 10000
		tmp.part_array = New TParticle[maxParticles]
		tmp.plength = maxParticles
		tmp.generateParticleX = New Float[maxParticles]
		tmp.generateParticleY = New Float[maxParticles]
		tmp.setup()
		Return tmp
	End Function
	
	Method loadValues()
		parser.loadFile( "tweakme.ini" )
		parser.parseFile()
		spawn_delay = Int(parser.getVariable("spawn_delay") )
		particlesPerFrame = Int(parser.getVariable("particlesPerFrame") )
		partMinSize =Float(parser.getVariable("partMinSize ") )
		partMaxSize=Float(parser.getVariable("partMaxSize") )
		partMinLife= Int(parser.getVariable("partMinLife") )
		partMaxLife= Int(parser.getVariable("partMaxLife") )
		partMinVelocity= Int(parser.getVariable("partMinVelocity") )
		partMaxVelocity= Int(parser.getVariable("partMaxVelocity") )
		partMinAngle= Int(parser.getVariable("partMinAngle") )
		partMaxAngle= Int(parser.getVariable("partMaxAngle") )
		partXSpread= Int(parser.getVariable("partXSpread") )
		partYSpread= Int(parser.getVariable("partYSpread") )
		rmin= Int(parser.getVariable("partColorRedMin") )
		rmax= Int(parser.getVariable("partColorRedMax") )
		gmin= Int(parser.getVariable("partColorGreenMin") )
		gmax= Int(parser.getVariable("partColorGreenMax") )
		bmin= Int(parser.getVariable("partColorBlueMin") )
		bmax= Int(parser.getVariable("partColorBlueMax") )
		amin= Int(parser.getVariable("partAlphaMinimum") )
		amax= Int(parser.getVariable("partAlphaMaximum") )
		
		textsize = Int(parser.getVariable("textsize"))
		textline1 = parser.getVariable("textline1")
		textline2 = parser.getVariable("textline2")
		parser.free()
	End Method
	
	Method setup()
	     createPartImg()
		Local i:Int
		For i = 1 To plength-1 
		part_array[i] = New Tparticle 
		part_array[i].image = particle_image
	
		part_array[i].life = Rnd(800,1000) 
		part_array[i].scale = 1
	
		part_array[i].is_alive =False 
		part_array[i].alpha = 1
	Next
	End Method
	
	'Called once at setup to Create the particle image
	Method createPartImg()
		Print "created img"
		' create a particle (programmatically, you can uncomment the loadimage line if you have a better particle image
		SetBlend ALPHABLEND 
		Local sz:Int =64 
		
		particle_image = CreateImage(sz,sz) 
		Local alpha:Float = 1.0 
		Local i:Int
			For i = 1 To sz/2 
					DrawOval (sz/2)-i,(sz/2)-i,i*2,i*2 
					alpha:* 0.65		
					SetColor Rnd(100,200),Rnd(100,200),Rnd(200,255) 
					SetAlpha alpha 	
			Next 	
		GrabImage(particle_image,0,0) ; Cls 
	End Method
	
	Method draw()
		spawn_delay:-1
		If spawn_delay < 0
			Local pp:Int 'spawned particles per frame
			Local xpos:Int=0
			Local ypos:Int=0
			
			While pp < particlesPerFrame
				pp :+1				
				Local i:Int
				For i = 1 To plength-1 	
					If part_array[i].is_alive = False 
						Local pvel:Float = Rnd (partMinVelocity,partMaxVelocity) 				
						Local life:Int = Rnd (partMinLife,partMaxLife) 			
						Local sc:Float = Rnd (partMinSize, partMaxSize) 				
						Local ang:Float = Rnd(partMinAngle,partMaxAngle)
						Local xrange:Int = partXSpread					
						Local yrange:Int = partYSpread
						
						spawnx = generateParticleX[i]
						spawny = generateParticleY[i]
						part_array[i].spawn(spawnx,spawny,pvel,life,sc,ang,xrange,yrange, rmin,rmax, gmin,gmax, bmin,bmax,amin,amax) 				
						spawn_delay = 0
						
						Exit	
					EndIf 
							
				Next 		
			Wend
			generatePartIndex = 0 		
		EndIf 
		
		'Local i:Int=0	
		i=0
		For	i = 1 To plength-1 
			part_array[i].update()		
		Next
		
		SetAlpha 1 
		SetTransform() 
	End Method
	
	'set a particle on
	'used by Line(x1,y1,x2,y2)
	Method wantParticle(x#,y#)
		If generatePartIndex < 10000
			generateParticleX[generatePartIndex] = x
			generateParticleY[generatePartIndex] = y
			generatePartIndex:+1
		EndIf
	End Method
	
	' Besenham's LineDraw routine (integer math only) by ImaginaryHuman <a href="/codearcs/codearcs.php?code=1465" >Besenham's LineDraw routine (integer math only)</a>
	Method Line(X1:Int,Y1:Int,X2:Int,Y2:Int,skip:Int)
		'Draws a line of individual pixels from X1,Y1 to X2,Y2 at any angle
	 	Local Steep:Int=Abs(Y2-Y1) > Abs(X2-X1)			'Boolean
		If Steep
			Local Temp:Int=X1; X1=Y1; Y1=Temp		'Swap X1,Y1
			Temp=X2; X2=Y2; Y2=Temp		'Swap X2,Y2
		EndIf
		Local DeltaX:Int=Abs(X2-X1)		'X Difference
		Local DeltaY:Int=Abs(Y2-Y1)		'Y Difference
		Local Error:Int=0		'Overflow counter
		Local DeltaError:Int=DeltaY		'Counter adder
		Local X:Int=X1		'Start at X1,Y1
		Local Y:Int=Y1		
		Local XStep:Int
		Local YStep:Int
		If X1<X2 Then XStep=1 Else XStep=-1	'Direction
		If Y1<Y2 Then YStep=1 Else YStep=-1	'Direction
		If Steep Then wantParticle(Y,X) Else wantParticle(X,Y)		'Draw
		While X<>X2
			X:+XStep		'Move in X
			Error:+DeltaError		'Add to counter
			If (Error Shl 1)>DeltaX		'Would it overflow?
				Y:+YStep		'Move in Y
				Error=Error-DeltaX		'Overflow/wrap the counter
			EndIf
			If Steep Then wantParticle(Y,X) Else wantParticle(X,Y)		'Draw
		Wend
	End Method 
End Type


tweakme.ini
spawn_delay=20
particlesPerFrame=100
partMinSize=1.0
partMaxSize=1.2
partMinLife=5
partMaxLife=25
partMinVelocity=0
partMaxVelocity=2
partMinAngle=0
partMaxAngle=10
partXSpread=1
partYSpread=1
partColorRedMin=200
partColorRedMax=255
partColorGreenMin=128
partColorGreenMax=128
partColorBlueMin=32
partColorBlueMax=32
partAlphaMinimum=1.0
partAlphaMaximum=1.2
textsize=8
textline1=V E C T O R 
textline2=T E X T
[codebox]The code is above as codeboxes only work in the description[/codebox]