コード例 #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 scrollCoins() {
   for (Coin i : coinList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
     i.setYPos(i.getYPos() + (int) (player1.getVelocity() * 0.3));
     i.setYMax(i.getYMax() + (int) (player1.getVelocity() * 0.3));
   }
 }
コード例 #3
0
ファイル: Team.java プロジェクト: GodPlaysChess/Jacal_maven
 public void takeCoin() {
   if (findSelectedObject() instanceof Pirate && ((Pirate) findSelectedObject()).isOn_plane()) {
     for (Coin O : GameData.Coins) {
       if (O.x_on_map == findSelectedObject().x_on_map
           && O.y_on_map == findSelectedObject().y_on_map
           && O.fields_left == findSelectedObject().fields_left) {
         O.takeOrPut();
       }
     }
   } else {
     for (Coin O : GameData.Coins) {
       if (O.x_on_map == findSelectedObject().x_on_map
           && O.y_on_map == findSelectedObject().y_on_map
           && O.fields_left == findSelectedObject().fields_left) {
         O.takeOrPut();
         break;
       }
     }
   }
 }
コード例 #4
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>();
  }
コード例 #5
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>();
 }
コード例 #6
0
 public void moveCoins() {
   for (Coin i : coinList) {
     i.move();
   }
 }