private void spawnPowerup(AnimatedSprite sprite) {
		int n = rand.nextInt(100);
		if(n > 12) return;
		
		AnimatedSprite spr = new AnimatedSprite(this, graphics());
		spr.setRotationRate(8);
		spr.setPosition(sprite.position());
		double velx = rand.nextDouble();
		double vely = rand.nextDouble();
		spr.setVelocity(new Point2D(velx, vely));
		spr.setLifespan(500);
		spr.setAlive(true);
		
		//customize the sprite based on powerup type
        switch(rand.nextInt(6)) {
        case 0:
            //create a new shield powerup sprite
            spr.setImage(powerupShield.getImage());
            spr.setSpriteType(SPRITE_POWERUP_SHIELD);
            sprites().add(spr);
            break;

        case 1:
            //create a new health powerup sprite
            spr.setImage(powerupHealth.getImage());
            spr.setSpriteType(SPRITE_POWERUP_HEALTH);
            sprites().add(spr);
            break;

        case 2:
            //create a new 250-point powerup sprite
            spr.setImage(powerup250.getImage());
            spr.setSpriteType(SPRITE_POWERUP_250);
            sprites().add(spr);
            break;

        case 3:
            //create a new 500-point powerup sprite
            spr.setImage(powerup500.getImage());
            spr.setSpriteType(SPRITE_POWERUP_500);
            sprites().add(spr);
            break;

        case 4:
            //create a new 1000-point powerup sprite
            spr.setImage(powerup1000.getImage());
            spr.setSpriteType(SPRITE_POWERUP_1000);
            sprites().add(spr);
            break;

        case 5:
            //create a new gun powerup sprite
            spr.setImage(powerupGun.getImage());
            spr.setSpriteType(SPRITE_POWERUP_GUN);
            sprites().add(spr);
            break;

        }
	}