Code archives/Miscellaneous/Text print queue

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

Download source code

Text print queue by BlitzSupport
(Posted 24 years ago)
This is hard to describe, but it's for messages you want to display only briefly on-screen, in a queue, like the sort of messages that appear in network games, etc, then disappear.

Simply paste the stuff below into your code, add UpdatePrintQ () to your main loop, just before 'Flip', then instead of calling Print when something happens (eg. Print "Player joined"), use PrintToQ "Player joined"...

This is only for brief 'event' messages -- you can change the default timeout of messages by adding a milliseconds value to UpdatePrintQ.
Type PrintQ
	Field message$
	Field time
End Type

Function PrintToQ (message$)
	p.PrintQ = New PrintQ
	p\message = message$
	p\time = MilliSecs ()
End Function

Function UpdatePrintQ (timeout = 2000)
	Locate 0, 0
	For p.PrintQ = Each PrintQ
		Print p\message$
		If p\time < MilliSecs () - timeout Then Delete p
	Next
End Function

Comments

None.

Code Archives Forum