Live data from Hacker News

Game devs explain the tricks involved with letting you pause a game

kotaku.com

1–10 of 273 posts

Re: Game devs explain the tricks involved with letting you pause a game

#4

Not sure if slowing down time is the right approach. The best approach would be using something like if(game_is_paused) return; in the game loops.

It depends on how your timers are implemented. If they are implemented as a "rendez-vous" absolute date (as in UTC for instance - not in local time unless you want to add "eastern eggs" related to daylight saving time...), this will cause bugs. If you implement your own in-game monotonic clock that you can stop, it should be ok.

Re: Game devs explain the tricks involved with letting you pause a game

#5

Not sure if slowing down time is the right approach. The best approach would be using something like if(game_is_paused) return; in the game loops.

Games are multithreaded and have loads of objects running everywhere. If you're using anything that's not a custom game engine, there really isn't a single main() function that you can plop an if statement like that into.

Slowing down time applies it universally. Otherwise you're going to need that condition to every single object in the game.

Re: Game devs explain the tricks involved with letting you pause a game

#6
post #4

Not sure if slowing down time is the right approach. The best approach would be using something like if(game_is_paused) return; in the game loops.

It depends on how your timers are implemented. If they are implemented as a "rendez-vous" absolute date (as in UTC for instance - not in local time unless you want to add "eastern eggs" related to daylight saving time...), this will cause bugs. If you implement your own in-game monotonic clock that you can stop, it should be ok.

>If they are implemented as a "rendez-vous" absolute date

Do people actually do that? What's the plan for when the user sleeps their machine? All the events just inexplicably happen all at once when they wake it?

Re: Game devs explain the tricks involved with letting you pause a game

#7

Not sure if slowing down time is the right approach. The best approach would be using something like if(game_is_paused) return; in the game loops.

The slowing down thing sounds like a hack needed for engines that don’t give you control over the main loop.

I haven’t tried this yet, but for a custom engine I would introduce a second delta time that is set to 0 in the paused state. Multiplying with the paused-dt „bakes in“ the pause without having to sprinkle ifs everywhere. Multiplying with the conventional dt makes the thing happen even when paused (debug camera, UI animations).

Re: Game devs explain the tricks involved with letting you pause a game

#8
One of the things that impressed me in Quake (the first one) was the demo recording system. The system was deterministic enough that it could record your inputs/the game state and just play them back to get a gameplay video. Especially given that Quake had state of the art graphics at the time, and video playback on computers otherwise was a low-res, resource intensive affair at the time, it was way cool.

It always surprised me how few games had that feature - though a few important ones, like StarCraft, did - and it only became rarer over the years.

Re: Game devs explain the tricks involved with letting you pause a game

#9

One of the things that impressed me in Quake (the first one) was the demo recording system. The system was deterministic enough that it could record your inputs/the game state and just play them back to get a gameplay video. Especially given that Quake had state of the art graphics at the time, and video playback on computers otherwise was a low-res, resource intensive affair at the time, it was way cool. It always s…

I wish I kept my demo files!
Post reply on HN