• Advertisement

Archived

This topic is now archived and is closed to further replies.

Main loop of the game

This topic is 5903 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey I have a problem with the main loop of my game. Every time i run it, my program seems to freeze up, but i think its still running. So far my main loop is like this: while(running) { //Random game stuff here Application->ProccessMessages() ; } (As you can probably guess, this is in borland c++). There is a keydown event called from the main form and if the key pressed is escape, then running gets set to false. I think the problem is that i need another "proccess messages" kind of function to call, but i dont know what it is. Can you help?

Share this post


Link to post
Share on other sites
Advertisement
Does Application->ProcessMessage() block if there is no message in the queue ?

Share this post


Link to post
Share on other sites
im not sure...
i just need to know if there are any other functions i might need to call in my main loop...

Share this post


Link to post
Share on other sites
Nup.... the ProcessMessages() call just pumps the message loop (mind you, in some situations, it doesn''t actually allow the messages to do anything if processor-intensive commands are going on)..... it won''t block, and I suggest you look for the problem in the "random game stuff".....

One thing I can suggest is that perhaps everything is running fine, but the form isn''t being displayed.... what I''d do is this...

When you start the game, enable a Timer with an interval of ~500ms, then use the timer to call some function with the main loop. Often, if the program executes the loop on a form show or something, it will use all the processor time going through the loop, and not drawing the form, even if you call App->ProcessMessages();

--Cirian

Share this post


Link to post
Share on other sites

  • Advertisement