Types of Upgrades

In the rubric you are required to have two active / functional upgrades.  This means that they need to change the behavior of your player in a meaningful way.  In short, they require code that extends beyond a simple addition or subtraction.  

You are welcome and encouraged to have both in your project.  Just make sure that at least two represent a functional change.

Passive (Numerical)

Active (Functional)

Stacking Or Not?

For each upgrade, you should ask yourself - do all of these work together?  Consider three examples:



Tracking Multishot

In main, we'll add a new variable to keep track of multishot.  For now, let's make it active at the start of the program.  We'll change that back later.

boolean hasMultishot = true;

Making The Player Shot Fire on Angles

Please see the tutorial in the More Enemies page on how to make a shot that fires at an angle.  

I think the easiest way is to simply modify the PlayerShotBasic class.   New code in green, changes in blue.

class PlayerShotBasic extends PlayerProjectile


   PlayerShotBasic(float x, float y, float xSpeed, float ySpeed)


      super(x, y, blueShot.width, blueShot.height, xSpeed, ySpeed);

      image = blueShot;

      damage = PLAYER_SHOT_DAMAGE;



Once you make this change, you'll have to add a few parameters for the basic bullets to make them fire straight up.  In this case, the xSpeed is zero and the ySpeed is -8.

Test your program - it should work exactly as it did before.

Adding More Bullets

In the player's act() method, we'll simply add more bullets sometimes.  These bullets only appear if the player has the multishot upgrade.

void act()


   /* other code */

   if(getKey(' ') && shotTimer == 0)


      /* original shots and timer code */



       objects.add(new Playershot(x+0, y, -1.5, -8));  

       objects.add(new Playershot(x+24, y, 1.5, -8));   




Test your program - are you now firing 4 total shots?  Are some at an angle?  Before moving on, turn multishot off and make sure that it reverts back to normal behavior.

Buying Multishot

To purchase multishot, we use the same approach as we did for our extra life upgrade... with one small change.  We need to make sure the user doesn't buy multishot twice, so we add a fourth requirement to our if statement.  

void updatePause()


  /* other code */

  if(getKey('2') && credits >= 30 && pauseTimer == 0 && !hasMultishot)


     credits = credits - 30;

     pauseTimer = 15;

   hasMultishot = true;



Can the user purchase multishot?  Is it possible to accidentally buy it more than once?

Going Gray

One final and optional step is to change the color of the text once the upgrade has been purchased.  When drawing the text for the upgrade, set a different fill color based on whether the upgrade has already been purchased or not.