Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Gamemaker Essentials

You're reading from   Gamemaker Essentials Learn all the essential skills of GameMaker: Studio and start making your own impressive games with ease

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784396121
Length 154 pages
Edition 1st Edition
Arrow right icon
Toc

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, this can be changed later on, but for now, let's keep things simple.

Now, create a new object and name it obj_Enemy. Link the new sprite to it; then, add a create event and drag in a code block.

There are three essential variables we need to create for...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime