Once you have mastered making basic games with Game Maker using the drag and drop interface, you will want to start learning some simple programming to extend what you can do with your games.  Game Maker has its own built in programming language, Game Maker Language (GML), that you can use in a number of ways.  This enables you to do much more with your games. 

There are three different places you can use GML.  You can make your own scripts, you can add a code action to an event, and you can write room creation code. 

Work through this example to make a pattern designer program using Game Maker Language. 

 

There are a few main points to remember when using code:
  • All your resources (sprites, sounds, objects etc) must have names that start with a letter, and only contain letters, numbers or the underscore _ symbol.  You cannot use spaces.
  • All your resources must have different names.
  • Don't use any 'reserved' words such as self, other, global, all, if, else, etc to name your resources or variables.

 

 

The Beginner's Guide to Game Maker Programming (470 Kb PDF) written by Carl Gustafsson is an excellent resource for beginners up to intermediate level programmers. It was written for Game Maker version 4.3, but much of it still applies to Game Maker 6.1

 

Here are some simple code samples produced by Tony Forster to get you started. 

Run each game.  Study the code.  Try to see how it works.  Then try to make some changes to the code to see what effects you get.

Follow the ball The ball follows the cursor and the ghosts follow the ball if it gets too close.

abs() mouse_x, mouse_y
 

Rotate Uses trigonometric functions to make a sprite always face another object
arctan(), mouse_x, mouse_y, pi
Clock Demonstration of trigonometric functions and draw

cos(), current_hour, current_minute, current_month, current_second, current_weekday, current_year, draw_circle(), draw_line(), for(), if(), pen size, pi, sin(), string()

Microplanet Simple drawing program

cos(), if(), Keyboard_string, ord(), Pi, real(), sin(), string_char_at(), string_length(), while()

Move Background Demonstration of a moving background

Background_hspeed[], Hspeed

Move Ball A simple game
Shoot both Sides Demonstration of shooting
Persistent Rooms Example of persistent rooms
Not Persistent The character remembers which house it entered but neither the character nor the house need be persistent
Persistent Objects Demonstration of persistent objects
Total abomination kills Kill enemy, build factories, manage resources etc

abs(), if, instance_change(), instance_create(), Other, set_cursor(), sprite_index, with ()

Tile Functions Demonstration of tile functions
Draw Functions Drawing program
Netcomms Networking
Questions Asking Questions
Temperature Converter