Enemy Planes Flying

Enemy 1

Obj: enemy1

Create the enemy1 object. 

First add a Create event where it moving downwards with

  • Vertical Speed 4.

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), y = -16 
    so it starts above top of the room 

Room

Change the room grid to 32x32.

Then 3-4 enemy1 planes in your room and test it out

  • do they fly down when in the room?
  • once they've gone out the bottom, do they reappear at the top?

Enemy 1 Controller

We'll create a controller to keep creating enemy1 planes with a bit of delay.

Create a new object enemy 1 controller with no sprite. 

  • Create event
    • Create Instance: enemy1 object,
      X = random(room_width) and Y = -16 
    • Alarm1 = 100
  1. Duplicate the event for Alarm1 event
  2. Then add a Test Instance Count action before the Alarm. If there are less than 8 of the enemy1 planes in the room, then we can set the alarm/timer to create more.

Room

Put the enemy 1 controller object somewhere near the bottom of the room...

Also delete the enemy1 plane objects from the room.

Test out if it works. If it does, continue.


enemy 2 plane

obj: enemy2

Start by duplicating enemy1 to create enemy2 - change the sprite for now.


obj: enemy 2 controller

Create a new object - enemy 2 controller - with no sprite.

  • Create event
    • Create Instance: enemy2 object,
      X = random(room_width) and Y = -16 
    • Alarm2 = 200
  1. Duplicate the event for Alarm2 event
  2. Then add a Test Instance Count action before the Alarm. If there are less than 5 of the enemy2 planes in the room, then we can set the alarm/timer to create more.

Room

To check that it works, go into your room and add enemy 2 controller object.


Enemy 3 plane

Obj: enemy3

Duplicate the enemy1 object again to create enemy3. Change the name and sprite.


obj: enemy 3 controller

Create a new object enemy 3 controller with no sprite. 

  • Create event
    • Create Instance: enemy3 object,
      X = random(room_width) and Y = -16 
    • Alarm3 = 300
  1. Duplicate the event for Alarm2 event
  2. Then add a Test Instance Count action before the Alarm. If there are less than 3 enemy3 planes in the room, then we can set the alarm/timer to create more.

Room

Now add the enemy 3 controller to your room.

Test it out and make sure you see all 3 planes flying down.