script for overhead car game so far i have just used a tutorial to get this code:
onClipEvent (load) {
downCapture = new Object();
downCapture.onKeyDown = function () {
switch (Key.getCode()) {
case Key.LEFT: left = true; break;
case Key.RIGHT: right = true; break;
case Key.UP: up = true; break;
case Key.DOWN: down = true; break;
}
}
Key.addListener(downCapture);
//listen for key returns
upCapture = new Object();
upCapture.onKeyUp = function () {
switch (Key.getCode()) {
case Key.LEFT: left = false; break;
case Key.RIGHT: right = false; break;
case Key.UP: up = false; break;
case Key.DOWN: down = false; break;
}
};
Key.addListener(upCapture);
rotateBy = 9;
accelleration = 5;
function radtodeg(deg) {
return (deg/180) * Math.PI;
}
}
onClipEvent (enterFrame) {
if (left) { _rotation -= rotateBy }
if (right) { _rotation += rotateBy }
if (up) {
if (accelleration < 10) {
accelleration++;
}
angle = _rotation;
angle = radtodeg(angle-90);
by_x = accelleration * Math.cos(angle)
by_y = accelleration * Math.sin(angle)
_x +=by_x
_y +=by_y
}
}
There may be a few errors as after 30mins of staring at a screen trying to figure this out i got bored and typed out how i think it went copying exactlly roughly the last 10lines.
My question is: how would i stop the car from rotating on the spot. I just cant figure it out!