Can anyone optimise this code chunk?

Blitz3D Forums/Blitz3D Beginners Area/Can anyone optimise this code chunk?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Lastly:

1) Don't use print, as it is slower. Instead use the Text command.

2) Are you using a back buffer ?
Depending on how the main loop is set up you might want to drop the CLS command. If the area where the debug text is being displayed (print always prints to the FrontBuffer, Text prints to the current active buffer)is always being redrawn by other images/blocks then CLS is probally not necessary. Just call your Debug function AFTER all other graphic drawing commands but BEFORE the Flip command.

3) After you create your Graphics screen do something like this:

Global screen_width = GraphicsWidth()
Global screen_height = GraphicsHeight()
Global screen_depth = GraphicsDepth()
Global screen_buffer = GraphicsBuffer()



Finally in your function:

[ oh, out of personnal preference, I opt to term my functions which output text with 'display' as oppossed to print... that's just me though ;^) ]

Function display_debug_info()
r = ColorRed()
g = ColorGreen()
b = ColorBlue()
Text 0,00,"PlayField Width: " + Screen_Width
Text 0,14,"PlayField Height: " + Screen_Height
Text 0,28,"PlayField Depth: " + Screen_Depth
Text 0,32,"PlayField Memory: " + Screen_Buffer
Text 0,46,"PlayField Drawing Color (DEC) " + r + " " + g + " " + b
Text 0,60,"PlayField Drawing Color (HEX) " + Hex$(r) + " " + Hex$(g) + " " + Hex$(b)
End Function


I only guessing that your playfield is the Screen Buffer, so change whatever you use accordingly.

Hope some of that helps. If I am wrong on anything, I am pretty sure it will get corrected.



Happy Coding !