what is the logic of game loop function??how can i find detailed information about game loop?
This is a discussion on game loop within the Game Programming forums, part of the General Programming Boards category; what is the logic of game loop function??how can i find detailed information about game loop?...
what is the logic of game loop function??how can i find detailed information about game loop?
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.
-
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/
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; } }