Invalid Position
Invalid Position
internet.com home logo
 
Flash Jobs
Invalid Position
 Top : Games 

Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


hardware central logo
Invalid Position
Invalid Position
» Level Intermediate

Added: : 2003-01-06
Rating: 7.04 Votes: 132
Hits: 9122

» Author
I have been using flash for about a year now and am learning at a high rate.

» Download
Download the files used in this tutorial.
Download (107 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Invalid Position
Simple GTA Style Car Game
Author: Dan Doheny |
 
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.
10987654321Read or Post Comments