Jump to content
  • Advertisement


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


Message - Game Loop

This topic is 6107 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

I am going to do a tetris clone, using only a standard window and win32 GDI. I have seen this message loop in a book I have:
while (1) {
    MSG msg;
    if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
			// Check if the message is to quit the application

			if( msg.message == WM_QUIT )
				// Exit the message loop


    else// Game Loop

This was going to be used for a full screen directx game, which ofcourse would need most of the free resources. But for the game I''m working on, this may be too much of a hog. What would be better for this project? Break;

Share this post

Link to post
Share on other sites
Dunno if it helps, but this is the way I do it...

MSG Message;

while(Message.message != WM_QUIT)

Pretty much the same as your code, except it doesn''t check to see if the message is WM_QUIT IN the loop. Instead it makes it the loops condition for running. This, to me, is more secure, and I suppose it would be a bit faster. It works on every project I''ve been involved with

Good luck.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!