Enemy 2 Shooting
Enemy 2 Bullets
The enemy2 plane will shoot bullets straight down.
Go into the object enemy2 bullet and add a Create event…
- Vertical Speed: set to 8 (= downwards)
Add a Outside Room event: if bullet has left the room, it’s destroyed
Firing Bullets
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
Room
In your room, delete the enemy1 and enemy3 controllers for now, keeping just enemy2 controller. If you hover over the object, it says at the bottom which object it is.
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 lives
Go into your life controller object and add a No More Lives event:
- Show highscore table
- Restart the game
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?
Enemy 3 Shooting
Enemy3 Bullets
This plane will shoot heat-seeking bullets (following the main plane).
Go into the object enemy3 bullet and add a Create event with the following actions…
- Test Instance: are there any instances of the main plane object?
object “myplane” > 0
- Move Towards: If yes, move the bullet towards the plane where it is.
- Else
- Vertical Speed: set to 8
Add an Outside Room event – have it destroy itself if it leaves the room.
Enemy 3 Plane Fires Bullets
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 by Bullets
Go into your myplane object. Duplicate the Collision with enemy2 bullet event.
It will do the same thing as the other enemy bullet – lose health and destroy the enemy bullet.
Room
Go into your room. Now delete the enemy2 controller and replace with the enemy3 controller object.
Test it out:
- enemy 3 shoots at you, bullets coming towards the plane
- does your health go down?
Main Plane Colliding with Enemies
If the player gets hit by an enemy plane more than 3x, the player loses a life and the main plane should be destroyed
Go into the myplane object and add a Collision with enemy1 event…
- Create Instance: first set to other (= enemy1 plane), not self (= main plane)
set object to explosion1, relative so same places as where enemy plane is
- Destroy Instance: other (enemy plane should disappear, not the main plane)
- Set Health: take away 30
If the plane is hit more than 3x, then player loses a life.
Duplicate the event for Collision with enemy2 and enemy3…
Room
Go back into your room and add the enemy1 contoller and enemy2 controller. You should have all 3 enemy controllers in the room.
Test it out:
- when the plane and enemy plane collide, there should be a small explosion.
- the health should go down by 30