Enemy 2 Plane Flying

Go into the enemy2 object.

Create event

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

Step event

Add a Step event.

  • Test Variable: if y > 512
    Checking if enemy plane gone past the bottom of the room, so
    480 (room height) + 32 (height of plane) = 512
    has the plane gone past the bottom of the room?
  • If so, Jump to Position: x = random(room_width) and y = -16
    so it starts above top of the room

Enemy 2 Controller

Go into enemy 2 controller object.

Create event

Add a Create event:

  • Create Instance: enemy2 object
    X = random(room_width)
    Y = -16
  • Alarm2 = 200

Alarm 2 event

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

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

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

Enemy 2 Hit

Go into the bullet object:

  • Right-click > Duplicate Event (on the Collision with enemy1 )
  • set to Collision with enemy2
  • change Set Score so player gets more points for shooting this plane since it will be harder to hit later on – set to 10 points

Enemy 2 Bullet

The enemy2 plane will shoot bullets straight down.

Create event

Go into the object enemy2 bullet and add a Create event…

  • Vertical Speed: set to 8 (= downwards)

Outside Room event

Add a Outside Room event: if bullet has left the room, it’s destroyed

Enemy 2 Shooting

Go into the enemy2 plane object. Change the Step event a bit. Add 2 new actions at the end…

  • Test Chance: set sides to “30”.
  • Create Instance: object “enemy2 bullet”, x = 0, y = 16, relative
    starts firing bullets (down, from center of the plane).

Main Plane Hit

Go into your myplane object and add a Collision with enemy2 bullet event. If the main plane gets hit, it gets a bit weaker, loses some health.

  • Set Health: lose 5 (make sure relative!)
  • Destroy Instance: other = enemy2 bullet

Test it out.

  • Do the enemy2 planes shoot bullets?
  • Does the main plane’s health go down?

Main Plane Destroyed

Once the main plane has lost all its health, it should blow up, be destroyed in a big explosion.

Big Explosion

Go into the object explosion2 object and add an Animation End event with the following actions..

  • Destroy Instance (self)
  • Sleep – to make sure the exploding sound is finished, 1 sec.
  • Create Instance: create a myplane in the same spot.
  • Set Lives: lose a life (relative)

No more Health

When the main plane has No More Health, we want it to turn into a big explosion.

  • Change Instance: if no more health, want to change object: myplane into a big explosion, explosion2
  • Set Health: set it back to 100

Test this out – make sure your plane explodes when you’ve hit too many enemy planes. When you run out of health, does your plane explode? do you lose a life?

Keep your game open in the Enemy 2 testing level to get checked off…