You can make programs to create some very
interesting moving patterns
and designs using Game Maker. The
simulation by Rex Smeal is a fine example of what you can do.
This
tutorial will show you how to make a simple design maker program.
It is an introduction to using Game Maker Language to enhance your
programs.
How it
will work
Play starts with a single red ball in the centre of the screen.
When the user presses the 'A' key, 10 balls appear in the place of the
single red ball and start moving outwards towards the edge of the play
area. If the 'A' key is pressed again, 10 balls will appear in the
same place as each of the red balls on the play area. When they reach the sides, they will wrap around to the
other edge. If too many balls are created the game will lock up,
so we will only allow more balls to be created if there are less than
3000 balls in the play area.
 |
Create a red ball sprite. Name it sprBall
Create a ball object objBall, and attach the sprite.
Create an empty room, and place the ball exactly in the
middle of it. (You can check the coordinates at the bottom of
the screen - if the game area is 640x480, the centre is at 320,
240 |
 |
Add an event to the ball object for when the A key is
pressed. From the control tab, choose
If the number of instances is a value

Put objBall < 3000 (We don't
want to create any more balls if there are already more than
3000 on the play area.) From the control tab, choose
Execute a piece of code
| counter=0
//initialise the counter repeat(10)
//this loop will produce 10 balls at a time at 36
degree intervals around the circle
{
counter+=36
//increment the counter by 36
ball= instance_create(x,y,objBall)
//create a new ball
ball. direction=counter
//give it a direction
ball. speed=5
//give it a speed
} |
When the balls leave the play area, we want
them to wrap to the other side:
Add an event for when the ball is
outside the room (From Other events
)
Choose the
Wrap around the play area action from the Move tab.

|
 |
| Try varying the code so that 18 balls
are given out each time.
You will need to look carefully at the code to work out what
you need to change. |
|
Download a finished version
pattern2.gm6
Download an enhanced version
pattern1.gm6