How to create the Space Shooter game from scratch: a tutorial (part 2)

Modified: 2008/05/01 20:01 by SuzanneH - Uncategorized
This is the second part to the "how to create the Space Shooter game from scratch" tutorial. Click on one of the following links to view a different section:

Part 1
Part 3
Part 4

Now you need to make your actors move. Start with the hero (the fighter spaceship).

1. Click on the Actors tab to return to the actors area
2. Click on the Fighter Spaceship in the actors list

From this area you can edit the appearance, behaviors and the properties of your actor. Behaviors tell your actor how to interact with other actors in the game, or how it can be controlled by someone playing the game.

In this game, the hero is controlled by the person playing the game. The player can move the hero right and left by using the arrow keys on their keyboard.

3. Click the Behaviors button
4. Click on the Motion button to add a new motion

A new motion behavior called “Motion 1” should have appeared in your list of actor behaviors. Start with implementing the “move right” behavior. First you need to select the event trigger. In this case it’s when a player presses down on the right arrow key.

Image

New motion behavior


5. Click the Event button for this new motion.
6. Click the Keyboard button
7. Click the right arrow keyboard key from the image of the keyboard
8. Click the “x” button to exit the dialog

Image

Select keyboard keys


Now you need to specify in what direction the hero spaceship should move. For Motion 1, you need it to move right.

9. Click the Motion button
10. Click the East (E) motion direction
11. Click on the While Receiving Event Button
12. Click on Preview to test out the keyboard controlled movement (you may need to click on the scene below the preview button to ensure proper focus)
13. Click the “x” button to exit the dialog
Now that you have added a “move right” motion, you can add a “move left” motion.

Image

Motion dialog





























14. Repeat steps 25 to 34, but this time hook up the keyboard’s left arrow key to the West (W) motion direction

Image

Add a new shoot behavior


Now that you have right and left movement, you need to add a “shoot” behavior to your hero spaceship.

15. Click on Shoot to add a shooting behavior














16. Set the Event to be the keyboard’s spacebar key
17. Click the Press button so that this motion doesn’t continue to happen as long as the key is pressed down. This way the spaceship will only shoot once every time the key is pressed.

Image

Select "on press" as the trigger
















18. Click the “x” button to exit the dialog
19. Click on the Projectile button to choose what type of “bullet” the spaceship will fire
20. Select one of the projectiles from the dialog that appears (Vertical Streak works well) and then click the “x” button to exit the projectile chooser dialog
21. Click the Motion button for the shooting behavior
22. Set the Relative To setting to Scene
23. Select the North (N) motion for an upward motion
24. Click preview to see the movement and shooting in action

The enemy spaceships disappear when they collide with a projectile because the projectile actor has a default behavior to make any solid actors that it hits, disappear.

Image

Preview projectile



25. Click the “x” button to exit the dialog

26. Click Sound to add a sound effect to your projectile when it fires (Classic Laser works nicely)
27. Click the “x” buttons to exit the dialogs until you are back at the actor editing area

Now is a good time to save your work if you haven’t done so recently.

In the next part of this tutorial, you'll make it so the enemy spacecraft move back and forth across the top of the scene (and shoot!) on their own.

Click here to continue on to part three of this tutorial.

Privacy. Terms of Use. Trademarks.
ScrewTurn Wiki version 2.0.22. Some of the icons created by FamFamFam.