I made a simple car engine for everyone to use. Why? Why did I make this for eveyone? Because I love everyone (except....maybe Wesley Snipes).
Anyway. With this code you can make things like this:
Car thing
Ok, so heres the script:
onClipEvent (enterFrame) {
// right
if (Key.isDown(Key.RIGHT)) {
_rotation = _rotation+move;
}
// left
if (Key.isDown(Key.LEFT)) {
_rotation = _rotation-move;
}
// up
if (Key.isDown(Key.UP)) {
if (move<8) {
move++;
}
} else if (move>0) {
move--;
}
// down
if (Key.isDown(Key.DOWN)) {
if (move>-10) {
move--;
}
} else if (move<0) {
move++;
}
// _x & _y position
if (_rotation>180) {
_y = _y+(move*Math.cos(Math.PI/180*_rotation));
_x = _x-(move*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y = _y-(move*Math.cos(Math.PI/180*_rotation));
_x = _x+(move*Math.sin(Math.PI/180*_rotation));
}
}
Put this script into a movie clip, and WHAM!! you have a car-ish thing. Also throw some hitTest's in it and you can do more than just.....drive it around.
Theres really not much I can explain, you'll understand it if you know basic / intermediate maths. Which can be found here:
Maths basic
Maths intermediate
Well, there ya go. Have fun.
Also, Note: I would recommend 24 fps, in case you don't know how to edit the speed and what not.
2b r not2b lawl
