**This is an old revision of the document!**

9. Adding bombs

It's great to have the core mechanic of collecting the shapes in place, but it gets boring quite quickly, and it's way too easy. What if we could increase the difficulty level by introducing objects that you shouldn't collect? Behold: bombs!

IMG 122

Click to Add a new object…

IMG 123

…and select the Sprite.

IMG 124

Object's name will be Obstacle, same goes for the name of the animation. We have two frames of the animation to show, and it will last for 0,1 seconds, looped.

IMG 125

Add another comment, and call it Obstacle.

IMG 127

Add new condition, select the Obstacle and search the Other conditions.

IMG 128

Within Timers and time, select Value of a scene timer. In the right panel, enter Time in seconds which will be RandomInRange(10,20), and Timer's name: ObstacleCreation.

This will create a new timer that will spawn a bomb independently from spawning the shapes, and it will appear randomly once every 10 to 20 seconds.

IMG 129

Now the action - select the Obstacle, search for Create an object, and set the X position to RandomInRange(80, 640-80), and Y to -100. It's the exact same approach as with shapes.

IMG 131

The second action to add is Start (or reset) a scene timer in Timers and time, and then ObstacleCreation as the name.

IMG 132

It should look like this above after you successfully complete the steps. If it is, add another action.

IMG 133

Remember about having the Obstacle selected, then look for Add a force (angle), enter 90 into the Angle field, and 200 into the Speed.

IMG 134

We'll make sure the bomb is in front of the shapes, and not behind them - to do that, we're gonna use Z order. It's a way to tell the game how we want the objects to be rendered. Obstacle, then Z order, then = (set to) and 4.

IMG 135

Launch the game and see the shapes falling down the screen, with bombs appearing once every few shapes and falling independently. Colleting shapes give you points, while bombs do nothing yet.

Bombs are challenging, so let's make the gameplay a little bit easier by introducing lives.