200+ GMZ Files – GameMaker: Studio GML Examples
Section 1 – Basic Examples – Variables
A) A password system where the user has to enter a correct password to continue.
B) Displays an object at a random position on the screen for one second. Player then clicks where the object appeared. Points depending on how close the player clicked.
C) A simple text input system using key presses. Allows user to enter their name. Then stores as global.name when enter is pressed.
D) A game where the player selects a number at random from 1 to 100. Player enters a value (for example 25) and the game will tell you if you are too high, too low or correct.
C) Makes a program that draws random positioned cloud sprites moving to the left at various speeds.
D) Gets user to enter their name. Draws this on the screen, formatted, moving from top of screen to the bottom. Destroys the object when it reaches the bottom.
A) Makes a moveable object that can wrap around the screen, so if it goes off of the screen it appears on the opposite side.
B) Creates a simple two player game, one player using WSAD and the other with arrow keys. One player must chase the other player around the room.
A) Draws the health a player as text in red above a player when health is less than 20. Sets it up so P and L changes the value of health.
B) Makes some text change colour, at random, each time the space bar is pressed.
D) Creates a mini game that randomly displays three objects that move in random directions when created and when clicked by the player. If objects goes off side of screen, wraps around screen. Player clicks objects to get points, displays points on screen.
A) Draws an animated character sprite that animates when moving right.
B) Sets it so the coin animates through its cycle 4 times, then jumps to a new position and starts the cycle again.
C) Makes simple top down maze game with a character that points in the direction the player is moving.
A) Draws a health bar across the whole of the top of the game window, draws lives under this as images. Allows keys Q and W to change health value, and A and S to change lives.
B) Uses GML to draw lives as images, using an animated sprite. Uses GML, not the built in Draw lives action.
C) Draws a bar at the top of the screen that draws the current score mod 1000. For each 1000 score increases the level by 1. Also draws score and level as text.
D) Creates 4 level buttons that each become clickable for every 1000 score points. Shows they are clickable using different sub images. Also changes sub image when mouse over and when clicked.
D) Creates a sound board (lots of buttons each of which plays a sound when clicked with the mouse). Draws text over each button, explaining what sound it plays.
E) Creates an object that can be moved around the room with the mouse.
A) Creates a program that changes the drawn text every 5 seconds, using a list of 10 strings.
B) A program with an object that moves with a speed of 1.Increases the speed of the object every 5 seconds. Also makes the object wrap around the screen.
C) Creates a program that plays a random sound every 4 seconds.
D) A simple system that allows the player to shoot bullets at a maximum rate of one bullet every two seconds.
E) Creates an enemy AI that changes direction randomly every 5 second. Makes the enemy object’s sprite point in direction that it is travelling. Also makes the enemy object wrap around the screen. Sets the object to shoot a bullet in the direction it is travelling every 8 seconds.
A) Makes the player change colour when it can see one or more of obj_enemy.
B) Creates an object, obj_target, and assigns a pink sprite to it. If player collides with it, it plays a sound and destroys itself.
C) Creates a clickable object with 4 sub images. When the mouse button is released when over the object, it changes the sub image. On the forth click destroys the object.
D) Makes the player change direction at random if the mouse gets within 100 pixels in any direction, but only checks this once every 5 seconds. Also makes the object wrap around the screen.
E) Has a room surrounded with walls. Creates a ball that bounces around the room. Has some objects in the room that require 4 hits of the ball to be destroyed, changing the sub image each time they’re hit.
A) Makes a splash screen with a background that shows for 5 seconds, plays a sound, and then goes to a new room.
B) Creates a level select screen that has 5 buttons that each go to a different room. Makes the buttons change colour when mouse is over them. Draws the level as text in the middle of each button.
Makes the player wrap up and down in each room. Makes it so a player object can move from one room to the next. So if the player moves off the right of room A, the player will appear at the same Y location in room B, but on the left of the room, and, if the player moves off the right of room B, the player will appear at the same Y location in room A, but on the left of the room. Does this for moving left also.
C) Creates two horizontal views, one which follows obj_player one which follows obj_enemy (makes both objects moveable using key presses).
D) Creates a parallax system using 4 backgrounds. Has the backgrounds move to the left, with the top layer moving the fastest. Changes the Y location of the background proportionate to player objects y location.
C) Creates a Jukebox program with 5 songs.
D) Creates a moveable player object, and a target object. If the player object is less than 200 pixels from the target object, it plays a sound effect. Increases the sound volume the closer the mouse gets to it.
A) Creates a splash screen and an object with a sprite animation. Sets it to go to the next room 5 seconds after the animation has ended.
B) Creates a menu room with background music with a button to go to an instructions room (with button to return to menu room), and a game room. Changes the music for instruction screen and playing the game.
A) Plays a random sound every time the player presses the space bar.
B) Makes an object jump to a random position, no closer than 50 pixels near the edge of the window, when clicked with the mouse. Uses a sprite with multiple sub images. Stops the animation on the last sub image.
C) Makes an object move randomly around the room without going off of the edges. Makes it change direction every 5 seconds. If it gets within 10 pixels of the edge of the screen, makes it change direction away from the edge.
D) Creates a lottery game that chooses six different numbers between 1 and 49. Displays them in ascending order, inside a circle. If the number is between 1 and 9 makes the circle white, 10-19 blue, 20-29 green, 30-39 red, 40-49 yellow.
A) Uses a control object to create a star every 5 seconds at a random position at the top of the screen which then falls towards the bottom. Player gets a point for every one collected. Player can only move left and right at the bottom of the screen, without being able to leave the window. Uses the control object to draw the score in the top left of the window, setting a font, drawing style and colour.
B) Makes a moveable player object (using arrow keys) and a static enemy object. Makes the enemy shoot at the player, getting faster as the player gets closer. Prevents the player from leaving the window. Ensures the bullet gets destroyed when leaving the room, uses room_width & room_height for this.
C) Creates an enemy that changes direction every 5 seconds to move away from the player, and wraps around the room if goes off of the edge. Also adds the bullet function from Example 17 B, but makes the firing speed no more than two seconds between shots.
A) Create two rooms, room_splash and room_game. Creates an object for room_splash that loads any data from an INI file to two global variables. If no INI file is present, sets the starting location the value of each to 100. Makes this object clickable to go to room_game. Creates a moveable object for room_game, that starts in the position stored in the INI file. Pressing X saves the location to the INI file and restarts the game.
B) Creates a counter that keeps track of how many key presses the player makes in total, and saves/loads the value of this counter to keep track of presses over multiple games. Uses a splash screen with an object to load from the INI file. Uses a separate object for detecting space presses.
C) Creates an object that takes in a 5 people’s names, ages and favourite food. Displays this data on screen. When the game is restarted, and an INI file exists, it gives the option to display the current INI file or enter new data.
A) Allows the user to change the weather by pressing W. Changes between a snow and rain effect.
B) Creates a menu button that creates fire work effects of different colours in the middle when pressed with the mouse button.
C) Creates a line of effects, 20 pixels apart, that start at the top of the screen and fall down to the bottom, then starts from the top again.
D) Creates an effect that spreads out from a location when the mouse is clicked. Makes the effect move out every 10 degrees from the starting point, using multiple objects. Destroys any object creating the effect after 3 seconds.
A) Places an object in a room at a random position. Creates another object that finds a random location within 100 pixels of the first object. Uses a while loop for this.
B) Adds 100 random numbers between 1 and 1000 to a ds_list, then sorts them into order, highest value first. Displays on screen in four columns of 25. Uses for loops for this.
C) Creates 4 random points in the room. Object visits each point in order. Displays a message when all points reached.
D) Stores the names of students in your class in an appropriate way. Displays names in alphabetical in order, one at a time on the screen for 5 seconds, with a gap with no name for 2 seconds.
A) Creates a 2D array with data relating to 4 students in your group. Includes name, age, height, eye colour and favourite food. Displays this data on screen.
B) Makes a 1D array with the values of 10 types of food. Displays one at random each time the space bar is pressed.
C) Creates and populates a two-dimensional array with the 12 times table. Draws the contents on the screen.
D) Creates an array to store the starting positions in a game of chess, uses letters to represent each piece, ie K for King, Q for Queen, N for knight, B for bishop and C for castle, all other squares to have a value of 0. Uses UPPER CASE for black and lowercase for white. Represents this board on the screen. Uses more than one loop to populate the array. Draws a chess board with the correct values in middle of each square.
A) Creates an inventory system for 5 objects. If you add an additional item, it adds it to the end of the list, then removes the top item.
B) Creates a ds_list with 5 fruits. Player enters a fruit, if it matches a value in the ds_list, removse it, and telsl player they made a correct guess. Player wins when all 5 fruits are guessed.
C) Creates a list with the names of students in the class. Sorts them ascending and draw on the screen.
D) Adds the names of all playing cards to a list. Shuffles them. Creates 4 new ds_lists to represent player’s hands. Deals and removes the top card from the main list and deals a card to each player until each has five cards. Draws the values of each player’s hand on the screen. Represents values and suits like: AS, 9H, 2D etc.
A) Create a Script to do each of following, display any result on screen visually, as required, remembering to set up any text drawing. A) Finds the average of 5 numerical values and rounds to the nearest whole number.
B) Works out if the player is within 200 pixels of an enemy object, returns true or false.
C) Draws given text, in black with a red shadow, at given position.
D) Creates3 different fonts. Creates a script that allows you to quickly draw text, using font, alignment, colour and position.
E) Creates a script that finds an average point between 2 objects, and draws a star effect at that position.
F) Creates a script that takes calculates an angle between two objects and draws that direction as text as the angle were on a compass needle, ie North or South West. The direction is that from the first object to the second. North is up.
Each of the following build together to create a single example:
A) Creates a background and control object that makes the background change direction every 5 seconds. Makes it move up, down, left, right and diagonally.
B) Creates a moveable player object and an enemy object that moves towards the player every 5 seconds. Only enemy can wrap around the screen.
C) Makes the enemy shoot in the direction travelling every time it changes direction, in the direction it’s moving. Player can also shoot in direction it’s moving, no quicker than once every 4 seconds.
D) Creates a small health bar above player and enemy objects. Sets it so being hit by a bullet reduces health (applies to enemy and player).
E) Allows player to place a bomb anywhere on screen using mouse. Bomb detonates after 3 seconds. If player or enemy are in range, they lose health.
F) Makes it rain if player has more health, snow if the enemy has more.
G) Creates visual and audio effects if a bullet hits player or enemy, or when bomb explodes.
To accept 5 fieldnames / legends and numerical
inputs (a value between 1 and 100), for each input.
Display a bar graph showing each value graphically
with the corresponding fieldname / legend under each.
Create an object with a sprite set. Allow this
object to be moved by clicking holding left mouse button over it and moving
Create a system that fades a room to solid black, goes
to a new room and then fades from black to fully transparent
To display string one character at a time. Make a
keyboard click sound as each new letter is shown.
To change the volume of a music track depending how
far player is from another object. The further away, lower the volume. The
closer it is, the higher the volume.
Create a path when mouse right button is pressed
that moves player to a new position whilst avoiding obstacles.
Make the room shake when S is pressed.
Create a falling snow effect with two different
size snow flakes.
Allow user to enter a password using the keyboard.
Allow player to enter at any time, do not use get_string. Make so that if the
player presses x and then types bacon, set as unlocked.
Create two player objects, one moveable by arrow
keys, the other by WSAD.
Put this in a large (4000×4000) room.
Create a control object that keeps both players
objects in the view by changing the view
Computer picks a random number between 1 and 100.
Player guesses by entering a number.
The computer will tell you if the number is too
high or too low.
Player keeps guessing until the number is found.
Allow player to click twice in the room using the
mouse, storing the x and y position of each click.
Place an X at the average location.
To retrieve a text file from a website, save
locally and then display the contents on screen.
Take 52 playing card sprites, shuffle them and then
deal out the top 5 cards when D is pressed
Create a sentence. Take this sentence and reverse
the word order.
To make an object rotate so it point towards the
mouse, and that slowly moves to the mouse position.
To create a fireworks display using the effects
that GM provides
To create random sentences when S is pressed and
display on screen. The sentences should (to a point) make sense.
Create a system that allows you to queue messages
and show them one at a time. Draw the messages as text, above a rectangle that only shows when a message
To make an object wrap around the screen on all
For example if it goes off the left the screen it
then appears on the right. Do the same for right, top and bottom.
Create a script that draws a shadow of a sprite
that has been assigned to an object. Allow you to send through distance,
direction, colour and alpha.
To create a simple music player that plays 4 music
tracks. Have a separate button for each track. When a button is clicked, stop
any music already playing and play the selected track.
Create a string that gives credits of a game. Make
the text scroll up from the bottom of the screen. Create so that when last
credit has left the screen the object is destroyed.
To randomly roll 5 dice and display the results
graphically. Have a button to roll the dice.
A substitution cipher is where each letter of the
original text is replaced by a different letter.
Allow a user to enter a sentence. Apply a
substitution cipher and display the result.
To create an INI system to save the highscore.
Display the highscore on screen. Create a button to allow user to enter a new
score, updating the INI file if the score is bigger. Show a message to indicate
whether highscore has been updated or not.
To create 4 spawn points. When a player object
collides with it, the player remembers the position. If T is pressed the player
spawns back at last spawn point.
User to enter a word, check if it exists within a
dictionary text file. Display message showing whether it exists or doesn’t. A
text file is present in the resources that you can use for this.
To draw text with a shadow.
To fire an object from a control object towards the
Display the current time in 2 major cities (one
ahead of your local time and one behind), and your local time. Display hours
and minutes as texts. Ensure a leading 0 is present if only one digit each
part. Do this hard coded, or create a script.
Takes a question, three possible answers, and the
correct answers from a text file.
Displays question each question and possible
answers and the correct option on screen.
Allow left and right to move through the sets.
To create a keyboard where user can click on a
letter and add this to a string. Also include an enter key. Each key should be
a separate object – do this manually or create buttons using code.
Create a tank that can moved using the keyboard.
When it moves, place some tyre tracks that stay for a few seconds.
To combine a number of backgrounds to create a
parallax effect. Have a player object that can move up and down. If player
object isn’t being moved, slowly move it back to middle. When moving up or
down, rotate with sprite. Base the parallax on the players y position.
To create a ghost that randomly appears at
different positions. Player gets points by clicking on it. Use a single image
or an animated sprite (in resources).
To create a fire place effect using GM’s partical
Sprites that you can use for this project are in
the resources pack.
Allow user to enter ten names. Sort them in order
using a bubble sort algorithm. Bubble sort is where you compare values and swap
if one has a bigger value than the other. You repeat this until all is in
order. (if you compare values however many times there are elements, then it
will be in order).
To create 5 buttons that can be locked or unlocked.
Show it’s current state using different sub-images. Use a single object for all
buttons. For testing purposes all left and right arrow key change the level.
To create a moon lander vehicle, where mouse is
clicked, that can hover and move left and right on its own. It needs to land on
a target at the bottom of the screen. When moving it should carry some
To create a movable player object (left and right),
and barrels that fall from the top of the screen. Increase the frequency of the
barrels as the game progresses.
User enters a temperature in degrees C, convert to degrees
To create a path from player to mouse click
position, avoiding objects.
User to enter weight and height, calculate and
BMI is weight divided by height^2.
To simulate a pack of cards being shuffled, save
the pack order to a file.
To display lyrics to the song, 10 Green Bottles.
Use loops and variables to display the lyrics. This can be combined with
Accept a string from a user and convert to Morse
code and display on screen. Allow for letters only.
Blitz was a popular game in the 80s. You have a
ship that moves across the screen, gradually getting lower. The aim is to
destroy the buildings below.
Create a mini (crazy) golf game. Make the ball move
towards the mouse position. Use the distance from ball to mouse a reference for
how fast ball will travel. Create some objects that the player should navigate
to get to the hole.
Recreate the classic rock, paper and scissors.
Player to compete against computer. Allow keys R P S to make selection. First
to 10 points wins.
Place an object in the room, set health as 1000.
Reduce health based on distance from object to mouse click.
To remake a basic version of Tank Trax (like a gorilla,
worms, angry bird type game).
Two players take turns trying to hit each other by
firing their gun.
Power and bullet direction set by position of mouse
relative to player
For this challenge you’ll need to create two
objects and two views, with each view following a different object. Have the
room size as 2000×2000 and each view as 400×400, shown side by side
To display a word at random on the screen. Player
is to type word before time runs out. If player types in time, award points,
reset timer and create a new word. If player does not type in time, reduce
points, reset timer and display a new word.
To create a terrain that can be destroyed (have
holes cut in it) when hit by an object.
Duck Hunt is a classic game from the 1980s. A duck
flies across the screen and the aim is to shoot it down.
To allow the view to follow a player object,
keeping a border whilst moving. Allow moving the player by WSAD and keep a
border of 250.
Output numbers 1 to 50. If a number is multiple of
3, display fizz. If a number is multiple of 5, write buzz. If it is a multiple
of 3 and 5, write fizzbuzz.
Allow the user to enter to numbers between 1 and
1000, A and B
Then to calculate and display each of the
Which number is bigger
Multiple A by B
Divide biggest by
What A plus B is
To create a particle trail when an object moves.
Allow user to click two places in a room. Draw a
rectangle and calculate and display it’s area and perimeter.
To create a side on partially random terrain
generation. To randomly place objects of grass next to each other +/- 3 times
the objects size. To place dirt under each grass tile 3 objects thick and stone
under the dirt. Grass, dirt and stone as separate objects.
To drop a coin from the top that bounces off of
pins to reach the bottom. Award points depending on which section it lands in
User to enter a number (up to 50). Calculate the nth result of the
Fibonacci sequence. The sequence goes: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 and continues
where the new number is the result of the previous 2 values.
To calculate the distance from an object the mouse
Draw the distance and image angle under the object.
To create scripts that convert a decimal entry to
To accept a sentence and then redraw with Xs around
it. For example:
To recreate the classic game frogger. You control a
frog. First you need to get past a busy
road, then navigate floating logs. Finally you need to reach the goal without
being eaten by the croc.
Create an object that allows you to take a
screenshot and save it.
Set up for F to get the save path and take a
Great for allowing sharing of your game on social
To make an object slowly move to a direction, using
the shortest route. For this example towards the mouse cursor.
It will use a couple of scripts do this.
Great for enemy movement, turrets, tanks and more.
To recreate the classic game of pong. Set it up for
two players, player 1 using W S to move, and player 2 using up and down arrows.
Create a target moveable by the mouse. Left button
shoots a bullet. Have some targets that pop up at random for a short time.
Award a point if player hits a target whilst it is shown.
To accept an alphabetical string and count how many
of each letter is present. Display the results as text on the screen.
Player to control a torpedo missile to a target,
avoiding obstacles. Controls are rotate left and right using arrow keys, up
arrow to increase speed whilst held.
To create a random sequence of the numbers 1 to
100, without repetition. Display the output in 4 columns of 25.
To simulate the flipping of a coin 100 times.
Display whether each flip is heads or tails. Keep track of the results and
display results as text.
This is a script that had to be included. It takes
the objects motion, friction and gravity to predict where it will be in a
certain no of steps.
For example I’ve added this to the Tank Trax
Challenge 53. I changed. (note I added gravity to the create event of both
bullets, and removed the vspeed code from the step events).
This calls the script and gets back the positions
in a ds grid. These values are then used to draw points.
To create a script that displays a button with the
text provided as a string.
Great creating buttons based on user input or
results from other code.
To remake the classic Sokoban game where you have
to push blocks into holes. Player can move into empty squares or push single
blocks into empty squares. Aim is to push all blocks into allocated holes.
For level design, see a site such as:
To create a play area with a ball and multiple
players. The aim is took kick the ball around. Only player nearest ball can
move at any one time.
To create a basic track and car that can drive
around it. Make left and right steer car and up to accelerate. Cap a maximum
speed and apply friction. Set the room as 2000×2000 pixels and the view as
800×800 and to follow player.
User to enter a number from 1 to 1000. Convert it
into words and display on screen. For example 234 would be “Two Hundred and
To show only
part of a room at a time and scroll in next part of the room when player leaves
To extract data from the provided INI file (in
resources) and display on screen. Allow left and right arrows to change planet.
The INI file has separate sections for each planet,
and key for each of those.
You work at a bakers. You use flour to make bread.
Flour comes in bags of 7, 3 and 1KG. The baker tells you how many kg of flour
he needs. Calculate how many of each bag size is needed so use the minimum
number of bags possible.
To draw a mini of objects in the player’s vicinity
that rotates based on direction to mouse.
Create a system that allows you draw a rectangle by
clicking and holding mouse button and select any troops within or collide with
the rectangle. Highlight selected troops.
To allow user to place pipes within a room. To
connect up with any pipes next to the newly placed pipe.
Sprites for this are in the resources pack.
To recreate the classic coin op game where horses
move at random speeds from left to right.
Create four horses and have them race each other.
Sprites for the horses are in the resource pack.
To allow the player to add more road objects to an
To draw a chess board and pieces. Allow pieces to
be moved by clicking and drag (no ai). Allow left mouse button to pick up a
piece and right button to place it.
To create the classic style of game play for 1942.
A player at the bottom of the room controls a ship and fires bullets at enemy
planes coming from the top . Some enemies fire bullets back. If a player shoots
down an enemy that get points. If they are hit by an enemy bullet they lose health.
Create a virtual ATM (bank teller) that keeps a
record of 10 card numbers, PIN code and bank balance.
Allow user to enter card no and PIN and withdrawal
cash if available.
Update bank balance accordingly.
To create a moveable ship that can move left and
right by applying a force in the direction, and apply upwards force. Also
simulate some gravity. Aim is to land on platform at bottom of room.
To get colours values from points in a picture and
use these values to re-draw the values to create a pixelated effect.
To create a top down mining system where player can
destroy and build blocks. Allow left click to destroy a block and right click
To draw on screen a standard 12×12 multiplication
Acknowledgements and Credits
David Szesztay Cheese
Scott Holmes Happy Go Lucky
Broke For Free Night Owl
Urbano A. Zafra Danza Filipina
Shadow Script: Peter
Board Game Sprites:
Fire Particle Effect
& Sprites : Martin Crownover – http://martincrownover.com
Random Terrain: Reed
GMLscripts.com – see:
GMLscripts.com/license. For The Following Scripts:
Design & Developed By ThemeShopy