I have a great problem with my 3d car racing game. in attachment there are a car image with 36 frames and the movement of car that i want.
My code dont work:
onClipEvent (load) {
//_rotation = 90;
var rot:Number = 270;
var speed:Number = 0;
var setSpeed:Number = maxSpeed;
var acc:Number = .1;
var setAcc:Number = acc;
var maxNos:Number = 500;
var nos:Number = maxNos;
var slow:Number = .98;
var brake:Number = .9;
var rotazione:Number = 0;
var rrot=0;
}
onClipEvent (enterFrame) {
_x += x;
_y += y;
rot = (speed/2)+1;
if (Key.isDown(Key.RIGHT)) {
//_rotation += rot;
rrot+= rot;
trace(rrot);
rotazione += 100;
quanto=rotazione/10;
ruota(quanto);
if(quanto>=360)rrot=0;
} else if (Key.isDown(Key.LEFT)) {
///_rotation -= rot;
rrot-= rot;
trace(rrot);
rotazione -= 100;
quanto=rotazione/10;
ruota(quanto);
if(quanto>=360)rrot=0;
}
if (Key.isDown(Key.UP)) {
speed += acc;
} else if (Key.isDown(Key.DOWN)) {
speed *= brake;
} else {
speed *= slow;
}
r=-rrot*10;
trace(r);
rad = r * Math.PI/180;
x = Math.sin(rad)*speed;
y = Math.cos(rad)*speed;
function ruota(dove){
dove=Math.round(dove)/10;
dove=Math.ceil(dove);
//per valori negativi
if(dove==-17)_root.car.gotoAndStop(19);
if(dove==-16)_root.car.gotoAndStop(20);
if(dove==-15)_root.car.gotoAndStop(21);
if(dove==-14)_root.car.gotoAndStop(22);
if(dove==-13)_root.car.gotoAndStop(23);
if(dove==-12)_root.car.gotoAndStop(24);
if(dove==-11)_root.car.gotoAndStop(25);
if(dove==-10)_root.car.gotoAndStop(26);
if(dove==-9)_root.car.gotoAndStop(27);
if(dove==-8)_root.car.gotoAndStop(28);
if(dove==-7)_root.car.gotoAndStop(29);
if(dove==-6)_root.car.gotoAndStop(30);
if(dove==-5)_root.car.gotoAndStop(31);
if(dove==-4)_root.car.gotoAndStop(32);
if(dove==-3)_root.car.gotoAndStop(33);
if(dove==-3)_root.car.gotoAndStop(34);
if(dove==-2)_root.car.gotoAndStop(35);
if(dove==-1)_root.car.gotoAndStop(36);
//posisizione
_root.car.gotoAndStop(dove);
}
}