In Game Chat Window

Blitz3D Forums/Blitz3D Beginners Area/In Game Chat Window

Hello!

Once again I must resort to the friendly forums for some help and advice. I am trying to create a chat window in my game that displays Area Chat, Friend Chat, System Messages and of course your own Chat. I am trying to make them different colors and utilize a scrolling enviroment. I am using sprite candy and have created an awesome chat window, but adding different color text is quite the battle. If someone could post some info or ideas on creating a standard Blitz3d one, without any includes, that would be great. I will post some info as I get more into this, I've already spent a few weeks on this, so any help would be greatly appreciated!!

I have checked out the Nemesis Chat from the archives, and it looks exactly like I want, but the download link is broken and it calls functions that arent present in the client code.

Maybe you could use a type for the chat messages:
	SeedRnd MilliSecs()
	Graphics3D 800, 600, 0, 2
	SetBuffer BackBuffer()

;-----------------------------------------------------------------------------------------------------
;													Globals
;-----------------------------------------------------------------------------------------------------
	
	Const textheight = 20;use stringheight
	
	Type msg
		Field s$
		Field col
	End Type
	
	Global 	chatscroll, scroll, scrollmode
	Global 	msgbox, msgtex
	Global  msgfont = LoadFont("Arial", 20)
	
;-----------------------------------------------------------------------------------------------------
;													Initialize()
;-----------------------------------------------------------------------------------------------------
	
	camera = CreateCamera()
	PositionEntity camera, 0, 0, -15
	
	InitChat()
	
	AddChat("Ready.", $FF0000)
	
	Repeat
	
		If Rand(60) = 15 Then AddChat(RandomWord$(), $FFFF00)
		If Rand(60) = 15 Then AddChat(">" + RandomWord$(), $00FF00)
		UpdateChat()
		RenderWorld()
		Flip
		
	Until KeyHit(1)
	
	End

;-----------------------------------------------------------------------------------------------------
;													UpdateChat()
;-----------------------------------------------------------------------------------------------------
Function UpdateChat()

	ClsColor 0, 0, 127
	Cls
	SetFont msgfont
	tel = 0
	For m.msg = Each msg
		Color 0, 0, m\col
		Text 0, tel * textheight - scroll, m\s$
		tel = tel + 1
		If tel = 14 Then Exit
	Next
	
	If scrollmode Then
		If scroll <= chatscroll Then scroll = scroll + 2;speed
		If scroll > chatscroll Then 
			scroll = 0
			Delete First msg
			scrollmode = 0
			chatscroll = 0
		End If
	Else
		If chatscroll = 0 Then If tel > 13 Then chatscroll = chatscroll + textheight: scrollmode = 1
	End If
	
	CopyRect 0, 0, 256, 256, 0, 0, BackBuffer(), TextureBuffer(msgtex)
	EntityTexture msgbox, msgtex

End Function

;-----------------------------------------------------------------------------------------------------
;													InitChat()
;-----------------------------------------------------------------------------------------------------
Function InitChat()

	msgtex = CreateTexture(256, 256)
	
	msgbox = CreateCube()
	ScaleEntity msgbox, 4, 3, 0.001
	MoveEntity msgbox, -10.8, 8, 0
	EntityTexture msgbox, msgtex

End Function

;-----------------------------------------------------------------------------------------------------
;													AddChat()
;-----------------------------------------------------------------------------------------------------
Function AddChat(s$, col)

	m.msg = New msg
	m\s$ = s$
	m\col = col

End Function

;-----------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------
Function RandomWord$()

	d$ = ""
	For l = 4 To Rand(8) + 4
	Restore
	onm = nm
	Repeat 
		nm = Rand(15)
	Until nm <> onm
	For i = 1 To nm
		Read c$
	Next
	d$ = d$ + c$
	Next
	d$ = Upper$(Left$(d$, 1)) + Mid$(d$, 2, Len(d$) - 1)
	
	Return d$

End Function
Data "talk", "house", "freak", "hold", "lamp", "driver", "school", "directors", "broadcast", "show", "dance", "song", "machine", "computer", "sea"


Thank you very much B32, I will use what you've given there and see if I can make what I need from it. I really appreciat the help there.

What about using several HUD panels within Sprite Candy to create a 'tabbed' chat box? Each tab (e.g. 'Area' 'Friends' 'System') you click show/hides the appropriate HUD panel?

Caffy, that would work great too and I thought of doing that. I may still put that in the works. Thanks for the input there!