News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Playback Time

Started by dangerousbrian, July 13, 2005, 12:43:02 PM

Previous topic - Next topic

dangerousbrian

I'm convinced my racegame is as good now as I'm ever gonna get it. However I would really like to replay the last 10 secs of the race, showing the runners crossing the line. I know its possible, but I haven't got a clue as to what commands are used, Can any one help?

kevin

arrays are your friend !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

:)

dangerousbrian

#2
Damn! (I haven't used arrays throughout the programme! :angry:

kevin

I noticed.. :).. But seriously Using them will reduce the size and improve the flexibility of your program(s) dramatically

dangerousbrian

What sort of info goes into the array(s)? :blink:

dangerousbrian

The offers still open for a professional to write this properly! (Although I've enjoyed the learning experience!)

kevin

#6
Numeric data, Strings, or user defined types


I.e.



; Create an Array called Highscores. This array has 10 data slots within it
 Dim HighScores(10)

; store  high score 1 in the HIghscore array at position #1
 HighScores(1)=10000

; store  high score 2 in the HIghscore array at position #2
 HighScores(2)=9000
; etc etc
 HighScores(3)=8000
 HighScores(4)=7000
 HighScores(5)=6000
 HighScores(6)=5000
 HighScores(7)=4000
 HighScores(8)=3000
 HighScores(9)=2000
 HighScores(10)=1000


; Display the highscore list

For lp =1 to 10
 print   HighScores(lp)
next

sync
waitkey


kevin

#7
Here's another more powerful example. T his one creates an array, fills it will random numbers, sorts the array into order, then displays the resulting sorted Array






; Create an Array called Highscores. This array has 10 data slots within it
Dim HighScores(10)

; Fill the highscore array wityh random values

For lp =1 to 10
 HighScores(lp)=rnd(10000)
next


; Sort the Array from element 1, through to 10
SortArray HighScores(),1,10

; Display the highscore list

For lp =1 to 10
print   HighScores(lp)
next

sync
waitkey





dangerousbrian

#8
so........ during the last 10secs I make the program write into an array the data concerning the positions of the runners (& presumably all the other sceery positions), then on the right key press it replays?

It seemed so simple when I read it in an email!
quote
 "It's just buffering up all the positions/ animation frames. Then to replay the race/game you can just show each scene at any frame during the race."

kevin

#9
yep.  

So if the game updates at 60 times per second, then each time the frame is drawn you'd store the screen positions all of the racers, the backdrop, the scores, the time (whatever you need) to redrawn this frame as it was later  

Then to offer a replay, you would write a version of the your display routines that read the Replay arrays at a certain frame and displays the screen as it was.

This will allow you to move back/forward, even have a slow motion.  (Pause between replaying frames) or even a fast forward

I'll write you a little demo with the mouse.

dangerousbrian

Thanks Kevin! (I've got more blue blocks under my name - hope this doesn't mean someone is going to be silly enough to ask me stuff!)

kevin

#11
more than likely  ;D

Here's a bit of an example  Capture Mouse Movements

dangerousbrian

That's impessive Kevin! Even tho I work hard at this stuff because it interests me (& it's good for business!) this could still take me months to work out. I still think I need a pro/gifted amatuer to write this for me. I'd really like you to do this, but if you haven't got the time is it ok with you if I respond to Draco's interest?

dangerousbrian

My brain is now bleeding! Well at least it feels that way.......Never have understood arrays. Crashes everywhere! (I'm goin down to the bar to get drunk!)