i just made a pretty simple car engine to all of u,
which is pretty easy to use or edit,
just change the variables to make
the car movement just as you want!
I know there has beeen make a topic like this before,
but that was by a n00b who stole the code from another site.
I was going to make a building hittest code too,
i will maybe add that later!
so here's the code!
onClipEvent (load) {
//variables u may change
acceleration = 2;
speed = 0;
rotation = 0;
forwardRotation = 15;
reverseRotation = -7;
maxSpeed = 16;
minSpeed = -8;
brake = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_rotation += rotation;
} else if (Key.isDown(Key.LEFT)) {
_rotation -= rotation;
}
if (Key.isDown(Key.UP)) {
if (speed<maxSpeed) {
speed += acceleration;
} else {
speed = maxSpeed;
}
if (rotation<forwardRotation) {
rotation++;
}
} else if (speed>0) {
speed--;
if (rotation>0) {
rotation--;
}
}
if (Key.isDown(Key.DOWN)) {
if (speed>0) {
speed -= brake;
} else if (speed>minSpeed) {
speed--;
}
if (rotation>reverseRotation) {
rotation--;
}
} else if (speed<0) {
speed++;
if (rotation<0) {
rotation++;
}
}
if (_rotation>180) {
_y += (speed*Math.cos(Math.PI/180*_rotation));
_x -= (speed*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y -= (speed*Math.cos(Math.PI/180*_rotation));
_x += (speed*Math.sin(Math.PI/180*_rotation));
}
}
so have fun! :)