Simulating time

Hi,

I'm new to the forums so sorry for jumping straight into this topic for my first question..

What is the best way to simulate time in a game from within programming?

Say you have a football management game, no fancy 3d graphics or sprites, just the front end management console? You have two halfs of 45 minutes and you want to simulate this game and all of the moveable components in a fluid manner but from within a programming loop? How do they achieve this?

:S Cheers.
 

Michael Brookes

Game Director
It's been a very long time since I've done any real programming, but this may help get you started:

You need to chop all of your similuation down into chunks, now you can split that time into fixed time or variable time chunks.

You would generally use fixed time chunks when the accuracy of the simulation is important, or you're not too worried about having to display the results of the calculations on a per frame basis.

Variable timechunks is usually used when the data used in the simulation is based on data that changes on a per frame basis, so for example how far a bullet has travelled since the last update. Generally anything you are displaying should take into account that the time taken to calculate each frame may not be the same each time.

From your brief description it sounds like you'd need to allow for both, so in the background you are calculating the variables of the game in progress, so player and ball positions for example. To ensure smooth playback you'd probably also want to replay those positions on screen through a variable time slice based on the current frame time.

So you'd have the game simulation that maybe calaculates what is happening in the game every second (of game time), but you might be showing the playback of the game so that every second of real-time is a minute of game time (or some other arbitary ratio). So you'd have to transform the simulation data onto what is being shown on screen.

Michael
 
Top Bottom