O'Reilly logo

GameMaker Essentials by Nathan Auckett

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

Enemies

We now have the very basics of a game. We have a player who has something to do. However, there is no challenge to the game at this point. In nearly every game, there is some sort of challenge or problem to overcome. This gives the player more purpose and makes their goal harder to achieve.

For this game, let's simply add in some enemies. These enemies will spawn randomly just like the collectable items, and they will also randomly choose to go either vertically or horizontally. When they collide with a wall, they will turn around and go the other way. We can also randomize their speed to add more variety and challenge.

Once again, let's start by creating a new sprite. Name it spr_Enemy and create a simple 32 x 32 red square. Once again, ...

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