Tag System - Up The Swanie

Blitz3D Forums/Blitz3D Beginners Area/Tag System - Up The Swanie

Here's one I wrote a while back. Uses a similar system, except ^WH or ^BL, etc. I'm sure you could adapt it. Very fast, and doesn't require a graphics buffer, or creating images on the fly. Just uses text commands. :)

Example included of course - the guts of it is the "Word" TYPE, which is used to split up the sentence into each color code section (or you could use other codes, for bold, etc - I just parse that in the main function call as you can see), and the function.

Graphics 800,600,32,1
	
	Global sfont=LoadFont("Times New Roman",18,0,0,0)
	Global bfont=LoadFont("Times New Roman",18,1,0,0)
	Global ifont=LoadFont("Times New Roman",18,0,1,0)
	Global ufont=LoadFont("Times New Roman",18,0,0,1)
	Global spfont=LoadFont("Verdana",14,0,0,0)
	
	Type Word
		Field Txt$
		Field Col$
		End Type
		
	SetBuffer BackBuffer()
	ClsColor 100,100,100
	Cls
	
	ctext "^go52760 ^whgold pieces",135,105	
	Flip
		
	WaitKey()
	End
	
	
	Function Ctext(txt$,x,y,bold=1,italic=0,underline=0,shadow=1)
	SetFont bfont
	If bold=0 Then SetFont sfont
	If italic=1 Then SetFont ifont
	If underline=1 Then SetFont ufont
	this.word=New word
	For i = 1 To Len(txt$)
		CurrentChar$=Mid$(txt$,i,1)
		If CurrentChar$ = "^" Then
			ColCode$=Mid$(txt$,i+1,2)
			this.word=New Word
				this\col$ = Lower(ColCode$)
			i=i+2
		Else
			this\txt$=this\txt$+CurrentChar$
		End If
	Next
	tx=x
	For this.word = Each word
		Color 0,0,0
		If shadow=1 Then Text tx,y+2,this\txt$
		
		Select this\col$
			Case "wh":Color 255,255,255
			Case "bl":Color 80,80,255
			Case "go":Color 200,200,70
			Case "bk":Color 0,0,0
			Default:Color 255,255,255
		End Select
		Text tx,Y,this\txt$
			tx=tx+StringWidth(this\txt$)
		Delete this
		Next
	End Function


+BlackD