Rewinding time

NexusxAlpha

  • Posts: 157
Edit: This is what I've got so far http://www.stencyl.com/game/play/14405

Hello everyone,

So this morning, I have had an idea for a game. I was just wondering though, if Stencyl would allow for  time rewinding. I know it doesn't have a magical block like "rewind for x seconds" but I'd be willing to look into the logic behind it. I was thinking about using an array of states, positions, velocity and inputs, but would this cause errors and dodgy behaviour like memory overflows etc?

If I were giving a user the ability to rewind 30 seconds from before their last move would this be better?

Like <player playing for 30 seconds> <user stops> <dont add any more data to array until moving again>

This would let the player rewind from the last time they stopped wouldn't it?

Thanks
Nexus

« Last Edit: August 29, 2012, 03:26:30 am by NexusxAlpha »

Sunflower

  • Posts: 591
30 seconds... with 100 updates per second it makes 3000 entries for a single value...
It would mean that if one number takes, let's say, 16 bytes (regular integer take 4, I don't know what about Numbers in AS3 or so and how it works with Arrays, so I try to come up with something relatively pessimistic) it would make astounding 48 kB per 30 seconds, or 96 kB per minute.

Or to put it other way, you can record 10 number values (e.g. xs and ys of 5 actors) every update and it'll still take less than 1 MB per minute. Not half bad, if you ask me. O.o'

Of course, it doesn't mean that you can't try some optimizing. The easiest one would be e.g. combining x and y in a single value [[ screen width ] * [ y ] + [ x ]] and then retrieve x by [remainder of [value] / [screen width]] and y by [floor of [value] / [screen width]].

But yes, how much you can optimise depends mainly on what sort of game you're making. I hope it's not a physics game. ;)

NexusxAlpha

  • Posts: 157
30 seconds... with 100 updates per second it makes 3000 entries for a single value...
It would mean that if one number takes, let's say, 16 bytes (regular integer take 4, I don't know what about Numbers in AS3 or so and how it works with Arrays, so I try to come up with something relatively pessimistic) it would make astounding 48 kB per 30 seconds, or 96 kB per minute.

Or to put it other way, you can record 10 number values (e.g. xs and ys of 5 actors) every update and it'll still take less than 1 MB per minute. Not half bad, if you ask me. O.o'

Of course, it doesn't mean that you can't try some optimizing. The easiest one would be e.g. combining x and y in a single value [[ screen width ] * [ y ] + [ x ]] and then retrieve x by [remainder of [value] / [screen width]] and y by [floor of [value] / [screen width]].

But yes, how much you can optimise depends mainly on what sort of game you're making. I hope it's not a physics game. ;)

Thanks for the info sunflower, much appreciated. It's not a physics game, its a side scroller [braid alert] lol. I'll be sure to make some sort of announcement in demo form if I get it working :)

Thanks
Nexus

NexusxAlpha

  • Posts: 157
Pretty much got it done, will upload a demo when I have worked out why at the end of the rewind, the character randomly jumps quite high (I think the Y of the character is being set to 0 for a split second before I empty the array of positions).

Edit: For some reason it was trying to return to the starting point of the player. Which was just randomly placed in the scene. Nothing to worry about lol.

ipe 369

  • Posts: 1001
This is quite interesting, i'd love to be able to see the code for this.

NexusxAlpha

  • Posts: 157
This is quite interesting, i'd love to be able to see the code for this.

Once I get it nice a smooth and easy to use I am sure I could look into making a behaviour for it for everyone. it was pretty easy to do though.