Firing the bubble

To fire the bubble, the player must press UP arrow key.

The idea: Detect when the player presses UP arrow key, and then calculate the horizontal and vertical speed of the bubble according to the cannon's rotation.

The development: This part has some similarities with the enemy ships' movement you dealt with during the making of Astro-PANIC!

Before we start checking for the UP arrow key, we'll define the bubble speed and some other variables. Let's make a couple of new declarations:

private const ROT_SPEED:uint=2; private const R:uint=18; private const D:Number=R*Math.sqrt(3); private const DEG_TO_RAD:Number=0.0174532925; private const BUBBLE_SPEED:uint=10; private var cannon:cannon_mc; private var left:Boolean=false; private var ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.