34
VACUUM MARAUDERS V1.0 © 2008 PAUL KNICKERBOCKER FOR LANE COMMUNITY COLLEGE In this game we will learn the basics of the Game Maker Interface and implement a very basic action game similar to Space Invaders . This game will focus on: Loading Resources (sprites, backgrounds, sounds) Object creation Room Creation Movement Controls Event handling Animation Collision Detection In order to have access to all the options in Game Maker needed for this and all future games, turn on the Advanced Mode under the File menu. Save your work often!

VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

VACUUM MARAUDERS

V1.0

© 2008 PAUL KNICKERBOCKER FOR LANE COMMUNITY COLLEGE

In this game we will learn the basics of the Game Maker Interface and implement a very basic

action game similar to Space Invaders.

This game will focus on:

• Loading Resources (sprites, backgrounds, sounds)

• Object creation

• Room Creation

• Movement Controls

• Event handling

• Animation

• Collision Detection

In order to have access to all the options in Game Maker needed for this and all future games,

turn on the Advanced Mode under the File menu.

Save your work often!

Page 2: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

1.LOADING RESOURCES

While the Game Maker software will be used to handle the actual operation of the game, it

must first be feed all the artwork and sounds it needs to use within the game. In this step we

will load all the artwork and music needed for the game’s characters and special effects.

We will start by loading the Sprites. Sprites are the images which represent the characters

within the game (i.e. the enemies, fireballs, the player, etc.). A single sprite may be used

many different times in a game, like with a group of enemies that all look the same.

To load a sprite click the button on the toolbar, which will bring up the new sprite box:

From here you will click the Load Sprite button and select the file you wish to use. In this

sprite we will load the player’s ship, which will result in something like this:

Page 3: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Game Maker will display the image and give you details on the file such as its dimensions in

pixels (dots on the screen) and its number of subimages (images within the image that are

used for animation).

We will want to change some the sprite’s other properties:

• The Name of the sprite is the unique name that Game Maker uses to refer to the

sprite and is very important in many features. It is a good idea to give the sprite a

descriptive name that starts with “sprite_”. We’ll name this sprite “sprite_player”

• The Transparent box makes the background of the image disappear when used in the

game, this is used so that the square image doesn’t look like a clunky block. Most

sprites are transparent so we will check this box.

(Note: When the transparency box is checked, Game Maker takes whatever color is in

the lower left-hand corner and changes all instances of that color to transparent. If

the background color is not different from the colors used in the rest of the sprite,

“holes” will appear in the sprite.

• The Origin box defines where the “center” of this sprite is, or point (0,0) on the co-

ordinate plane. By default this is in the upper left hand corner of the image, but by

clicking the Center button you can place it in the center of the image. When working

with the co-ordinate system it is often easier to have (0,0) in the center of the

sprite, so we will click the Center button.

• The other check boxes have to do with collision detection and displaying the image.

Precise Collision Detection turns the Bounding Box on and off. The Bounding Box is

the outline of the core of the sprite (in this case the spaceship) and is what is

actually used for collision detection. Preload Textures is used on large sprites for

Speed. Keep Precise turned on.

The result is:

Page 4: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Repeat this process using the same settings to create sprites:

• sprite_enemy1 – Enemy Image

• sprite_enemy2 - Enemy Image

• sprite_enemy3 – Enemy Image

• sprite_shot1 – Player Bullet Image

So that we have:

We will also load a special sprite, an explosion, that contains animation. Animation in Game

Maker is done using animated GIF files, which basically operate like a flipbook. The image

itself is composed of numerous subimages and the animation is created by changing the image

over time. If we load an explosion image into a new sprite named “sprite_exp” and configure

it like the previous sprites we get:

Page 5: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Notice that the number of subimages is 21, and if you click the Edit Sprite button you can see

all the subimages that make up the animation:

When this sprite is displayed in the game, it will automatically start and loop the animation

sequence.

Page 6: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Now we will load in the Background Image that will be used to give the impression that the

player’s ship is in space. Backgrounds are loaded using the button. Click the Load

Background button and select the image file. Rename the background to “background_space”

so that you have:

• Transparent works just like sprite transparency. Leave this unchecked.

• Smooth Edges attempts to make the image less blocky. Leave this unchecked.

• Preload Texture speeds up gameplay. Leave this unchecked.

• Use as tile set is used for making tiles (like sprites for the background). Leave

unchecked.

Page 7: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Loading sounds is done with the button. Use the Load Sound button to load in the sound file. The default settings for the sounds will be fine for now. Load the following

sound effects:

• sound_exp – the sound of an explosion

• sound_player_fire – the sound of the player firing

• sound_enemy_fire – the sound of the enemy firing

• sound_music – the background music

With all the resources loaded, our file should look similar to this:

Page 8: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

2. CREATING THE PLAYER

With the sprites, background and sounds loaded, we can move on to creating the player

object.

The Object is the core programming unit of the Game Maker software, it defines all the

behaviors and actions for an element used in the game (i.e. the player’s ship, the enemy,

fireballs, etc.). The object will dictate what the game should do when something happens to

the element, like when it collides with another element.

While a sprite may be the visual representation of the character, the object controls all the

behavior of that character. Though objects are often associated with a single sprite, but may

switch between several sprites during the course of the game or have none at all (being

invisible to the user).

Objects are created using the button. Rename the new object “object_player” and use

the button in the Sprite area below to select “sprite_ship” as the sprite associated with

the object. Giving:

This object is now set up to display the ship sprite whenever it is used in the game.

Page 9: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

• The Visible checkbox must also be checked in order for the ship to be visible (the box

is used with special objects that do things behind the scenes of the game).

• The Solid checkbox is used in collision detection. It does not have to be checked

• Depth is used to determine what object is displayed on top when 2 or more objects

overlap. The higher the number the “deeper” the object is, so an object with depth 10

would be displayed on top of an object of depth 100. Keep depth at 0.

• Persistent determines whether the object resets when rooms in the game are

changed.

• Parent is used to establish inheritance among objects, this is discussed in a later

version. Keep it at <no parent>

• Mask us used for making a collision detection shape that is different from the sprite’s

shape.

We will return to the player object later to add movement controls.

Page 10: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

3. CREATING A ROOM

In Game Maker all the action happens inside of Rooms. Rooms are used for Intro screens,

completion screens and the levels of the game. After creating a room, you populate it with

the objects and set various settings to give it a distinctive look. By default, when the game

starts the first room will be loaded.

All the action in this game will happen in the same room. A new room is created using the

button. Rename the room to “room_main” in the Settings tab and set the Width = 480

and Height = 640 (making the room 480 X 640 pixels in dimension). We also want to set

Giving something like:

• Caption is the text that will be displayed in the top of the window of the Game. This

can be set to “Vacuum Marauders” is desired.

• Speed dictates how many “Steps” (explained later) the room will take in a second,

and controls the speed of gameplay in this room. Leave it at 30.

Page 11: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

• Persistant has to do with whether this room’s status will be maintained when the

game moves to a different room. Leave this unchecked.

• Creation code provides access to Scripts (explained later) that can be used to perform

advanced behaviors when the room is loaded. Don’t use this now.

We will now set the background for the room so that instead of the dull grey, it uses our

starscape. Click the Backgrounds tab and select “Background 0” from the list. Now click the

button and select our “background_space” background. Ensure the Visable when room

starts box is checked and you should have:

• Draw background color is used when no background image is used and the background

should be a solid color, that color is defined using the Color box beneath the checkbox.

• Up to 8 backgrounds can be loaded into a room (Background 0 – 7), this is useful when

backgrounds change during gameplay or for layering images.

• Foreground image defines the background as being in front of all the objects on the

screen.

• Tile Hor/Vert is used when the background uses tiles. Not used here.

• Stretch will automatically scale the background image to fill the room. Out

background is the same dimensions as the room so this is not needed here.

• Hor/Vert Speed are used for scrolling the background. Not used here.

Page 12: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

The last thing to do is place the ship object in our room. Go to the objects tab and select the

“object_player” object with the button.

At the top of the window is the box. This box defines the size of the

grid in the room. You want to set the grid to be a multiple of the size of the sprites you are

using. For example, our ship and enemy sprites are 40 X 40, so set the Snap X and Snap Y to

be 20. This will make our ship line up better in the grid and make placing objects easier.

Grids can also be used to align objects during the game (explained later).

You should now have something like:

Page 13: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

To place the space ship in the room just move the mouse to some place near the bottom of

the room and click the mouse button, Like:

We only want one ship so if you accidentally put in 2 ships, you can remove the extra object

by right-clicking on it.

Page 14: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

We can now press the button to test our game, we get something like:

The ESC button will quit the game.

Page 15: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

4. MOVEMENT CONTROLS

While our game now runs, it’s not very interesting because it doesn’t really do anything. So to

add keyboard control of our ship we will begin adding Events and Actions to our player

object.

If we look at our player object we see that Events and Actions are side by side:

Events are any event that happens during the course of the game – creation of the object,

collision with another object, pressing the <Space> key, moving outside the room, etc. The

events act as triggers for controlling the game, for example: if my missile hits an enemy

(collision event) I want to have the game destroy that enemy. We dictate how the game

behaves by giving it Actions to perform when an event happens.

Page 16: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Actions are the actual commands that we give to the game to control individual objects and

the game as a whole. Actions are connected to an event and are executed when that event is

triggered, usually events have quite a few actions associated with them.

We want to add movement to our ship when we press the arrow keys, so we will add the Key Press event our player object. This way we can add movement actions to the event so that

the object begins to move when we press a key.

To add events press the button, this will bring up a menu of events to

choose from:

• The Create event is triggered when the object is created – if the object has been

placed in the room (like “object_player”), this will happen when the room starts.

• Destroy is triggered when the object is destroyed, it is the last thing the object does

before it dies.

• Alarm goes off when an alarm is triggered, this is discussed later.

• Step goes off at each “step” of the game and is usually used to monitor conditions

inside a game. This event is constantly executed.

• Collision is triggered by Game Maker’s collision detection, often used to destroy

enemies and assign points. You can specify what object you are colliding with.

• Keyboard is any key pressed on the keyboard (specific keys can be selected). This

differs from Key Press because it executes as long as the key is held down.

• Mouse handles mouse input, i.e. clicking, movement, scroll wheels.

• Other contains a collection of less frequently used events.

• Draw is called whenever the image is redrawn. This is used to change object sprites

and write to the screen. Discussed Later.

• Key Press/Key Release execute once when a key is pressed, and once when it is

released (respectively).

Page 17: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

For our movment we will use the Key Press Event. Clicking on Key Press will bring up a list of

keys to use:

First we will handle Left Movement, select <Left>. This will enter into the event list like so:

Page 18: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

From here we can drag-and-drop (or right click) from the buttons on the right into the

Actions box to define what happens when the key is pressed. We will be using the Move

Fixed action which is represented by the button. Moving the button to the Action box

will pop up the dialog:

By clicking the directional buttons we can dictate what direction the object can go, and the

Speed box defines how fast.

Set the Speed to 6 and press in the left directional button:

Page 19: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Relative determines whether this resets movement or should be applied to objects current

movement, this is an important concept and shows up in many of the actions. We want

Relative off because we only want the ship to move at a fixed speed. If we set the speed to 6

and clicked Relative, every time the <left> button was pressed the ship would have its speed

increased by 6 (i.e. 6 -> 12 -> 18 -> 24 ….). This would quickly give us an out of control ship.

Applies to is an important box and is mainly used during collision events ad is explained later.

For now keep it on “Self”.

You should now have:

Page 20: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Now Create an Key Press event for <right> and add a Move Fixed event to it where Speed =

6 and the right directional button is pressed, giving:

Page 21: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

From here we can test our game and see that the ship moves to the left and right when the

direction buttons are pressed:

OH NO!!!! – While our ship will move left and right, it will not stop once it gets moving and it

flies right off the screen. This is because we never told the ship to stop and we never did

anything to keep it from flying off the screen. Game Maker will not assume anything about

your game - anything you want (or don’t want) to happen has to be defined using actions and

events.

Page 22: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

First Bug – Not Stopping:

We want the spaceship to move while the <left> or <right> buttons are pressed and stop when

they are released. One of the events available to us is the Key Release event which will run

whenever a specific key pressed down is released, which is exactly when we want to stop the

ship.

Add a event for the <Left> key and add a Move Fixed ( ) action to it.

The moved Fixed should have Speed = 0, and the center direction button depressed. Like

this:

This will set the speed back to 0 and set the direction of movement to no direction. This has

the immediate effect of stopping the ship.

Perform the identical steps for the event for the <Right> key.

Second Bug – Running off the screen

Game Maker will not automatically keep your objects in the room because there are many

times it is useful to have things move outside the room, or come in from outside of the room.

There is an easy way of dealing with this problem through the use of the Intersect Boundary

event:

The Intersect Boundary event for an object is triggered whenever that object runs into one

of the 4 walls of the room. It is found under the button along with some

Page 23: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

other lesser used events. What we will do when this event happens is to stop the ship from

moving, exactly as we did in fixing the last bug.

While we could repeat the process of adding a Move Fixed to the Intersect Boundary event

like we did with Key Release, we will instead introduce a time saving device, the “Duplicate

Events”. If we right-click on either of the Key Release events we will get the option of

“Duplicating Events”:

After selecting this it will pop up the events box, from which you can select Intersect

Boundary:

This will create an exact copy of the actions of the duplicated event only under a new event.

This is very handy for events like movement that contain an identical set of actions with just

a few different settings (i.e. speed, direction, etc.), you can copy the event then just change

the settings in the actions.

All Fixed – Test the game to make sure the ship stops at the right places.

Page 24: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

5. THE ENEMYS

While we have movement down, we now need something destroy. Our first enemies will be

very simple, bouncing back and forth at the top of the screen. Create a new object named

“object_enemy” and assign it one of the enemy sprites:

We want this enemy to start moving automatically when it pops into existence, so we will

user the Create event ( ). This event happens as soon as the object is created

and is often used to start movement and set up elements the object will need to use. In this

case we want to set the enemy moving either to the left or right. We can do this with a Move

Fixed, we set Speed = 4 and select both the left and right arrows:

Page 25: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

With both arrows selected the object will randomly choose one of the directions, this means

about 50% of the enemies will go left and the other 50% will go right.

We also need to make sure the enemies “bounce” against the sides of the room – we do this

the same way we stopped our ship from leaving the room: Intersect Boundary. Create a

Intersect Boundary event and add the Reverse Horizontal action ( ) to it. Reverse

Horizontal sends the object off in the opposite direction at the same speed, making the

object appear to “bounce”.

From here we just need to put the enemies into the room. Place 3 or 4 near the top:

When we start and test the game we get bouncing enemys:

Page 26: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room
Page 27: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

6. COLLISION DETECTION

While we have the player and enemies in close proximity to each other, there is no way for

the player to destroy the enemies. We will have to give the player something to shoot at the

enemy. For this create a new object called “object_shot” and give it a missile sprite:

Make sure you set Depth = 10 on this object. This ensures that when the object is “launched”

by the player object, it appears to be under the ship and not on top of it.

The whole point of the missile is to travel straight up and collide with the enemy, so we will

have it start moving up the screen as soon as it is created. Add a Create event, and put in a

Move Fixed with the arrow going up and Speed = 8:

Page 28: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

This is all we really need for the missile object, but we will add one more event/action pair

for good housekeeping.

Game Maker has to track all the objects in the game for as long as they exist in the game, the

amount of memory and computer resources it uses depends on how many objects it is

tracking. The less objects, the faster the game - the more objects, the more lag. This is why

it is very important to remember: Game Maker will track an object until you specifically

destroy it. So for every object you make you should have some code that destroys it when it

isn’t needed. In this case we will be creating a lot of missiles, but once they leave the room

they are no longer needed. If we don’t destroy these missiles when they leave the room,

Game Maker will use up memory tracking them.

So to get rid of the missiles we are creating we add the Outside Room event, which is in the

button. Inside that event we add the Destroy Instance action ( , found

in the “Main1” tab of the actions). Outside Room executes whenever the missile object is

outside the room’s boundaries, and in this case destroys itself. Adding a destroy event

becomes very important when lots of objects are being used in a game.

Now we need the player to shoot the missiles – Open “object_player” and add a Key Press

event for the <Space> bar. Inside the event, add Create Instance action ( , found in the

“Main1” tab). An Instance is a unique copy of an object in the game, while there is only one

“object_enemy” defined in the game there are several instances of that object all acting

independently. The Create Instance is just like placing an object in the room using the

room’s setup box (like we did for enemies and the players ship), only it is done while the

game is in progress.

Here, we are creating a new missile in the room so we the object to be “object_shot” and

X=0, Y=0, making sure we check the Relative box:

Page 29: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

The X and Y determine where the object will be created. We use Relative because we want it

to appear at “object_player”s point (0,0) – which is the center of its ship sprite. If we had

Relative off, it would always appear at the ROOM’s (0,0) which is in the upper left hand

corner. Relative always says that you are referring the CURRENT state of the object you are

putting the action into.

If we test out our game we see:

Page 30: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

OH NO!!! – Even though we have missiles shooting, nothing happens when the missiles impact.

This is because we never defined what happens when missiles and enemies collide. Again,

Game Maker makes no assumption about what collisions mean in your game.

We handle collisions using the event and we can define what objects we

collide with. In this instance we want a collision between a missile and a enemy result in both

being destroyed. We could do this with a collision event in both the enemy and missile, but

when handling collisions it is often best to have just one object handle all the collision

actions. This is so that if something goes wrong it is easier to debug and it also avoids

problems about which collision event happens first.

We will handle all the actions through the Enemy object, so open “object_enemy” and add a

collision event for “object_shot”:

Under the event add the Destroy Instance ( ) action, but this time switch Applies to =

Other

Page 31: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

This makes the Destroy Instance apply to the instance that the enemy COLLIDED WITH, the

missile. Using the Other setting on any action that allows it will have it apply to the instance

that the instance declaring the action collided with. This process destroys the missile that hit

the enemy.

Now add a Destroy Instance with Applies to = Self. This will destroy the enemy itself. It is

very important you do it in this order – once the enemy is destroyed the program stops

processing actions (so the missile would never get destroyed).

Now test your game and you should have enemies that disappear when hit.

7. SPECIAL EFFECTS

Though the missiles destroy the enemies, they do it in a fairly unspectacular manner. To add

some spice we will create an explosion object, an object who whole purpose is to display an

explosion and disappear.

Create an object “object_exp” and give it the sprite “sprite_exp”. Add the event Animation

End (which is under the button) and inside that event put the Destroy

Instance ( ) action applied to Self:

Page 32: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Animation End is an event used when an object has an animated sprite (like “sprite_exp”), it

is triggered when the animation finishes displaying its last sub-image. Normally, if an object

has an animated sprite that animation will loop endlessly. Our object lets the animation run

just once then has the object destroy itself. To display an explosion we just have to create an

instance of the object, the rest will take care of itself.

The explosion object is also good for handling the sound effects associated with the

explosion. Add a Create event and place in it a Play Sound action ( , in the main1 tab).

This will cause that explosion to always add in the sound when it appears. Set the action to

play “sound_exp” and set Loop = False:

Page 33: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

Now that we have and explosion lets add it into our collision event in “object_enemy”. Use

drag and drop to put a Create Instance action ( ) above the two Destroy Instance events.

Create the instance “object_exp” at point (0,0) Relative:

This will create a self-destructing animation at the exact point the enemy was. Again, the

order of the actions is very important – the Create Instance must happen before the Destroy

Instance actions or the enemy object will be destroyed before the Create Instance can make

an explosion. By default, new actions go to the bottom of the list so you may have to drag the

action to the top of the list once it’s created:

Page 34: VACUUM MARAUDERS V1 - Lane Community College · 2008-12-27 · can be set to “Vacuum Marauders” is desired. • Speed dictates how many “Steps” (explained later) the room

This is also a good time to add in the shooting sound effect. We can do this by adding

a Play Sound action ( ) to the Key Press <Space> in the “object_player” or to the

Create event in “object_shot” . While adding it to “object_player” may be tempting,

the Create event of “object_shot” is a better fit because it makes our game more

flexible. What if we were to add an ammo counter for shots? Pressing the key may

make a sound without producing a missile. In general: try to keep as many of the

actions associated with the object IN the object. (A notable exception being collisions)

Add Play Sound to the “object_shot’ Create event, set the sound to be

“sound_player_fire“ and Looping = False.

FINISHING UP

Now we should have the following features implemented:

• A moving ship that stays within the room

• Moving enemies the bounce off the sides

• Missiles shot by the player that can destroy enemies

• Explosion animations and sound effects