![Hurr Durr :crazy:](./images/smilies/ms-crazy.png)
In the examples folder you will find a LOVE project to try. Left and Right arrows to move, Z to jump and LShift to rewind the time.
https://github.com/otapliger/timetraveler
Thank you for the feedback, I really appreciated it. Yes, I will remove useless arguments and also update the readme as I forgot to mention you need to pass the delta time to the record functionzorg wrote: ↑Fri Jul 21, 2017 4:51 am I looked at the code, and i see that you only use dt in the record function to decide whether or not the beginning of the stored data should be trimmed to limit the interval one can rewind back. You could remove the argument from the other function since it's not used.
This is a good way of handling time, since the stored state is not using time-stamps, they're going by ticks... but maybe you should stress that this will only work correctly if the games it is used in use a fixed time-step. (Otherwise it might rewind with varying speeds, it should still be correct in a sense unless you also have things unaffected by such mechanics, like in braid, then it becomes an issue.)
The code for making it work with variable time-steps would be harder, since you'd need to store time-stamps so that the rewind speed would stay consistent, along with some mechanism to only allow returning to actually stored, valid timestamps, and not any in-between state that would be only for smooth rendering.
Code: Select all
-- timetraveler.lua:41
for i, v in ipairs(timeFrames) do
if os.difftime(os.time(), v[2][2]) >= M.rewindLimit then
table.remove(timeFrames, i)
end
end
Code: Select all
local time = os.time()
for i, v in ipairs(timeFrames) do
if os.difftime(time, v[2][2]) >= M.rewindLimit then
table.remove(timeFrames, i)
else
break -- skip the other timeframes once we encounter a timeframe that is within the rewindLimit,
-- since all following time frames will also be within the rewindLimit.
end
end
Code: Select all
tick = tick - 1 / M.fps
Code: Select all
tick = tick + dt
while tick >= 1 / M.fps do
now = {}
for i, v in ipairs(properties) do
table.insert(now, {v[1](), os.time()})
end
table.insert(timeFrames, now)
tick = tick - 1 / M.fps
end
Users browsing this forum: zingo and 1 guest