Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

Game Maker – Lesson 1

VIEWS: 371 PAGES: 12

									Game Maker Lesson 1 Introduction
When you write a story you use all the words and sentences you are familiar with. You might hear or see new words that you will use to make your writing more interesting as you progress. These words and sentences will have been used by many writers before you but the way you put them together will make your writing unique. This is similar to how you will make your computer game. With each lesson you will learn something new to help you make your game technically better but at all times it is how you use the skills you have learnt that will make your game unique and interesting.

Game Maker – Lesson 1  Games take place in rooms. " In these rooms you place objects (which have sprites as their images, and properties like solidity and actions like movement.) Typical objects are walls, main character, monsters etc. some things move and some things don’t. Certain things will happen to objects. Such happenings are called events. They can be what happens when they are created (creation event), what happens when they are destroyed (destroy event), what happens when a particular key is pressed (keyboard event) or maybe what happens when two objects collide (collision event).



Getting Started Add a sprite (graphic) You can draw your own Sprite, which you will do later, or use a sprite that someone else made. This is what we’ll do now by clicking on Load Sprite. Go to C:\Program Files\Game_Maker7\Sprites\various if you aren’t brought there automatically. Pick any sprite you like and click on Open.

We won’t change the name this time but for all other games we will as it makes them easier to identify. Click OK 1

Game Maker Lesson 1 Add object Assign the sprite to the object by clicking on the small menu icon beside the Sprite name and choosing the one you want from the list. We won’t change the name of the object this time but for all other games we will as it makes them easier to identify.

Make sure Solid is also selected. Click OK.

We now have an object for our game and a sprite as its image. Next we will put our object in a room.

Add room Under the Objects tab you will be able to choose any object you have created. There is only one available at the moment. Click anywhere in the room to place the object. Click OK.

Run the game

or press F5 What happens to your object? Nothing! The object needs to be programmed to do something. Press escape to exit game 2

Game Maker Lesson 1

Object Properties In order to program the object we set its properties. Double click on object0 to bring up its properties. We are going to add an event to make something happen to our object0. Click on Add Event. The event is going to happen as soon as the object appears in the room i.e. at its moment of creation so choose Create from the Event Selector.

We want something to happen when object0 is created. This is an Action. All the possible actions are in a library arranged at the right of the dialogue box. They are sorted under 7 tabs. The Action we want to occur is under the move tab

3

Game Maker Lesson 1

For the create event, drag the action Move Fixed from the library into the Actions area. Options will appear.

Set the direction to down by clicking on the down arrow. It changes to red.

Set the speed to 4. This will make the object move down at a speed of 4 pixels.

Click OK twice Run the game

or press F5 What happened? Interesting but we want the ball to stay in the play area. We are going to build a wall around our room to keep the ball in.

To build our wall we will once again load a sprite (sprite1) object (object1). We don’t need to add any Events to it. Go to the start of the lesson if you can’t remember how to do this.

and assign it to an

4

Game Maker Lesson 1 Add object1 to the room by selecting object1 from the menu that appears when you click anywhere under the object tab. You can then click once on the frame of the room for every square you place. To save time you can keep Shift pressed as you click with the left mouse and it will appear like you are drawing the squares. To erase an object click with the right mouse button. Other shortcuts and instructions are listed at the bottom of the window. Note how to move an object.

Click OK Run the game

or press F5 What happens to your object? It moves down as it was meant to do but then it disappears. We want object0 to bounce when it hits the wall. We will now program this to happen. Double click object0. Click on Add Event and select Selector. A small menu of objects appears. from the Event

We want this collision event to deal with a collision with the wall so select object1 from the menu.

5

Game Maker Lesson 1 When this collision event between the ball and the wall happens we want a bounce Action to occur. Drag over the Bounce Action from the library.

At the moment we don’t care how precise the bounce is so we don’t need to change the setting.

We set object1 as a solid object so we don’t have to change this option either. Click OK and Run the game. Now the ball will bounce up and down but not around the room. We need to change the Action of the Create Event for the ball. Double click on the Action icon Start moving in a direction.

Change the Directions to those indicated. If you use the up and down and left and right arrows the ball could get stuck in those directions. Run your game. The ball should bounce around the room.

6

Game Maker Lesson 1 Objects and Instances We want to add a couple of more balls to the room. We already have a ball object. This is like a mould and from it we can use as many copies of the ball as we want. This copy is called an instance. Add two more instances of the ball to the room by clicking with the left mouse button as you did before. Play the game and now you will see the three balls bouncing around the room. OK it doesn’t fit into any category of game that we mentioned before. Let’s design a game around this simple scenario. You should write down your ideas before you start your game. Use the headings you see here. Name of the Game: UFO Defense Game Idea: This is a simple action game. In this game three UFOs/balls move around in a room. The goal of the player is to destroy the three UFOs by clicking with the mouse on each one. Expected playing time is just a few minutes.
UFO Defense design document Game objects There will be just two game objects: the UFO and the wall. The wall object has a square like image. The wall surrounding the playing area is made out of these objects. The wall object does nothing. It just sits there to stop the three instances of the UFOs from moving out of the area. The UFO object has the image of a ball. (Try changing it to a diamond sprite.) It moves with a fixed speed. Whenever it hits a wall object it bounces. When the player clicks on a UFO with the mouse the score is raised by 1 point and it disappears. Sounds We will use one sound in this game. There will be a click sound that is used when the player manages to click with the mouse on a UFO. Controls The only control the player has is the mouse. Clicking with the left mouse button on the UFO will grant it. Game flow At the start of the game the score is set to 0. The room with the moving UFOs is shown. The game immediately begins. When the player presses the <Esc> key the game ends. Levels There is just one level. The game should get more difficulty if it is to be good. We won’t do this at the moment but can you think of ways this could happen? 7

Game Maker Lesson 1 You can see from our design document that our existing game needs a little work. So let’s finish our game. First we’ll load a sound clip so it will available for us to put into our game. Click on or right click in the resources area on Sounds and click on Create Sound.

Click on Load Sound and go to C:\Program Files\Game_Maker7\Sounds if you are not brought there automatically. Choose a sound you’d like to try and click on Open. You can play the sound to hear it by clicking on . will stop the sound playing. If you are happy with the sound click OK.

Now we want to add some Events and Actions to the ball/UFO so double click on object0 to open its properties. Add Event Mouse and choose Left pressed from the menu. We will now add an action that will occur when the Event of the left mouse button is pressed on object0.

8

Game Maker Lesson 1

The first action we want to occur is that the player will get a score of 1 whenever he/she clicks on a UFO.

Select the score tag from the Actions library.

Drag the Set the score icon into the Actions area.

In the Set Score dialogue box put 1 as the new score. Also tick Relative. By ticking relative you are telling the computer to add 1 each time the UFO is clicked. The score will start as 0 and 1 will be added making the score 1. The next time a UFO is clicked the 1 will be added to the score that was memorized before and the score will now be remembered as 2. For the final UFO 1 more will be added to the score that is in memory and the score will be 3. This is an important concept.

At the same time as adding a score we want our sound to play. Choose the main1 tab. Drag over the Play sound icon into the Actions area. Choose sound0 to play.

Finally we want the instance of the UFO that the player has clicked on to be destroyed.

9

Game Maker Lesson 1 Under the same main1 tab drag the Destroy the instance icon into the Actions area. Just click OK when you have done this as it is Self that we want to destroy.

You can now try the game. Every time you click on a UFO you should hear a sound and the UFO should disappear. The score appears in the top left of the game window. Finally we are going to create a message that will appear after all the UFOs have disappeared to tell the player that the UFOs have been destroyed and the earth is saved. We need a new object for this but it doesn’t need a sprite attached to it as it is only going to be used as a control and doesn’t have to be seen.

For this object’s properties we are going to add the Draw Event. Go to score in the Actions library and choose the icon for If score is equal to. We want to Test the Score to see if all the UFOs have been clicked. There are 3 UFOs so we need to check if the value of the score is 3. (each UFO was worth a score of 1).

If the score is equal to 3 we want the message ‘YOU HAVE SAVED THE EARTH!’ to appear.

10

Game Maker Lesson 1 This will also occur under the Draw event. Choose the draw tab from the Actions Library and drag across the Draw a text icon. Add the text ‘YOU HAVE SAVED THE EARTH!’ We want this to appear somewhere in the middle of the room so we set the x and y number of pixels as shown. You may need to experiment to get the text in exactly the correct position. Open your room to do this

The origin (0,0) of our room is in the top left corner.

Our room is 640 X 480 pixels in size.

Move your pointer over the room. You will see the position you are pointing at will change on the status bar at the bottom. Try to find a better position to have your final text appearing.

While we have the room open we need to place object2 in the room. It will appear as a ? inside a circle when we are designing the room. It won’t appear at all when the game is being played. As explained it is just there to control the text that appears.

That’s it. You have made your first game. It won’t win any awards but it is a good foundation for any of your own games in the future.

11

Game Maker Lesson 1 Giving games to your friends Your friends don’t need Game Maker to play games that you make. Simply Create an Executable by going to File and choosing the option from the menu.

The file you create can then be put on a CD and given to your friends. You can try sending them by e-mail too but sometimes Executable files will be rejected as a virus by e-mail systems.

In this lesson, you have learnt:1. How to load a sprite 2. How to create an object 3. The difference between a sprite and an object 4. How to add an object to a room 5. Program an object by changing its properties, events and actions 6. Know the difference between an object and an instance 7. The importance of a design document 8. Load music 9. Set a score and the meaning of relative 10. Get text to appear 11. Create an Executable to give to your friends Challenge 1. Instead of having three UFOs the same, create separate sprites and objects for each UFO. Have each UFO go at a different speed to make it a little more difficult. The faster UFO could be allocated a higher score. 2. Write a different story for the game. This game was about three UFOs. Can you make up something else that could fit just as well? Reference: Tony Forster http://tonyforster.blogspot.com/ Andrea Munro, Sacred Heart College, New Town, Tasmania 12


								
To top