Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Pause routine for timer based programs (DBPro)

Author
Message
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 21st Aug 2004 13:19 Edited at: 21st Aug 2004 13:21
Making a pause code isn't quite as straight forward as you'd think. The problem is, that if your program uses timer based movement/physics, and you press pause, the timer still keeps running - because timers are based on the computers internal clock which you can't stop.

So, if you want to pause your game, and don't want all your timer based objects to have moved on when you return, you will need to include a timing routine into your pause code which stores the amount of time you paused for, and this can then be subtracted from the main timer in the main program loop. This pause time then needs to be added to a total pause time to enable multiple pauses throughout the game/program.

This snippet is the code for incorporating a timer and a pause subroutine into your program:

Login to post a reply

Server time is: 2024-11-23 19:22:31
Your offset time is: 2024-11-23 19:22:31