| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- ' Debug Print Queue...
- ' Copy and paste the DebugQ type and the PrintQ/UpdateQ functions. Use
- ' PrintQ to add a debug message to your game, and UpdateQ in your main
- ' loop to display/update messages...
- Type DebugQ
- Global DebugQList:TList
- Field message$
- Field alpha# = 1
- Function Print (message$)
- If DebugQList = Null Then DebugQList= New TList
- p:DebugQ = New DebugQ
- p.message = message$
- DebugQList.AddLast p
- End Function
- Function Update (alphacut# = 0.01)
- If DebugQList = Null Then Return
- y = 0
- For p:DebugQ = EachIn DebugQList
- SetBlend ALPHABLEND
- SetAlpha p.alpha
- DrawText p.message$, 0, y
- y = y + TextHeight("")
- p.alpha = p.alpha - alphacut; If p.alpha < 0 Then DebugQList.Remove p
- Next
- SetBlend SOLID ' Need to get old values!
- SetAlpha 1 ' Need to get old values!
- End Function
- End Type
- ' Functional interfaces for non-OO'ers...
- Function PrintQ (message$)
- DebugQ.Print message$
- End Function
- Function UpdateQ ()
- DebugQ.Update
- End Function
- ' D E M O . . .
- Graphics 640, 480
- Repeat
- Cls
- x = MouseX ()
- y = MouseY ()
- DrawRect x, y, 32, 32
- ' Add items to debug print queue...
- If MouseHit (1) Then PrintQ "Left mouse button hit!"
- If MouseHit (2) Then PrintQ "Right mouse button hit!"
- ' Print/remove all debug items...
- UpdateQ
- DrawText "Click mouse...", 0, GraphicsHeight () - 20
- Flip
- Until KeyHit (KEY_ESCAPE)
- End
|