Posted: 23rd Apr 2004 1:43
HEre's a code snippet that allows you to rewind time like in PoP.

Yeah i no its a lot but thats just for 60 seconds---> Dim Time(3600,3600,1)

+ Code Snippet
sync on
sync rate 55

dim Time(3600,3600,1)
make matrix 1,1000,1000,25,25
make object cube 1,10
Time=1
Speed=5
do
set cursor 0,0
Print "Move around a bit, then press R to rewind like in Prince of Persia!"
Print "Only without thouse really cool effects!"
box 10,50,10+(Time/10),60
Print "FPS: " ;screen fps()
point camera object position x(1),object position y(1),object position z(1)



if inkey$()<>"r"

if upkey()=1 then move object 1,10
if downkey()=1 then move object 1,-10
if leftkey() then dec angle,5 : yrotate object 1,wrapvalue(angle)
if rightkey() then inc angle,5 : yrotate object 1,wrapvalue(angle)
endif
if Time>3600 then Time=0



if inkey$()="r"
dec Time
sync rate 30
if Time<1 then Time=0
else
sync rate 55
inc Time
if Time>3600 then Time=0
Time(Time)=object position x(1)
Time(Time,Time)=object position z(1)
Time(Time,Time,1)=object angle y(1)
endif
posx=curvevalue(Time(Time),object position x(1),1)
posz=curvevalue(Time(Time,Time),object position x(1),1)

Position object 1,posx,20,posz
yrotate object 1,Time(Time,Time,1)
set camera to follow object position x(1),object position y(1),object position z(1),object angle y(1),100,10,2.0,0
sync
loop
Posted: 23rd Apr 2004 16:43
Wow, that array must take up a lot of memory
Posted: 23rd Apr 2004 19:15
so this just stores the position and angle of ONE object for 60 seconds....try to do this in a real game and you'll get a big headache
Posted: 23rd Apr 2004 19:31
To be a little constructive...it's a good start. You could take it further...

Record only changes in speed/direction, and time it ocurred. This has 3 advantages...

1. Less memory usage
2. Less CPU time writing to the arrays
3. Less processor hogging when replaying.

The code would be more complex, but I'm sure this could be wrapped up in a function that could poll multiple objects, and become a very useful routine.
Posted: 23rd Apr 2004 20:03
Yeah i might start developing something like that
I was inspired by that Acoders competition on time.

anyways here's a version that records 5 objects at one time and uses less memory

+ Code Snippet
sync on
sync rate 55
randomize timer()
dim Time(5,3600,1,1)
make matrix 1,1000,1000,25,25
make object cube 1,10
c=rnd(1000)
b=rnd(1000)
for t=2 to 5
make object sphere t,50
position object t,c,10,b
next t

Time=1
Speed=5
do
inc a,5
set cursor 0,0
Print "Move around a bit, then press R to rewind like in Prince of Persia!"
Print "Only without thouse really cool effects!"
PRint "Time: " ;Time
Print "FPS: " ;screen fps()
point camera object position x(1),object position y(1),object position z(1)


position object 2,500+sin(a)*50,10,500+-cos(a)*50
position object 3,500+sin(a)*50,10,570+cos(a)*50
position object 4,500+sin(a)*50,10,640+-cos(a)*50
Position object 5,500+sin(a)*50,10,710+cos(a)*50
if inkey$()<>"r"

if upkey()=1 then move object 1,10
if downkey()=1 then move object 1,-10
if leftkey() then dec angle,5 : yrotate object 1,wrapvalue(angle)
if rightkey() then inc angle,5 : yrotate object 1,wrapvalue(angle)
endif
if Time>3600 then Time=0



if inkey$()="r"
dec Time
sync rate 30
if Time<1 then Time=0
else
sync rate 55
inc Time
if Time>3600 then Time=0
for t=1 to 5
Time(t,Time)=object position x(t)
Time(t,Time,1)=object position z(t)
Time(t,Time,1,1)=object angle y(t)
next t
endif

for t=1 to 5
Position object t,Time(t,Time),20,Time(t,Time,1)
yrotate object t,Time(t,Time,1,1)
next t
set camera to follow object position x(1),object position y(1),object position z(1),object angle y(1),100,10,2.0,0
sync
loop
Posted: 23rd Apr 2004 20:05
I was inspired by that Acoders competition on time.

ah. ha! i thought so...i'm entering into that comp are you?
Posted: 23rd Apr 2004 20:07
Maybe, i'm not quite sure what kind of game to make so i'll keep it at the back of my mind somewhere.