Bubble popping animation

It’s in the class Bullet, method display() : the ellipse command.

In the method explode(), note that new Bullet (explosion shrapnel or splinters) is generated with 4 parameters: the first two are the position (around the bubble) the second two is the speed of the shrapnel (away from the bubble).

I think replace 10 (in both places) by 20 or whatever.

Where you initiate the 10 bullets - the 2nd two parameters (number 3 and 4) are the speed

default belongs to switch(). It’s doing the same as the else in if else…: it takes care of the cases we forgot. In our case this would apply if state had a value that we didn’t expect. This would be an error. The exit() would terminate the program. But it’s necessary to check whether state has a wrong value and to register this immediately and terminate the program.

Maybe you should read the tutorial on objects. In this part (named the constructor) in the class we initiate a new Bullet. It gets its values from the parameters of this specific function (the constructor) and these are from the parameters copied into the bullet properties. That’s how objects (the cookies) are made from the class (the cookie maker).
You call this part here:

      // make a new bullet at CURRENT POSITION : start, riseStart
      Fallout newFallout = new Fallout(
        cos(angle)*RADIUS+start, sin(angle)*RADIUS+riseStart, 
        cos(angle)*0.8, sin(angle)*0.8);
2 Likes