This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by senjutsuka

What would be the most optimum way to do time reversal in a simple game?

A good example would be taking the Box2d demo or the canvas demo with the little jet pack guy and allow it to add a time reversal functionality such as seen in Braid.

Anyone have any ideas on this. There seems to be discussion about it from a theory stand point out on the web, but not in relation to this engine or to box2d physics.


1 decade ago by paulh

record the xy position of the player and sprites in array for x seconds, play it back ;-)

But funkier than that :-D

1 decade ago by senjutsuka

Yeah it'd have to be funkier then that. The floating point math in box2d would have issues going backwards. Aside from that I dont want to record just the player, I want to record the entire game state and reverse it. The most reliable way seems to be every action records to a stack with a time stamp of sorts, then a key frame is created every x seconds to record location data of each entity. This, in reverse, will help alleviate the math issues.

Problem is Im not entirely sure what the best approach to doing this is with the vector/force/impuse etc that comes w/ box2d. As is, every action is on the ms scale b/c it uses accurate gravity etc. Putting that on a stack seems like overkill. Maybe using box2d is just a bad idea for this b/c its tick based physics instead of constants such as speed etc...

1 decade ago by Mediamonkey

Then don't use a stack (array), but a linked list.
For recording, you can take the head node, overwrite the data and place it at the tail.
That way the list will stay the same length and it's the quickest way to read/write data.

1 decade ago by quidmonkey

Set up a sample rate and cache each sample. Your sample should be an object with a timestamp, position and animation. For playback, you can interpolate between the samples.
Page 1 of 1
« first « previous next › last »