Advertisement

Windows Game Programming

Started by June 12, 2002 01:55 AM
4 comments, last by FlamELorD 22 years, 6 months ago
dudes.. can someone explain really specific how does the MAin game loop works???? i kinda have an idea but... i dont understand it 100% and other thing.... what about the frames per second... how can i lock my game to run at 50 fps or so.... =) thanks "Aika Multaa Muistot"
Kaimera Project- A myth... traditional story about supernatural beings or imaginary people that narrates a common belief or explains some natural phenomenon.
quote: Original post by FlamELorD
how can i lock my game to run at 50 fps or so....

The question is: Why would you want to do that?

Why not implement frame rate independent animation/motion instead (its just as easy to implement as locking the frame rate, and it works correctly regardless of the speed of the computer running your game).
Advertisement
well.. not to lock it... just to slow it down so i can see what am I doing... it runs so fast I cant see shit =(

"Aika Multaa Muistot"
Kaimera Project- A myth... traditional story about supernatural beings or imaginary people that narrates a common belief or explains some natural phenomenon.
quote: Original post by FlamELorD
dudes.. can someone explain really specific how does the Main game loop works???? i kinda have an idea but... i dont understand it 100%

A main game loop is just the loop that runs in main during the whole game, nothing advanced at all...

For example:

int main() {    initGfx();    bool exit = false, Win = false;    while(!exit && !Win) {        drawGfx(); // Draw stuff whatever it is        checkKeys(); // Check keys and move spaceship or whatever        Win = CheckIfWin(); // true if player has won        if(Keypress = ESC) // If you have pressed ESC            exit = true;    }return 0;} 

This was maby not the best example I could give but I think you got the idea; one loop is one frame, check everything during every frame. If the player quits or wins level/game quit loop.

No way! I will never write a profile signature! :p
quote: Original post by FlamELorD
well.. not to lock it... just to slow it down so i can see what am I doing... it runs so fast I cant see shit =(


You are probably not getting more than 100 fps (in fullscreen) now so reducing FPS to 50 will not solve the problem. It will only half the problem.

You need to move your objects according to time and not frames.
Search these forums for "locking fps" or something like that and you should find several threads discussing this.


[edited by - granat on June 12, 2002 5:50:34 AM]
-------------Ban KalvinB !
Gamedev has an article on frame independent movement here

This topic is closed to new replies.

Advertisement