How to Get New Enemies on "Game Maker"

game over image by Marvin Gerste from

Games aren't much fun if you only have one enemy, and it's not feasible to manually program the creation of every single enemy in your game. The solution then is to automate the process by getting the game to create the enemies for you, a process called spawning instances.

To get enemies spawning in your "Game Maker" game, you will need a "controller" object that will be placed in each room where you want the enemies to appear.

Create a new object called "obj_enemyTimer". This object will not have a sprite associated with it.

Click "Add Event" and select the "Create" event. With this event highlighted, click-and-drag the "Set Alarm" icon from the "Main2" tab to the "Actions" window. A new window will pop up. Enter the time you want the game to wait before making the first enemy. The time is measured in steps; there are 30 steps to a second. If you want a random time, type "random([time])" where "[time]" is the maximum wait period in steps. Note that the "in alarm no:" field is set by default set to Alarm 0. You may change it if you want. Press "OK."

Click "Add Event" again and select "Alarm" and "Alarm 0." Click and drag another "Set Alarm" icon to the "Actions" window and enter the values from the previous step. Also click-and-drag the "Create Instance" icon from "Main1" tab. Choose the enemy you want to spawn from the "Object" drop-down menu and enter the X and Y coordinates where you want the enemy to spawn. Click "OK."

Open the room you want the enemies to appear in. Click-and-drag the "obj_enemyTimer" from the objects list on the left hand side of the screen on to your room where you want the enemies to appear. A small circle with a "?" will appear, indicating that the object is there but has no sprite. The circle will not be visible when you play the game.