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...