PDA

View Full Version : Fishy Friends



Michael Clease
06-06-2009, 00:58
I have been playing with the new sprite functions and here is a rough version of a simple demo, it needs more logic and some collision of sprite to sprite and sprite to background.

Enjoy


Mike

ErosOlmi
06-06-2009, 08:46
That is very nice Michael. Thanks for the present.

The only problem I see in the example is CPU usage that is too high I suppose because using WHILE/WEND loop. If it could be converted to callbacks and timer it would really fly.

Ciao and thanks again.
Eros

Petr Schreiber
06-06-2009, 09:40
Hi Michael,

that is very nice demo!

If you want to let it in window and still have low CPU use, instead of:


while TBGL_isWindow(hWnd)
' -- Rendering code here
wend


you can use "periodical" function mechanism:


' -- Specify which function will take care of rendering, and how often
TBGL_BindPeriodicFunction(hWnd, "Do_GameLoopFunction", 15) ' -- 15ms timeout

' -- Here it halts rendering and starts calling Do_GameLoopFunction each 15ms if possible
TBGL_ProcessPeriodicFunction(hWnd)

' -- Once TBGL_UnBindPeriodicFunction is called, we get here

...

SUB Do_GameLoopFunction()
' -- Rendering code here
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then TBGL_UnBindPeriodicFunction( hWnd )
END SUB


It should kick CPU usage down to almost zero. Internally it is timer based.


Petr

Michael Clease
06-06-2009, 09:58
Thanks guys

I will do a rewrite when time allows and add some more, it was from the sprite sample.


thanks for your help as always

Quick update I have used Petr's timing and it has gone down to 0 seconds but I wont release a new version until i've add more features.
Does looks quite good in full screen from a distance, so I will add an option to do that.