TGB/Tutorials/Asteroids/Section1

From TDN


Asteroids Tutorial

Written for TGB Version: 1.6


Section 1

This section covers how to set up a new project and copy the asteroids scene included in the Behavior Playground.


Starting From Scratch


While it is possible to use the pre-built level from the Behavior Playground, you can also start from scratch with a new project. The following steps are needed:


1. Create a new project


You can call the project whatever you like. For this tutorial, it will be simply Asteroids. After you do this, exit the level builder.


2. Copy the image files


Depending on where you installed TGB, go now to the Behavior Playground folder and in the game/data/images subfolder copy the needed images shown in the right hand figure to the corresponding data/images folder in your new project. Then start the level builder.


3. Create your ImageMaps


In the level builder create tab, click on the "Create a new ImageMap" button and add all 11 image files to your project. The default names for all the images have been kept. For everything outside of the background and ship images, you will need to go into the image builder and set the image mode to CELL. For certain imagemaps, you will have to manually set the Cell Count X and Cell Count Y values.


4. Create an Animation


While we don't have any particle effects yet, one of them will need an animation. Let's add that now. Click on the "Create an Animation" button and choose the particles_arcImageMap. In the animation builder, click on the green plus icon to add all frames to the animation. Set the Frames Per Second to 10 and leave the cycle animation checked. Click save to leave the animation builder.


5. Add the Particle Effects


Exit the level builder again and go back into the data/particles folder of the Behavior Playground. Copy the 4 .eff files as shown to the right and add them to the particles folder of your project. When you restart the level builder again, you should see the particle effects in the create tab.


6. Don't forget the behaviors


If you have the level builder open, close it and add the behaviors used in the demo level from the Behavior Playground. The figure to the right shows which files you should copy. We won't be using every behavior from this list right away, but they are all needed. Note: These behaviors are from the Behavior Playground project and NOT from the Astral Objects game.


Recreating the Level


Now that we have all the files we need to properly set up our scene, let's continue on:

Populating the Scene


The following is a list of objects you need to now add to the scene. Included on a separate page is the final properties of each object. Some of the behavior properties can only be first set when you add the appropriate object to the scene. For example, you have to add the projectile object to the scene and name it before you can select it in the shoots behavior of the player ship.

Add the backdrop_bImageMap to the scene with the following properties:

Scene Object
 Position X: 0  Y:0, Size X: 100  Y: 75, Layer 31
Scripting
Name: background

Now add the player_shipImageMap with the following properties: Click Here
In addition to setting the properties, edit the collision polygon to look something like this:
Image:TGB Asteroids Tutorial 1 7.jpg

Add a large asteroid by using button_shieldImageMap, frame 0. Place this sprite well outside of the camera view.The properties of this object can be found here: Click Here

Just like the large asteroid, add a small asteroid using button_dualImageMap, frame 0 outside of the camera view. It's properties are: Click Here

Now add our projectile using particles_glowImageMap, frame 0. Place it as well near the asteroids outside of the camera view. Properties are: Click Here

Similar to the player ship, remember to set the collision polygon for both asteroids and the projectile to follow the shape of the object.

Time to add a t2dSceneObject. We will use this to spawn our asteroids. So on the Create tab Other rollout, drag a SceneObject into the level. It has the following properties:Click Here

Last but not least, add outside the camera view each of the 4 different particle effects. Name them respawnEffect (small_respawn), smallExplosion (cartoon_small), shipExplosion (cartoon_big), and largeExplosion (big_explosion). Give them each the template behavior.

When you are finished, your scene should look something like this:

Image:TGB Asteroids Tutorial 1 8.jpg Image:TGB Asteroids Tutorial 1 9.jpg



Remember to save your scene, with whatever name you'd like. The one for this tutorial is called mainLevel.t2d. Now try out the level to see if everything in your copy plays similar to the Behavior Playground. When you're ready, continue on to Section 2.


Return to Asteroids Tutorial Hub

Behavior Playground Project can be found at:

http://tdn.garagegames.com/wiki/TGB/Behaviors