예제 #1
0
 public void moveLayerThree(Graphics g) {
   backy += (int) (player1.getVelocity() * 0.1);
   midy += (int) (player1.getVelocity() * 0.5);
   drawEnemy(g);
   drawCoin(g);
   drawBox(g);
   drawPoof(g);
   drawStar(g);
   drawJumper(g);
   drawSpike(g);
   drawPup(g);
   if (backy <= dieHeight) {
     // System.out.println(die);
     g.drawImage(player1.move(2), player1.getX(), player1.getY(), this);
     if (player1.animationComplete()) {
       die = true;
     }
   } else {
     if (backy <= dieHeight) {
       player1.resetCounter();
     }
     if (keys[KeyEvent.VK_RIGHT]) {
       g.drawImage(player1.move(1), player1.getX(), player1.getY(), this);
     } else if (keys[KeyEvent.VK_LEFT]) {
       g.drawImage(player1.move(-1), player1.getX(), player1.getY(), this);
     } else {
       g.drawImage(player1.move(0), player1.getX(), player1.getY(), this);
     }
   }
 }
예제 #2
0
 public void drawPowerUpEffect(Graphics g) {
   if (player1.getPower().equals("Magnet")) {
     Image magpic = magnetList.get((int) count % 6);
     g.drawImage(
         magpic,
         player1.getX() - ((magpic.getWidth(null) - player1.getWidth()) / 2),
         player1.getY() - ((magpic.getHeight(null) - player1.getHeight()) / 2),
         magpic.getWidth(null),
         magpic.getHeight(null),
         this);
     count += 0.1;
   } else if (player1.getPower().equals("Ball")) {
     g.drawImage(
         ballPower,
         player1.getX() - ballPower.getWidth(null) / 2 + 17,
         player1.getY() + player1.getHeight() - 20,
         ballPower.getWidth(null),
         ballPower.getHeight(null),
         this);
   } else if (player1.getPower().equals("Sheild")) {
     g.drawImage(
         sheildPower,
         player1.getX() - ((sheildPower.getWidth(null) - player1.getWidth()) / 2),
         player1.getY() - ((sheildPower.getHeight(null) - player1.getHeight()) / 2),
         sheildPower.getWidth(null),
         sheildPower.getHeight(null),
         this);
   } else if (player1.getPower().equals("Umbrella")) {
     g.drawImage(
         umbrellaPower,
         player1.getX() - (umbrellaPower.getWidth(null) / 2) + 20,
         player1.getY() - umbrellaPower.getHeight(null) + 40,
         umbrellaPower.getWidth(null),
         umbrellaPower.getHeight(null),
         this);
   } else if (player1.getPower().equals("")) {
   }
 }
예제 #3
0
 public void loseCoins() {
   int x = player1.getX();
   int y = player1.getY();
   double losePercentage = 0.1;
   for (int i = 0;
       i < (int) coins * losePercentage;
       i++) { // makes the user lose 10 percent of the coin and draws them in a circle
     // System.out.println(i);
     int xPos = x + (int) (100 * Math.cos(Math.toRadians((360 / (coins * losePercentage)) * i)));
     int yPos = y - (int) (100 * Math.sin(Math.toRadians((360 / (coins * losePercentage)) * i)));
     coinList.add(new Coin(xPos, yPos, 3));
   }
   coins -= (int) (coins * losePercentage);
 }