6 Dropping The Burgers
The buildings are destroyed by the burgers. This process of creating and dropping the bombs starts in the plane object's window. The process for dropping bombs is controlled by the canfire variable we created with the plane object. When canfire is equal to 0, the plane can drop a bomb. The plane cannot drop a bomb until its previous bomb has hit a building or gone off the screen. So after we create a bomb, we set the variable canfire to 1.
Start with a Test Variable action like so,
Drag in a Start Block icon and follow that with a Create Instance icon to create the burger.
You may want to adjust the values in the box after you have tested the game in a wee while.
Next you need to set the variable canfire to 1,
Finish off with an End Block icon and close the plane object window.
Now turn your attention to the burger itself. We need to make it fall down the screen, in line with one of the 'columns' formed by one of the buildings. We do this by making it snap to the nearest horizontal grid position based on 32 pixel squares (the width of the buildings).
Add a Create Event and drag in the Move Fixed action. Set the object to move down the screen at a speed of 5.
Follow that with an Align To Grid action, filling it in like so,
Add a Collision Event with the building, and drag in a Destroy Instance action.
Add an Outside Room Event and drag in a Destroy Instance action.
Drag in a Destroy Event and drag in a Set Variable action and fill it in as shown,
This means that the player can now fire bombs again.
You can test the whole bomb action at this point. Beware, the buildings won't disappear yet.
Getting Rid Of The Buildings
Open up the obj_building window. The required actions are,
- Create an instance of the fire object
- Destroy the building instance
- Play an explosion sound
- Increase the score by 10
This is done as follows,
Limiting The Fire's Lifespan
Open up the fire object window and add a Create Event. Drag in a Set Alarm icon and fill it in as shown,
Add an Alarm0 Event and drag in a Destroy Instance action.
Save and test the game - that's sort of it.