View Single Post
Old 05 July 2019, 06:17   #2
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,406
Post

Quote:
Originally Posted by MartinW View Post
I think I'm confusing myself!

Simple question...

If I have a main loop such as this (pseudo code):

Code:
while (!mouseClick())
{
    gameLogic();

    WaitTOF();
    updatePlayfield();
}



Not taking into account when things get too slow and it can't render at full speed for now, will that loop 50 times per second on PAL, 60 times per second on NTSC due to the WatTOF, or will it loop as fast as it possibly can?

[EDIT] I'll leave the question there but never mind. As soon as I posted I noticed I had a setting wrong in my WinUAE display settings!!
I was playing around with this kind of update loop back in the 80's, from memory my solution was this:

Code:
while (!mouseClick())
{
   ticks = (currentTime - lastTime)
    
    gameLogic(ticks);

    updateDisplay();
}
The idea behind this approach is that the faster your CPU is then the smaller the ticks will be for updating your game world which will result is smoother movement (and more frames per second) but the world will always be updated in a linear manner (no slow-down, just frame skipping on slower CPU's).

I could be wrong though, that was many years ago
NovaCoder is offline  
 
Page generated in 0.04374 seconds with 11 queries