100% CPU usage

Blitz3D Forums/Blitz3D Programming/100% CPU usage

Someone who was playtesting my game mentioned he saw 100% CPU usage while the game was running, making it difficult to run background tasks. The game isn't doing anything obscure, but rather just in a normal game loop.

He wondered if there was a way to put the game into a sleep cycle of sorts to at least allow other apps a slice of the CPU. I didn't know of any capabilities with the Blitz language to do something like this. Anyone have any suggestions?

What exactly do you mean? is your game running in windowed
mode? or is it just too CPU intensive?

http://www.blitzbasic.com/Community/posts.php?topic=31084

Sorry for lack of info. I am actually doing a 2D game (Graphics mode not Graphics3D). I have alot of graphics in memory (png's, jpegs) and have a C++ dll running and whatever overhead that entails (it only stores one global variable).
It is running 800x600 windowed mode. Actually, when I minimize it I can do otherstuff without too much trouble. But since he asked I was just wondering if there was anything available in Blitz.
thanks again...Dave

If you put a 'delay' statement in your loop, the CPU gets some more breathing space.

Thanks! I didn't know about the Delay command. I'll try it out.

I think you need to put in 'delay 8' or 'delay 16' at least.

WaitTimer() would be better.

What I do is have a target fps - and when it gos faster than the target, delay by a certain amount of time.

Bot Builder, that's what I meant.. that's what WaitTimer() does.