How to Get New Enemies on "Game Maker"

Written by brian hagan
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Get New Enemies on "Game Maker"
Enemies help add challenge and provide a good "Lose" condition for the game. (game over image by Marvin Gerste from Fotolia.com)

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.

Skill level:
Easy

Other People Are Reading

Things you need

  • Enemy you want to spawn

Show MoreHide

Instructions

  1. 1

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

  2. 2

    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."

  3. 3

    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."

  4. 4

    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.

Tips and warnings

  • You can use multiple alarms in the same enemy timer object to control the spawning of different enemies. Use the random() function in the timer lengths and object X & Y coordinates to make your game a bit less predictable.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.