Thread: game loop

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    80

    Post game loop

    what is the logic of game loop function??how can i find detailed information about game loop?

  2. #2
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    very general question.

    it depends on the game you are creating and also on what is the specific thing you want to do in that portion.
    -

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    Typically speaking, one loop through the "game loop" usually represents a "frame" in the animation of the game.

    Code:
    start_loop:
    Update game logic (where is everyone and why).
    Write picture to offscreen memory buffer one piece at a time.
    Flush buffer onto the screen (a frame is born).
    Repeat from start_loop.
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  4. #4
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Yeah, it really depends on what game you're doing..
    It's basically a loop, until victory or defeat conditions are met.
    For example, this is a Tic Tac Toe loop:

    Code:
    int main ()
    {
    
    	init();
    	system("CLS");
    	table();
    	do
    	{
    		if (moves < 9)
    		{
    				getInput(playerup);
    				while (setInput(playerup))
    				{	
    					cout << "\tThat move has already been made!\n\n";
    					getInput(playerup);
    				}
    				system("CLS");
    				table();
    				if (playerup == 'o')
    				{
    					playerup = 'x';
    				} else {
    					playerup = 'o';
    				}
    		} else {
    			cout << "\n\tNo winner this time, thanks for playing\n\n\n\t";
    			
    			_getch();
    			return 0;
    		}
    	} while (checkWin(playerup) == 2);
    	if (playerup == 'x')
    	{ 
    		cout << "\n\tCongratulations " << playername2 << ", you've won!\n\n\n\t";
    		//system("PAUSE");
    		_getch();
    		return 0;
    	} else {
    		cout << "\n\tCongratulations " << playername1 << ", you've won!\n\n\n\t";
    		
    		_getch();
    		return 0;
    	}
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D Game project requires extra C++ programmers, new or experienced
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 05-16-2007, 10:46 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  4. game loop
    By X PaYnE X in forum Windows Programming
    Replies: 6
    Last Post: 02-15-2005, 01:33 PM
  5. for loop or while loop
    By slamit93 in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2002, 04:13 AM