So I am making a simple game like "the impossible game" where the character just moves forward(from a 2D prespective) and the only thing you have to do is press the screen to jump at the correct time to avoid crashing into obstacles.
My record algorithm is quite simple:
onJump()
{
events.append(player.pos.x);
}
And my replay is:
onUpdate()
{
if(player.x==events[nextevent])
player.jump();
}
Everything works O.K but sometimes in extreme situations(the player jumped just before he crash on an obstacle)while the player didn't actually crash, on replay the player crashes. I know this is happening because of the delta time(different delta on record and on replay). How can I fix it without having the need to record my delta time too?
EDIT:it seems that many didn't actually understood my question ,the question is not how to implements a replay system (knight666 answer is full and complete and it deserves the accept but its not what i asked) but how to deal with the changes of delta time.for example ,lets say the player jumps just before he crash ,while he is still in the air he passes 1 pixel away from the obstacle and it doesn't crash, but in the replay cause the delta can happen to be different than the delta while it was recorded the player passes -1 pixel away from the obstacle and it crashes.