PDA

View Full Version : Help for my Racing Game


cekneb
07-20-2005, 09:20 PM
Hi!

i want to make a Racing Game in flash. There is a car which is driving on a track. The handbrake is SPACE. when you use it there should be skidmarks (skids). A friend of mine helped me a little bit and has shown me this code:

function skid(Handbrakey)
{
var skidleft = _root.track.attachMovie("skidmark", "skidleft"+skids, skids);
for(var i = 0;i < this.displaywheels;i++)
{
wheelsPos[i] = getPos(this["w"+i]);
if (handbrakey) {
// play hardcore squeal

skidleft.lineStyle(4, 0x000000, 70);
skidleft.moveto(this.wheelsPos[i].x-track_x,this.wheelsPos[i].y-track_y);
skidleft.lineTo(this.lastpos[i].x,this.lastpos[i].y);
}
else
{
// play gentle squeel sound
skidleft.lineStyle(3, 0x000000, 50);
skidleft.moveto(this.wheelsPos[i].x-track_x,this.wheelsPos[i].y-track_y);
skidleft.lineTo(this.lastpos[i].x,this.lastpos[i].y);
}

lastpos[i].x = this.wheelsPos[i].x-track_x
lastpos[i].y = this.wheelsPos[i].y-track_y
skids++;
}
return true;
}

Is there anybody who could help me to understand this? Some little Words?

I thank you very much

greetz


cekneb

Ricod
07-21-2005, 03:20 AM
I'll give it a shot. If someone could chek it please. It's 4.24 am here :

function skid(Handbrakey)
//A function named 'skid' is declared with a variable, Handbrakey
{
var skidleft = _root.track.attachMovie("skidmark", "skidleft"+skids, skids);
/*a variable 'skidleft' is giving the following value. So when you see 'skidleft'
read the right side instead*/
for(var i = 0;i < this.displaywheels;i++)
{
/*this is a loop. As long as the variable 'i' is less than displaywheels, the
following code should be executed, after which 'i' rises by 1;
wheelsPos[i] = getPos(this["w"+i]);
/*wheelsPos[i] is the same as wheelsPos.0, wheelsPos.1 etc. depending
on 'i's current value. It's give the value of whatever that right part is.
Another function ?*/
if (handbrakey) {
// play hardcore squeal

skidleft.lineStyle(4, 0x000000, 70);
/*the thickness is 4, the color is black and ehrm, i don't know the last
one atm. alpha ?*/
skidleft.moveto(this.wheelsPos[i].x-track_x,this.wheelsPos[i].y-track_y);
skidleft.lineTo(this.lastpos[i].x,this.lastpos[i].y);
//well, you could lookup moveto and lineTo in your help file, right ?
}
else
{
//so, if handbrakey is not true
// play gentle squeel sound
skidleft.lineStyle(3, 0x000000, 50);
skidleft.moveto(this.wheelsPos[i].x-track_x,this.wheelsPos[i].y-track_y);
skidleft.lineTo(this.lastpos[i].x,this.lastpos[i].y);
}

lastpos[i].x = this.wheelsPos[i].x-track_x
lastpos[i].y = this.wheelsPos[i].y-track_y
//set the last positions of the wheels
skids++;
// at 1 to 'skids'
}
return true;
}