Book Image

GameMaker Programming By Example

By : Brian Christian, Steven Isaacs
Book Image

GameMaker Programming By Example

By: Brian Christian, Steven Isaacs

Overview of this book

This book is excellent resource for developers with any level of experience of GameMaker. At the start, we’ll provide an overview of the basic use of GameMaker: Studio, and show you how to set up a basic game where you handle input and collisions in a top-down perspective game. We continue on to showcase its more advanced features via six different example projects. The first example game demonstrates platforming with file I/O, followed by animation, views, and multiplayer networking. The next game illustrates AI and particle systems, while the final one will get you started with the built-in Box2D physics engine. By the end of this book, you have mastered lots of powerful techniques that can be utilized in various 2D games.
Table of Contents (16 chapters)

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 call event_inherited(). Next, check if an instance of the boss object collides with the bottom of the missile (using place_meeting). If so, increment y by 5. What this does is have the missile move down out of the boss' launchers until it's outside...