It sounds soo good but I'm totally novice I'm very grateful for the support and I have had troubklewith the size of the laps.
Let me tell you: At first I did all laps i 1 flash and got to the knowledge that I had to split it to lapby lap movies and load in levels. I have made an 80 lap movie in a high framerate and it was almost 50MB.
Thanks for the response - I will try to post a movie here using arrays to control the car positions sometime this weekend. That should now be quite straightforward because I have almost finished another which I will post today, which uses mapping arrays to hold information on moveable limbs of a human figure,
The whole subject of controlling a group of objects in concert, on a timeline, is applicable to your grand prix circuit, to animation of a player in a Doom scenario and many other games where either the game player initiates a sequence (e.g. encountering a combat attacker)
or in your case a list of lap-times is used to control motion.
You need to do two two things to customize it for your own program.
Make your Grand Prix background be a button and use it to exactly map your track layout starting on the Finish Line and going around the track in 32 equal steps, clicking on the red track. My demo program here does just that but you need to do it using your actual layout, and also for other tracks like UK, Germany etc.
The program is smart enough that when a racecar completes a lap it gets its new(future) laptime and that sets the speed for the next lap for that car. You can see it in the lower straight track which is used to calculate where it should appear in the circular track.
I am quite pleased with the result technically and as you can see I chose to use the colored number decals for each car rather than just a number, the car actually being a button with a color and a number.
Button shading techique and other graphics could be employed here too.
Interesting to see arrays in action, it will take a while before I understand it!
Can you look at the attached file with v3.72 please so you can follow me...
I think that the correct traveltimes is needed to make it interesting to view, and the point of beeing able to edit one traveltime where an driver makes a mistake and seeing the other drivers overtake him there in that corner is far away! The equal traveltimes between the array points is not allright.
Maybe I should have attached this file the first time but I thought that v4 was nessecary and I thrue it together fast... I'm sorry for that if it is the case! In 1 lap there is only 3 times I need to edit the traveltime the rest of the lap can be the same with all cars...
I would like to use the v4 acceleration effect on the straight also...
When I found 3DFA I was happy because it made it possible and I made lap-replays and even full-racereplays, but I soon found out that it was to much work (5 laps done in 3 hours with move thrue keypositions).
I think that it will take me a while before I get it done more simple and I only know that when 3DFA allows seconds to be variables in travel thrue keyposition or duration in v4 to be variables - then I would be able to get what I want on my own.
I'm happy to ask here for help and it is the only way to get me somewhere, when duration/seconds canot be variables in 3DFA, in some way I think that scripts is the solution and I think:
* a script like you've done defining arrays
* and a load that tells how much time to travel between the arrays in detail
* then 3 times a lap a possibility to edit a traveltime for each car
It should be possible with 3DFA it sound to me and with your positive help I think I'm pushed forward... Thanks again, this forum should be awarded because of the people here!
Have a look at the LapData array for the cars number 22,18,14 and 12
You will see that the laptime e.g 22 is 62.5 seconds
Thats the only information for Lap1 for car #22
If we add more functionality into the arrays we could
1. Set a value like 0 or -1 in LapData to show a crash
2. acceleration points in the Track array to show where valid
3. (more difficult) When /where overtaking one by another
The problem with just a lap time is that the cars travel at a constant speed where S=distance/laptime
but this is just a beginning. Other than the laptime you would need to record when and where the events took place if this is to be a faithfull repro of a past race.
so now the data for a car would be something like
Car ID 22
Lap no 01
Track # 14 ---- 14th section of the 32 section track
Event ---------- Some event like crash or stall, accelerate/decelerate
Now its going to get more complex to program, but all of this is do-able. Car 22 could reach #14 in the track, accelerate to 1.5 times the current lap speed then reach #15 and slow down again etc etc
Problem is you are never going to reproduce the actual race with all its nuances, short of having black box recorders for each car (which this application is trying to become.) Your manual setting of moving_object_through_posistions is hampered by the same, and the more points you do in this method the greater the flash overhead becomes.
By adding more design thought and with the sensible use of arrays you could develop a system where you maybe have arrays holding key interaction data (one per car?) which is highlight information. But that comes back to Is this a true repro or an artistic rendition ?
As it is now the cars do lap each other as the race proceeds but at an unchanging circuit pace because the speed is constant for a given car for a given lap. Looking at my attempt again I see that the first change should be how a car moves from one track position to the next. Currently I start at Position x1,y1 and know I need to move to x2,y2 on your non-uniform track with its straights and bends.
The cars on the non-uniform track have NO VELOCITY and are moved in [remaining_distance/47] steps while the cars on the straight reference track have the uniform velocity determined at the start of each lap. 47 was a number arrived at during testing, I tried values from 5 to 100 I hope you understand all this and 47 is easy to find in the code.
Currently I move 1/47th of the remaining gap distance per move to allow for correction errors, so the first steps are larger than the final steps. I should probably determine the dead-reckoning angle and then move in that direction at the current speed for n seconds and then stop and calculate the direction for the next dead-reckoning step. That would be my next version change.
I cannot discuss much, since all is new to me, what I can do is breif you on a little background and what not.
The attached file is what the game league manager releases after recieving racefiles from every driver, and as you can understand, it is a cool thing to grab a work and make a replay of the race, it is appriciatedby the drivers in the league ad there are plenty of leagues that could have fun with this (mainly since the gamedoesn't support multiplaying over internet).
And the data I could recieve from the manager of a league or the drivers themself,look like this:
Driver Car LN RP FP Fuel Wght Split1 Split2 Lap_Time Session_Time AvPO SDur F1 F4 F7 OT TWLR TWRR TWLF TWRF
sören östmark #21 0 13 13 16.9 644 -:--.--- -:--.--- -:--.--- 0h00m04.601s 0% 0.0 0 0 0 0.00 0.00 0.00 0.00
sören östmark #21 1 9 8 15.9 642 0:34.703 1:02.844 1:24.689 0h01m29.290s 78% 0.8 0 0 0 0.08 0.08 0.06 0.07
LN=Lapnumber the interesting bits is Split1, split2, Lap_time and Session_time wich is the things I've been using when I've made it before. The lap could offcourse be handled in 3 different movies, if it simplifies the different values at the split1 a.s.o.
As long as there is a simple way of editing. To copy lap 5 and name it lap 6 and then edit only at split1, split2 and lap_time.
The way I did it in v3.72 made the race-replay very true to what had been done by the drivers since I edited at split1,split2and lap_time but I needed about 500kb for each lap and 50MB webspace to put the 80 lap race and the whole procedure took 3 hours for 5 laps (much of what I did was just copiesof previous laps since I didn't get to edit the laps)
I tested loadvars and got that to work and I thought if only I could get the drivers themselfs to sendme a variable-file then everything would be speeded up and then I found out that time and duration cannot be variables (not in move element thrue keypositions or 'move to' -actions), I got a scriptexample from another one in this forum and he had a 3000milliseconds pause done with that scriptaction and I managed to shift that pausetime with a variable but weinded up in trouble when I considered how it would work at split1 for one car at a time when the cars reach split1 at different pace and so on... It troubles my mind!
I do think that your talk about filesize and efficiency is of importance, and I do see that arrays can do me good, it feels like the natural way to make a race replay, if only the programming can keep in mind what car to do what with . I remember the days when I programmed BASIC with the C64 and made a DATA code ,I made backgroundpictures and moved things over the background...
There is not 1 thing I know about actionscripts/Java butwith the experience of programming with BASIC and C++ and pascal I find similairities and can figure out a little.
Have a look at the LapData array for the cars number 22,18,14 and 12
You will see that the laptime e.g 22 is 62.5 seconds
done that and my stopwatch said that car 14 does the 1st lap in about 33 seconds and car 22 does the first lap in about 44-53 seconds...
When it is here you talk about:
lapdata[22] = new Array(62.5,60,60,57)
// you have the 4 laptimes there between the commas
// and lapdata for car14 is
lapdata[14] = new Array(68.5,67,69,67)
// soo I'm confused
It must be a speed velocity setting for travelling... It could be useful the whole thing you've done, if I only disregard the actual driving and want to show the relation/distance between the cars at all laps. (which always have been the case- to see the distance between the cars correctly)
It will be fairly easy to add more arrays/travelpoints so that the cars go a little more on the tracklayout, i see, and yes with my stopwatch I can get things close to real-times ...
What I really need to have implemented in what you've done would be to start a lap with up to 95 second gap e.g:
*car 22 starts its lap and runs it
*95 second later car 14 enters the lap (soon to be lapped by car 22) and runs it
* the lap should stop when leader of the race crosses the finshline or go automatically into displaying the next lap with the leader of the race and continuing with the other cars
// you have the 4 laptimes there between the commas
// and lapdata for car14 is
lapdata[14] = new Array(68.5,67,69,67) * * * in a 3 lap race * * *
// soo I'm confused
It must be a speed velocity setting for travelling... It could be useful the whole thing you've done, if I only disregard the actual driving and want to show the relation/distance between the cars at all laps. (which always have been the case- to see the distance <
between the cars correctly)
<<< This could be done with more work...>>>
It will be fairly easy to add more arrays/travelpoints so that the cars go a little more on the tracklayout, i see, and yes with my stopwatch I can get things close to real-times ...
<<<yes >>>
What I really need to have implemented in what you've done would be to start a lap with up to 95 second gap e.g:
*car 22 starts its lap and runs it
*95 second later car 14 enters the lap (soon to be lapped by car 22) and runs it
* the lap should stop when leader of the race crosses the finshline or go automatically into displaying the next lap with the leader of the race and continuing with the other cars
<<<again.. yes this could be done...>>>
This could become a very cute program We need to design it correctly so please define what is required. Here are the first two 'rules'
Rule #1: Vehicles start a lap with up to 95 second gap from the previous starter and run (n) laps.
Rule #2: the lap should stop when leader of the race crosses the finshline or go automatically into displaying the next lap with the leader of the race and continuing with the other cars.
If you follow through the design based on what we know that an array can hold specific rows of data for a given car for a given lap, then we can extract the data at a specific time and point on a lap to either place a car or change one of its parameters.
A racecar or flight simulator holds similar rows of parametric data during its simulation for a flight right down to (and most importantly) engine parameters, so we are not exactly breaking new ground here but you can expect to program an exeedingly good simulation using 3dfa scripting.
By the way - go look at my Kung Fu Monkey post and download the swf and then click the Playback button. You will see the monkey perform. This is EXACTLY the same technique. There are 14 moveable parts in the humanoid so equate that to 14 cars in a race.
As the monkey performs 'the race' is run and each part ('car') has classic rules for a skeleton
Rule #1 "The leg-bone is connected to the ...thigh-bone..." etc
Rule #2 Joints have rotation
14 bones with a position in x,y flat 2D representation of a skeleton and a rotation
so I have 14 x 3 = 42 datapoints in the array for each step in the dance = 'step along your racetrack'.
So, for my monkey movie I chose 50 steps in the dance choreography and 42 datapoints producing... an array of lapdata[50][42] for my movie = 2100 datapoints
If my monkey has a 3D z-axis then I would need 14 x 4 x 50 = 2800 and a different kind of program to show 3d-skin.
The last thing you mentioned was something about chopping it all up and having array points and moving the cars from one array to another and repeating to get the lap done, it sounded great(It would produce a lap with the correct time spent over straights and thrue corners,I suppose), I don't know about the effort needed to map up the lap translating seconds into velocity over the whole lap (which would be needed once for the whole race)and at 3 moments of every lap I would ask myself:
"How much is 3.5 seconds in velocity between this and that array, and what velocity is 3.4 seconds between the same arrays? (for up to 22 different times - maximum is 22 cars in the race)"
I'm aiming at making x-y's in array's but sticking to pairs and expressing a velocity of movement between the places for the object, i.e. not the whole track x and y's in array's and a velocity for the whole lap as done in this example.
I'll need to spend some time on breaking this(the example made by carnwath) down and understanding:
1. the action that makes the movement from x-y to x-y
2. some simple way of scaleing the travel into correct velocity
Since it is very important for me to be exact(with the timeing) with the car travel through the turns and straights...
carnwath - the division by 47 in the actionscript sets the 2pixel movement of the track-car going... I need to get some timeing into that place and a variable might be more correct.
As you can understand I'm making progress, I have split down your movie and made a 1 car story of it (instead of 4).
Still your 60 seconds lap done by car22 was a slower lap than the 68 seconds lap done by another car and that lapdata-array-story needs some thinking how I could use it... But I think I allready know that I could shift over a low number to create more velocity, than a high number.
I want to split the track into 40-60 small legs(each corner and straight beeing 1 leg each) and I want to hold it in arrays and move everycar the same speed/time at every leg, except at 3 legs where I want to tweak each car in different speed/time.