Enemy 3 Planes Flying

Open the enemy3 object…

Create event

Add a Create event where you set Speed Vertical to “4”.

Step event

Also add a Step event…

  • Test Variable: if y > 512
  • If so, Jump to Position: x = random(room_width) and y = -16

Enemy 3 controller

Go into enemy 3 controller object.

Create event

Add a Create event …

  • Create Instance: enemy3 object with X = random(room_width) and Y = -16
  • Set Alarm3 to 300

Alarm 3 event

Right-click on the Create event and Duplicate … set to the Alarm3 event.

Add a Test Instance Count action at the top… set it to test enemy3 planes, if there are less than 3 of them

Enemy 3 Hit

Go into the bullet object:

  • Right-click > Duplicate either Collision with enemy 1 or 2 event for Collision with enemy3
  • give the player 20 points for hitting this enemy plane

Save and test the game, using the ‘N’ key to skip to the “Testing: Enemy 3” level. Make sure the planes are flying, and you can shoot them, getting points.

Enemy 3 Bullet

Create event

Go into the object enemy3 bullet and add a Create event with the Test Instance action – check if there are any instances of the main plane…

Then add the action Move TowardsIf yes, move the bullet towards the plane where it is.

Now add Else and set Vertical Speed: set to 8

So the Create event should look like this…

Outside Room event

Add an Outside Room event with the Destroy Instance action (have it destroy itself if it leaves the room).

Enemy 3 Shooting

Go into the enemy3 plane object, into the Step event and add the following at the end:

  • Test Variable: if y less than 360

We don’t want to have the enemy3 plane be able to shoot when it’s below our main plane. It’s hard enough to avoid the bullets as is. So we’ll first test if the enemy3 plane is a bit above the score panel at the bottom. From the top of the room to the bottom = 480. The bottom score panel’s height = 76 and the enemy3 plane’s height = 32. So 480 – 76 – 32 = 372; so we’ll use 360 to be safe, add a bit of an extra margin.

Inside Start End blocks add:

  • set Chance to 50 (so less often than enemy2 bullets), and
  • change the type of bullet for the Create Instance action to enemy3 bullet.

Main Plane Hit

Go into your myplane object. Right-click and Duplicate the Collision with enemy2 bullet event to create a Collision with enemy3 bullet event.

It will do the same thing as the other enemy bullet – lose health and destroy the enemy bullet.

Save and test the game, using the ‘N’ key to skip to the “Testing: Enemy 3” level.

  • enemy 3 shoots at you, bullets coming towards the plane
  • does your health go down?