Synchronise graphics and logic code
Posted
by
Skeith
on Game Development
See other posts from Game Development
or by Skeith
Published on 2011-06-16T14:30:29Z
Indexed on
2011/06/29
16:31 UTC
Read the original article
Hit count: 236
I have a procedural approach to the game loop that runs various classes.
it looks like this:
- continue any in progress animations
- check for used input
- apply AI
- move things
- resolve events such as collisions
- draw it all to screen
I have seen a lot of posts about how drawing should be running separately as fast as it can, possibly in another thread.
My problem is that if the drawing runs as fast as it, can what happens if it tried to draw while I'm still applying the AI or resolving a collision? It could draw the wrong thing on screen.
This seems to be a well established idea so there must be an explanation to this problem as I just cant get my head around it. The only solution I have is to update the screen so fast that any errors like that get refreshed before we see them but that sounds hacky.
So how does this work / how would you implement it so that they are in sync but running at different speeds?
© Game Development or respective owner