Code archives/Miscellaneous/DebugText
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Here's a typical 3D game loop:Repeat UpdateGame () RenderWorld Flip Until KeyHit (1) Now, assuming UpdateGame deals with movement of entities, player input, etc, and you want to stick some text on-screen to find out a certain value while debugging. If you use the Text command, it'll be obliterated by RenderWorld, so you won't get any output. That's what this sorts out, allowing you to call DebugText from anywhere to get stuff on-screen without loads of messing about (eg. temporarily setting up globals to hold the debug values)... Paste the code below into your program, place Debug3D () just before Flip, and call DebugText wherever you would normally want to call Text (with the same parameters, except you can add optional R, G, B to the end :) | |||||
Type DebugItem Field x, y, r, g, b, message$ End Type Function DebugText (x, y, message$ = "", r = -1, g = -1, b = -1) d.DebugItem = New DebugItem d\x = x d\y = y d\message = message$ d\r = r d\g = g d\b = b End Function Function Debug3D () For d.DebugItem = Each DebugItem If (d\r > -1) And (d\g > -1) And (d\b > -1) Color d\r, d\g, d\b EndIf Text d\x, d\y, d\message Delete d Next End Function |
Comments
None.
Code Archives Forum