First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: jonny shaw
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.
» Level Intermediate

Added: 2005-01-06
Rating: 3 Votes: 39
(10 being the highest)
» Author
gravitationally_challenged99@hotmail.com
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.