Let us look at an example

First of all you can download all the Examples and Assets from http://wiki.yoyogames.com/images/d/d6/Assets.zip It is good first to have a look at how to make a very simple example. We assume here that you run Game Maker in simple mode. The first step is to describe the game we want to make. (You should always do this first; it will save you a lot of work later.) The game will be very simple: There is a blue ball bouncing around between some red walls. The player should try to click on the ball with the mouse. Each time he succeeds he gets a point.

As can be seen, we will require two different objects: the ball and the wall. We will also need two different sprites: one for the wall object and one for the ball object. Finally, we want to hear some sound when we succeed in clicking on the ball with the mouse. We will just use one room in which the game takes place. (If you don't want to make the game yourself you can load it from the Examples folder under the name hit the ball.gmk.)

Let us first make the sprites. From the Resources menu select Create Sprite (you can also use the appropriate button on the toolbar). A form will open. In the Name field type “wall”. Select the Load Sprite button and choose an appropriate image. That is all, and you can close the form. In the same way, create a ball sprite.

Next, we make the sound. From the Resoources menu select Create Sound. A different form opens. Give the sound a name and choose Load Sound . Pick something appropriate and check whether it is indeed a nice sound by pressing the play button. If you are satisfied, close the form.

The next step is to create the two objects. Let us first make the wall object. Again from the Resources menu choose Create Object. A form will open that looks quite a bit more complex than the ones we have seen so far. At the left there is some global information about the object. Give the object an appropriate name, and from the drop down menu pick the correct wall sprite. Because a wall is solid, you should check the box labeled Solid. That is all for the moment. Again create a new object, name it ball, and give it the ball sprite. We don't make the ball solid. For the ball, we need to define some behavior. In the middle you see an empty list of events. Below it there is a button labeled Add Event. Press it and you will see all possible events. Select the Create event. This is now added to the list of events. At the far right you see all the possible actions in a number of groups. From the move group choose the action with the 8 red arrows and drag it to the action list in the middle. This action will make the object move in a particular direction. Once you drop it in the action list, a dialog pops up in which you can indicate the direction of motion. Select all 8 arrows to choose a random direction. You can leave the speed as 8. Now close the dialog. So now the ball will start moving at the moment it is created. Secondly, we have to define what should happen in the case of a collision event with the wall. Again, press Add Event. Click on the button for collision events and in the drop down menu select the wall object. For this event we need the bounce action. (You can see what each action does by holding the mouse cursor still above it.) Finally, we need to define what to do when the user presses the left mouse button on the ball. Add the corresponding event and select the left mouse button from the pop-up menu. For this event we need a few actions: one to play a sound (can be found in the group of main1 actions) and one to change the score (in the group score) and two more to let the ball jump to a new random position and moving in a new direction (in the same way as in the creation event). For the sound action, select the correct sound. For the score action, type in a value of 1 and check the Relative box. This means that 1 is added to the current score. (If you make a mistake you can double click the action to change its settings.)

Our objects are now ready. What remains is to define the room. Create a new room in the game, again from the Resources menu. At the right you see the empty room. At the left you find some tabs, one for setting the background, one for setting some global properties like the width and height of the room, and one where you can add instances to the room. At the bottom you can select an object in the pop-up menu. By clicking in the room you can place instances of that object there. You can remove instances using the right mouse button. Create a nice boundary around the room using the wall object. Finally, place 1 or 2 ball objects in the room. Our game is ready.

Now it is time to test our game. Press the Run button (the green triangle on the button bar at the top of the window) and see what happens. If you made no mistakes, the ball starts moving around. Try clicking on it with the mouse and see what happens. You can stop the game by pressing the <Esc> key. You can now make further changes.

Congratulations. You made your first little game. But it is now time to learn a bit more about Game Maker.

Converted from CHM to HTML with chm2web Pro 2.85 (unicode)