| | | Page 1 |  | | 1 |
1. The Car
Create a movie clip and name it car
Put these actions into the movie clip:
onClipEvent (enterFrame) {
_root.speed = speed;
_root.mph = Number(speed)*2;
_root.mph -= _root.mph%1;
if (_root.mph<1) {
_root.mph = 1;
}
if (Key.isDown(Key.UP)) {
speed += 2;
}
if (Key.isDown(Key.DOWN)) {
speed -= 1;
}
if (Math.abs(speed)>20) {
speed *= .7;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 14;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 14;
}
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.boundary.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
onClipEvent (enterFrame) {
if (this._x> 600) {
this._x = -50;
}
}
onClipEvent (enterFrame) {
if (this._y> 450) {
this._y = -50;
}
}
onClipEvent (enterFrame) {
if (this._x <-50) {
this._x = 600;
}
}
onClipEvent (enterFrame) {
if (this._y <-50) {
this._y = 450;
}
}
2. The speedometer
Make a dynamic text box named speed with a variable of speed
Then make one named mph and name it mph
Place the one named speed off of the screen and the one named mph on the screen where you want the speedometer.
3. The boundary
Draw what you want the walls to be and make it all a movie clip named boundary
DO NOT EDIT THESE ACTIONS!!! | 1 |  |
|
Please rate this tutorial, 10 is the top rating, you can also click the
comments link to read/write a review.
| |
|