O'Reilly logo

GameMaker Programming By Example by Steven Isaacs, Brian Christian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming a Boss AI

In this section, we'll be programming in a Boss AI for the player to fight after a certain time (a minute specifically). Create a missile sprite where its head points downwards (to make launching it from the boss easier to code), and of course, center its origin. Then, create a boss object and a missile object. We'll work on the boss later, but we'll have to reference it in the missile object.

Make the missile object a child of class_enemy, give it a depth of -10, and of course assign it its sprite. In the Create event for the object, give it two variables: hp, which should be set to 5, and dir, which should be set to 270. dir. This will be the default direction of the missile to face.

Now, add a Step event to the object. First ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required