Пример #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();
   }
 }
Пример #2
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>();
 }