At 5/23/12 03:14 PM, egg82 wrote:
At 5/23/12 02:53 PM, SketchistGames wrote:
Ok, could someone help me? I am making a new platformer game but I wan't it to have a twist, the main character has the ability to "travel back in time" like in the game Dusk 2 If this is in the wrong forum I will delete it and post it in the correct one thanks :D! Please help however you can!I've actually thought about this before (i've never implemented it, was just thinking for fun) - but i've never solved it.
I'll think aloud here (just some things that come to mind), and see if any of this helps.
Think of time as a variable
use arrays to store the last movement data? (Ie ran left for x seconds, right for x seconds, jumped...) - use the time variable to control how far back it goes
that's all i'm able to come up with at the moment
thought about it some more. I can get more specific on my theory
you can do this one of two ways:
one: create one array for movement. You could constantly record the player's position (every quarter or half-second) and reverse those steps be moving backward through that array, clearing each variable it passes. The reason you clear them as you pass them is if the player wants a "drop-off point" somewhere in the middle of that array, then you still have the start of the array as a buffer in case they want to go back again.
or two (this is the one I like): create one array for movement and one array for time. Each time the player presses a key, record the key and the time started. When the player releases the key record the end time. This will decrease the size of the array and speed up your program (as compared to the first method, which is constantly checking. This method only "checks" when something happens) - then use logic to run back through the steps, same as method one. The reason for the time array (if it isn't obvious) is because the timer isn't a constant. It's an unknown.
I'm forgetting something, but I can't remember what. Anyway, I hope that explains more.