Esempio n. 1
0
 // -------------------------------------------------------------------------------------------------------------------------------------------------------
 // Drawing
 public void drawCoin(Graphics g) {
   // draws the coins
   for (Coin i : coinList) {
     g.drawImage(
         i.getPics().get(i.getCounter()), i.getX(), i.getY(), i.getWidth(), i.getHeight(), null);
     i.count();
     i.setDirection();
   }
 }
Esempio n. 2
0
  public void checkPupCollision() {
    // pretty much the same thing as before, however it alsoe does the powerup effects
    for (Powerup p : pupList) {
      if (p.getOnScreen()) { // can be removed later on
        if (p.checkCollision(player1)) {
          pupRemove.add(p);
          player1.setPower(p.getType());
          player1.setVelo(50);
        }
      } else {
        pupRemove.add(p);
      }
    }
    if (player1.getPower().equals("Lucky")) { // changes everything to stars
      for (Coin c : coinList) {
        starList.add(new Star(c.getX(), c.getY(), 2));
        cRemove.add(c);
      }
      for (Box b : boxList) {
        starList.add(new Star(b.getX(), b.getY(), 2));
        bRemove.add(b);
      }
      for (Enemy e : enemyList) {
        starList.add(new Star(e.getX(), e.getY(), 2));
        eRemove.add(e);
      }
    } else if (player1.getPower().equals("Magnet")) { // moves the coins towards the player
      for (Coin c : coinList) {
        c.moveTowards(player1);
      }
    } else { // else do nothing

    }
    for (Powerup p : pupRemove) {
      poofList.add(new Poof(p.getX(), p.getY(), 2));
      pupList.remove(p);
    }
    pupRemove = new ArrayList<Powerup>();
  }
Esempio n. 3
0
 public void checkCoinCollision() {
   for (Coin c : coinList) {
     if (c.getOnScreen()) { // check if the coin is on the screen
       if (c.checkCollision(
           c.getPics().get(c.getCounter()), player1)) { // if the player collides with the coin
         cRemove.add(c); // remove the coin
         player1.setVelo(50); // set the velocity so the player moves up
         player1.setDown(false); // set the down false (players moving up)
         coins += c.getValue(); // check the coins collected
         score += c.getPoints(); // get the score
         if (musicOn) {
           coinSound.play(); // play the sound
         }
       }
     } else {
       cRemove.add(c); // remove the coin
     }
   }
   for (Coin c : cRemove) {
     poofList.add(new Poof(c.getX(), c.getY(), 0));
     coinList.remove(c);
   }
   cRemove = new ArrayList<Coin>();
 }