Game Loop and Game Engine

Started by
4 comments, last by johnc82 20 years, 11 months ago
hi.... Can anyone tell more in depth about game loop and game engine... Thanks...
:-)
Advertisement
more in depth than what?
I don''t know, but I''ll give you a little info anyway.

Every game operates in a constant loop whereby, input is read, objects are updates and graphics are displayed. In terms of pseudocode, it could look something like this...

while(gameplaying == true)
{
checkInput();
updatePlayers();
updateEnemies();
drawGraphics();
}

Obviosuly that is just an example but it should give you the general idea. That is the basics of how a game-loop works.


A game engine can mean different things to different people, but I''ll explain it in terms of that game-loop example.

The engine is the real work-horse of your game taking care of that game-loop. It will start by loading all the resources (graphics, levels and sounds etc). Once everything is loaded it can go about setting the game in motion. How this is achieved is obviously dependant on your game but lets assume its a platform game. It will load all the level data, load the player data, the enemy data, the sounds and so on. Once done it will enter that aforementioned game-loop and take care of that constant looping process.

Not sure if that will help but I hope it does something useful for ya.
anymore information?



Thanks

:-)
Well, give us an idea of what you can do first? That way we can gauge how much detail you require.

Have you made any games before?
What language?
How long have you been programming?
And so on

The game loop is the cycle of instructions executed that comprise the entire game engine. The game engine itself can be subdivided into a graphics engine, sound engine, etc. A game loop roughly follows the structure:

1) Initialise game.

Then the actual loop is:
2) Accept user input
3) Update game state
Terminate loop.

4) Close game.

Hope this clarifies.
I suggest using states in the game loop to tell if it''s in the main menu, in-game, or end screen....

while(gameplaying == true)
{
switch(gameState)
{
blah blah blah.......
}
}


- Rob Loach
Current Project: Go Through Object-Oriented Programming in C++ by Robert Lafore

"Do or do not. There is no try."
- Yoda
Rob Loach [Website] [Projects] [Contact]

This topic is closed to new replies.

Advertisement