Game Maker: How to Make Enemies in Game Maker
Browse articles:
Auto Beauty Business Culture Dieting DIY Events Fashion Finance Food Freelancing Gardening Health Hobbies Home Internet Jobs Law Local Media Men's Health Mobile Nutrition Parenting Pets Pregnancy Products Psychology Real Estate Relationships Science Seniors Sports Technology Travel Wellness Women's Health
Browse companies:
Automotive Crafts, Hobbies & Gifts Department Stores Electronics & Wearables Fashion Food & Drink Health & Beauty Home & Garden Online Services & Software Sports & Outdoors Subscription Boxes Toys, Kids & Baby Travel & Events

Game Maker: How to Make Enemies in Game Maker

Game Maker has very easy coding in it, however, it can be hard to learn at some points. Now you can finish making a TDS. This is guide shows the easiest way on how to make one. Get better at GML and find out how to get better at it fast now!

Before you start with this guide, read this article first to catch up on this. After you have done that, it is time to add enemies. Start out by creating a sprite. Name it spr_enemy, click edit sprite create a new sprite and leave the width and height at 32 and click OK. Zoom in eight times. Click Draw an ellipse or press the hotkey I. Make sure you make the right color different from the color of middle of spr_main. Make a circle. Click the check, click it on the next screen, click center, on the next screen, click OK.

Open obj_main, go to the step event and change all the place_empty's to place_free. It should look like this 

if keyboard_check(vk_left) and place_free(solid.x-5,solid.y) x -= 5

if keyboard_check(vk_right) and place_free(solid.x+5,solid.y) x += 5

if keyboard_check(vk_up) and place_free(solid.x,solid.y-5) y -= 5

if keyboard_check(vk_down) and place_free(solid.x,solid.y+5) y += 5

Create an object and name it obj_enemy. Make its sprite spr_enemy. Click OK, open obj_bullet, click add event, choose collision-obj_enemy. Drag and Drop an execute code button, Make sure it is open and type in 

with self


with other


This means when the bullet collides with obj_enemy, the bullet and the enemy will be destroyed.

Click the check mark, click OK. Save the game. Open room0, put in as many enemies as you want. Open obj_main. Click add event, choose collision with obj_enemy. Drag and Drop an execute code button, with it open, type in

HitPoints = 100

This will set the variable HitPoints to 100. Open the execute code button in obj_main in the collision with obj_enemy eventyy type in 

HitPoints -= 1

if HitPoints < 1{

with self




This will make the variable HitPoints go down by 1 every step that it is touching obj_enemy, it will also destroy obj_main and end the game when it runs out of HitPoints. Click the check mark, Click OK. Create an object and name it draw_score. Add an event and choose Draw. Drag and drop the execute code button inside it, type in


Then add the event step. Type in 

if obj_main.objMain = false{

with self



This will make the number 100 be at the top left corner of the screen. Make its depth 10 (under "visible" and "solid"). Open room0 and place draw_text anywhere in the room, other than on an enemy or on obj_main. Click the check mark, click OK, click save. Now you're done, just run the game and have fun with it.

Additional resources:

Need an answer?
Get insightful answers from community-recommended
in Computer Programming & Languages on Knoji.
Would you recommend this author as an expert in Computer Programming & Languages?
You have 0 recommendations remaining to grant today.
Comments (1)

I do have this program.  I will have to get back to it as far as creating games in the future.