Racing game tutorial flash




















I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit. Advertiser Disclosure. A Flash Developer Resource Site. First time here? Developer Channel FlashKit. Tutorials Home. What's New. Top Rated. By Flash Junkie. This is the first part of a long step-by-step article that will guide you through the entire process of creating a Flash game including input management, basic physics, collision detection and a lot more!

Add further visual excitement and interactivity to your game will scrolling terrain. Create this game. Defend the TNT beneath the grass by blowing up any incoming airplanes and the bombs they drop.

Hangman is a popular game which can be coded using a few symbols and a short amount of code. This tutorial is intended for intermediate or advanced users of ActionScript. This tutorial will show you how to shoot bullets to destroy objects, in Flash games. The Math class implemented in Macromedia Flash does not work with angles measured in degrees.

Instead we will have to provide angles measured in radians an alternative unit measurement for angles. Why do we do that? So what we do here is force the car to steer right.

OK, I guess everything is clear up to this point. To simplify things we will take the Left Side Point as an example. But the car will not always have an angle of 0. Well, here comes the tricky part. And again back to our Actions Window. Why the car will not move in the first frame? Those variables will be used to store the exact time when the race started initialTime and the exact time when the current lap started lapTime.

And instead of increasing the number of laps with one, you will increase it with two, ten or one hundred laps, so the race will be ready quite fast. This problem can be solved in a few ways but we will chose the solution that fixes both our problems: we will add a checkpoint the red line to the left. This checkpoint will be placed somewhere around the middle of the race so that the player will lose more time returning to the finish line than he will lose by completing the lap.

Of course if you want a more secured race you will add more than one checkpoint. Drag your racer to the starting position in front of the finish line. You'll do this in the left-hand pane. Doing so will ensure that your racer is in the correct starting position when you go to create your script. The racer will stop once it touches the finish line, so make sure the racer is in front. Part 3. Click the Scripts tab.

You'll find this at the top of the Scratch page. Click Events. It's an option just below the Scripts tab. Doing so brings up a list of event-based code brackets. Add the "when flag clicked" event to the pane. Click and drag the "when [green flag] clicked" icon onto the right-hand pane, then release it there. Click Motion. This blue link is in the Scripts section. Add your racer's starting location. This will determine where your racer starts whenever you begin a new game: Place your mouse cursor over your racer.

Review your racer's x and y coordinates just above the upper-right side of the "Sprite" window. Drag the "go to x: 16 y: " event to fit under the "when flag clicked" event. Double-click the "16" text box, then type in the x value. Change the starting position. Drag the "point in direction 90" event from the "Motion" menu to fit under the "go to x y" box. This will ensure that your car is facing the correct direction when the flag is clicked.

Indicate which costume to use. Click Looks , then drag "switch costume to costume2" to fit below the starting position, click the "costume2" box, and select costume1. This causes your racer to revert to its non-crashed costume when you reset the game. Part 4. Add a movement script. This is the script which your racer will use to move forward: [1] X Research source Click Events. Drag the "when flag clicked" event onto the pane, separate of the first "when flag clicked" script.

Click Control. Drag the "forever" event to fit below the "when flag clicked" script. Click Motion , then drag the "move 10 steps" option to fit in the "forever" slot. Create controls. You'll use the following script to assign turning controls to your racer: Click Events , then drag the "when space key is pressed" event onto the pane twice.

You should have two separate "when space key is pressed" events. Click the "space" text box on one "when space key is pressed" event, then click left arrow in the drop-down menu. Click the other "when space key is pressed" event's "space" box, then click right arrow in the drop-down menu. Add motions to the controls. This is how you'll use the arrow keys to turn your racer: Click Motion.

Drag the "turn [right arrow] 15 degrees" event to fit below the "right arrow" control. Drag the "turn [left arrow] 15 degrees" event to fit below the "left arrow" control.

Create an out-of-bounds rule. Using this rule will ensure that, should your racer touch the background color not the track , it will "crash": Click Control , then drag the "if then" option onto a blank space.



0コメント

  • 1000 / 1000