How to code Time Stop or Bullet Time in a game?
- by David Miler
I am developing a single-player RPG platformer in XNA 4.0. I would like to add an ability that would make the time "stop" or slow down, and have only the player character move at the original speed(similar to the Time Stop spell from the Baldur's Gate series).
I am not looking for an exact implementation, rather some general ideas and design-patterns.
EDIT:
Thanks all for the great input. I have come up with the following solution
public void Update(GameTime gameTime)
{
GameTime newGameTime = new GameTime(gameTime.TotalGameTime,
new TimeSpan(gameTime.ElapsedGameTime.Ticks / DESIRED_TIME_MODIFIER));
gameTime = newGameTime;
or something along these lines. This way I can set a different time for the player component and different for the rest. It certainly is not universal enough to work for a game where warping time like this would be a central element, but I hope it should work for this case. I kinda dislike the fact that it litters the main Update loop, but it certainly is the easiest way to implement it.
I guess that is essentialy the same as tesselode suggested, so I'm going to give him the green tick :)