Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author Miguel Panos
»  Title: Tarta
»  Description: It is a circle graph or pie chart that takes the data entered by user
»  More by Miguel Panos


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4839 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  AuthorDeft Creative Ltd
»  Link: Home Page
»  Description: Portfolio site for .DeftCreative Ltd. A UK based web design studio specialising in flash websites, games and interactive CDROMs. With an emphasis on making things different.


Random Links | Add your own Flash Related Links
Flash Tutorials 1484 Tutorials 7 New Tutorials Added!
What's New | Top100

» Making Automatic Training Screen Capture Easily
» Create Undersea Life Animation
» Making Deinterlace Video with a low bitrate Easily
» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» Unknown Tag: Title10
Random Tutorial | Add Site


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

Search Tutorials


Tutorials Tutorials » Games

Categories Realistic Car Rotation game including lap counter
Author: jonny shaw

 
Page 1
1

Put a static text on the stage saying: How many laps? or anything similar to that. Then create an Input text on the stage with a variable name of Number. Lastly on this frame put another static text saying Next or Enter. Press F8 and make it a button with the code: on(press){ _root.gotoAndStop("2") } on(keyPress""){ _root.gotoAndStop("2") } This basically says when the mouse is pressed/the enter key is pushed it goes to the next frame. Next add another frame. In this frame Make a car for you and a car for your opponent(they are both movie clips). A hint is to make your car a square or rectangle because otherwise parts of the movieclip will it the wall and bounce off when they aren't actually part of your car(name the car myCar and the opponent enemy). In your car put this code: onClipEvent (enterFrame) { // make the car go forward if (Key.isDown(Key.UP)) { speed += 1; } // make the car go backwards if (Key.isDown(Key.DOWN)) { speed -= 1; } // tells the car to slow down after the speed of 20 if (Math.abs(speed)>20) { speed *= .7; } // you can change the rotation of the car to your desire if (Key.isDown(Key.LEFT)) { _rotation -= 15; } if (Key.isDown(Key.RIGHT)) { _rotation += 15; } // here is where the hittest is for the boundary speed *= .98; x = Math.sin(_rotation*(Math.PI/180))*speed; y = Math.cos(_rotation*(Math.PI/180))*speed*-1; if (!_root.land.hitTest(_x+x, _y+y, true)) { _x += x; _y += y; } else { speed *= -.6; } if (this.hitTest(_root.wall1)) { speed *= -.7; } } Copy that last if test for every wall movie clip you have on the stage. Next go into the opponent movie clip and animate it going around the track at an even pace. Next draw the track you want to race in. The track must only consist of straight lines. Make each straight line a seperate movie clip making each of their instances names wall1, wall2, wall3 etc depending on how many walls you have. Make two Dynamic text boxes called Laps and Laps1. Next make a finish line and two other invisible lines anywhere on the track(name the two lines L1 and L2. The finish line can remain nameless). In the finish line put the code: onClipEvent(enterFrame){ if (this.hitTest(_root.MyCar) and _root.LastLine=="1"){ _root.Laps++; _root.LastLine="2"; } } onClipEvent(enterFrame){ if (this.hitTest(_root.enemy)){ _root.Laps1++; } } Now make a white flag in the middle of the track above the finish line called flag. Go into it and animate it waving back and forth. in the flag put in the code: onClipEvent(enterFrame){ if(_root.Laps==_root.Number-1){ this._visible=true; } } onClipEvent(enterFrame){ if(_root.Laps1==_root.Number-1){ this._visible=true; } } onClipEvent(enterFrame){ if(_root.Laps==_root.Number){ _root.laps= _root.Laps+ " = your laps"; _root.laps1= _root.Laps1+ " = computers laps "; _root.gotoAndStop("3") } } onClipEvent(enterFrame){ if(_root.Laps1==_root.Number){ _root.laps= _root.Laps+ " = your laps"; _root.laps1= _root.Laps1+ " = computers laps "; _root.gotoAndStop("4") } } Now in this frames code put the following: _global.LastLine=""; Laps=0; Laps1=0; setProperty("flag", _visible, false); stop(); Now make 2 new frames. In frame 3 put a static text box saying You won. put two dynamic text boxes called laps and laps1(make sure these are in lower case and the other ones earlier were in capital letters). In frame 4 do the same(static and 2 dynamics) but the static text box says You lost. Thats it if you completed this tutorial please email me at gravitationally_challenged99@hotmail.com and tell me if you liked it or not.

1

» Level Intermediate

Added: : 2005-01-06
Rating: 3.09 Votes: 40
Hits: 734
» Author
gravitationally_challenged99@hotmail.com
» Download
Download the files used in this tutorial.
Download (0 kb)
Get conversion and unzipping tools for PC and Mac here!

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

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments