Project+Formula+1

= = = = = = =**Formula 1** =

Despite the name, this has nothing to do = = = with the F1 club that we have in this school. = This game involves:


 * 2 players
 * 2 cars
 * 2D track/field
 * 4 checkpoint gates

It is a two-player racing game!

Basic Movement
As usual we start with the basics. Look at the following code. code onClipEvent (load) { speed = 4; spinRate = 5; function bound { if (this._x>=420) { this._x = -19; }         if (this._x<=-20) { this._x = 419; }         if (this._y>=421) { this._y = -20; }         if (this._y<=-21) { this._y = 420; }    } } onClipEvent (enterFrame) { bound;// keeps you on the screen if (Key.isDown(Key.RIGHT)) { this._rotation += spinRate; }    if (Key.isDown(Key.LEFT)) { this._rotation -= spinRate; }    if (Key.isDown(Key.UP)) { actualAngle = 90-this._rotation; mathAngleInRadians = (actualAngle)*Math.PI/180; this._x += Math.cos(mathAngleInRadians)*speed; this._y -= Math.sin(mathAngleInRadians)*speed; } } code

Notice the movement code. Now paste it on a triangle that you draw on the screen (acute angle facing up). Here is what it should look like:

media type="file" key="basicMovement v2.swf" width="297" height="224"

Complex Movement
You see, the complex movement is called complex because it considers acceleration.

Here is what is looks like:

media type="file" key="f1 project 3.swf" width="508" height="508"

Look over the previous code. What do you think you need to change?

(November 15, 2010) Note: we will not post the source code. If you have questions, please ask in discussions section and we can give code //snippets//.

The Final Result!
media type="file" key="f1 project 5.swf" width="500" height="500"

Don't drive off the road!

Spin-off Game! Bumper-cars!
media type="file" key="f1 project 7.swf" width="495" height="495"