Getting Started

Wall

Go into the wall object. Check the box to make it solid. Then click on OK to close it.
No events/actions for this; they just sit in the room.

Balls Moving

Go into the ball object. Add a new event: Create (what happens when the room loads)…

Drag the Move Fixed action into the Actions area and let go…

In the action window that opens up, click on all the arrows (but not center square) so the ball will move in all directions, speed 8.

So now your ball object looks like this so far…

Balls Bouncing Off Walls

We need the balls to stay in the room so you need to add another event: Collision with wall

First add a Bounce action…

Click OK to keep default settings (set to solid objects, so it’ll bounce off the wall object which is solid but not other balls).

Your Collision with wall event looks like this…

You can say OK to the ball object to close it for now.

Room

Double-click on room1 to open it.

First go to the objects tab on the left and click to add a few balls in the room…

Go to the backgrounds tab and change the background to the sky. Then click on the green checkmark to close the room.

Testing the game

Always save your game before testing it out (when it’s saved there will be no * by the file name).

Then click on the green arrow to run the game.

You will get a window opening asking you to install something. Click on either “Skip this installation” or “Cancel”.

GM creates another copy of your game in play mode that is a plain red ball.

Make sure everything is working so far:

  • Do the balls move on their own?
  • Do the balls stay inside the walls?
  • Do the balls move randomly?

To close it, hit the Esc key.

Score

Go into the ball object and add the Left button event (under Mouse events)…

Add action Set Score

In the window that opens up, check the box for relative (so it keeps going up) and the amount to 10 so the player gets 10 points each time they click on a ball.

Now add the action Jump to Random position (default settings). This is so that each time the player clicks on a ball, it starts over in a new random place (otherwise the game would be too easy, you could just hold down the mouse on a ball and have your score rack up!)

Your Left button event should look like this…

Test your game (F5) and click on some balls. You should see the score in the caption area of your window.

Bad Guy

Duplicate the ball object (right-click)…

Change the name to badguy and change the picture/sprite.

Select the Left Button event, then double-click on the Set Score action and change the amount to -20 so the player loses 20 points when they click on the bad guy.

Add bad guys to the room

Go into your room. If the badguy object isn’t showing in the top-left corner on the objects tab, then click anywhere on the left and select it.

Then click and place about 4 badguy objects in the room.

Then test your room and see if it works.

Ending the Game

To end the game we need to test when the game would be over, ie when the player reaches a certain score.

Create a new object by clicking on this button.

Give it the name controller. No sprite; it’s invisible, sits in the background. You should see it in the list on the left…

Add the Step event (this will continuously check for the action we set next)

We will first test how many points the player has using the Test Score action…

Since this is a simple game and we just want to get the idea, we’ll test if the score is larger than 100.

If it’s true, then you want it to do both of the following actions (so you need to put start and end blocks around it)…

  • Display a Message – type in something like “Congratulations”
  • End the Game

So your controller object should look like this.

Add Controller to the Room

In order for this to work, you have to place the object somewhere in your room – it doesn’t matter where (it’s invisible), just don’t replace an object you already have…

Test your game. When you have 100 points and click on the next ball, you should get the pop up window. When you click “OK”, the game should close.