Ejemplo n.º 1
1
 public void victory() {
   battleWon = true;
   player.expGain(totalExperience);
   enemies.removeAll(enemies);
   spellsThrown.removeAll(spellsThrown);
   staminaTimer.stop();
 }
Ejemplo n.º 2
0
 public String[] getPropertyName() {
   String[] save = new String[x.getProperties().size()];
   for (int i = 0; i < x.getProperties().size(); i++) {
     save[i] = (Game.SlotsList[x.getProperties().get(i)]).getName();
   }
   return save;
 }
Ejemplo n.º 3
0
 public void scrollEnemies() {
   for (Enemy i : enemyList) {
     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));
   }
 }
Ejemplo n.º 4
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));
   }
 }
Ejemplo n.º 5
0
 public void checkStarCollision() {
   for (Star s : starList) {
     if (s.getOnScreen()) { // if the star is on the screen we need to check if player collides
       if (s.checkCollision(
           s.getPics().get(s.getCounter()),
           player1)) { // if the player collides with the star we remove it then change the
         // velosity to the distance that the star provides
         sRemove.add(s); // remove star once you collide with it
         player1.setVelo(s.getDist()); // changes the velocity
         player1.setInvi(true); // sets the player invisble for a few seconds
         score += s.getPoints(); // points increase by the star type
         if (musicOn) {
           starSound.play(); // playthe star sound
         }
       }
     } else {
       sRemove.add(s); // remove the star if its not on the screen
     }
   }
   for (Star s : sRemove) {
     poofList.add(new Poof(s.getX(), s.getY(), s.getNum() + 3)); // make the poof effect
     starList.remove(s);
   }
   sRemove = new ArrayList<Star>();
 }
Ejemplo n.º 6
0
 public void checkEnemyCollision() {
   for (Enemy e : enemyList) {
     if (e.getOnScreen()) { // can be removed later on
       // goes through all the enemies and checks if they collide
       if (e.checkCollision(e.getPics().get(e.getCounter()), player1)) {
         if (player1.getInvi() == false) {
           // If the player is not invisble then you get spiked.
           if (player1.getVelocity() > 0) { // if the player hits it from the bottom
             player1.setSpikeVelo();
             loseCoins();
           } else {
             player1.setVelo(
                 50); // if the player is on top instead the player bounces off the enemy
             if (musicOn) {
               bounce.play();
             }
           }
         }
         eRemove.add(e); // once we hit, we remove the enemy
       }
     } else {
       eRemove.add(e); // if the enemy goes of the screen, we remove
     }
   }
   for (Enemy e : eRemove) {
     poofList.add(new Poof(e.getX(), e.getY(), 1)); // removes all the enemies
     enemyList.remove(e);
   }
   eRemove = new ArrayList<Enemy>();
 }
Ejemplo n.º 7
0
 @Override
 public void update(Observable o, Object arg) {
   if (arg instanceof Player) {
     Player player = (Player) arg;
     int points = player.getPoints();
     System.out.println("Spieler" + player.getNum() + "an der Reihe");
     if (player.getNum() == 1) {
       System.out.println("Spieler1 punkte++");
       points1Num.setText("" + points);
     } else if (player.getNum() == 2) {
       System.out.println("Spieler2 punkte++");
       points2Num.setText("" + points);
     }
   } else {
     GameController controller = (GameController) arg;
     if (controller.getPlayer().getNum() == 1) {
       ImageIcon image = new ImageIcon("../gfx/spieler1_play.png");
       l1.setIcon(image);
       ImageIcon imageOld = new ImageIcon("../gfx/spieler2.png");
       l2.setIcon(imageOld);
       System.out.println("spieler gewechselt");
     } else {
       ImageIcon imageI = new ImageIcon("../gfx/spieler2_play.png");
       l2.setIcon(imageI);
       ImageIcon imageOldI = new ImageIcon("../gfx/spieler1.png");
       l1.setIcon(imageOldI);
     }
   }
 }
Ejemplo n.º 8
0
 public void mouseClicked(MouseEvent e) {
   if (scene == BATTLE) {
     if (!battleWon) {
       int target = 0;
       if (kickDirt.contains(mX, mY) && player.getStamina() >= 33.3 && !player.getDeath()) {
         spellsThrown.add(
             new Spell(
                 0,
                 new Color(153, 76, 0),
                 player.centerX(),
                 player.centerY(),
                 enemies.get(target).centerX(),
                 enemies.get(target).centerY(),
                 target));
         player.staminaGain(-333);
       }
       if (hurlPebble.contains(mX, mY) && player.getStamina() >= 100 && !player.getDeath()) {
         spellsThrown.add(
             new Spell(
                 1,
                 Color.LIGHT_GRAY,
                 player.centerX(),
                 player.centerY(),
                 enemies.get(target).centerX(),
                 enemies.get(target).centerY(),
                 target));
         player.staminaGain(-1000);
       }
     }
   }
 }
Ejemplo n.º 9
0
	public void PlayerSelectedTarget(int x,int y)
	{
		m_TargetLoc[m_CurrentPlayer.getNumOfSelectedTargets()-1] = new Location(x,y);
		m_GameWindow.updateActionConsole(m_CurrentPlayer.getName() + ":  Selected Target...\n\t" +
										 m_CurrentPlayer.getName() + ": Has " + (5 - m_CurrentPlayer.getNumOfSelectedTargets()) + " Left");
		System.out.println(m_CurrentPlayer.getNumOfSelectedTargets() + " num of targets");
	}
Ejemplo n.º 10
0
  public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2d = (Graphics2D) g;

    g2d.drawImage(img, 0, 0, null);
    g2d.drawImage(p.getImage(), p.getX(), p.getY(), null);
  }
Ejemplo n.º 11
0
  public void drawVictory(Graphics g) {
    g.setColor(new Color(0, 0, 0, 200));
    g.fillRect(195, 220, 410, 110);
    g.setColor(new Color(255, 255, 255, 200));
    g.fillRect(200, 225, 400, 100);
    g.setColor(new Color(0, 0, 0, 200));
    g.setFont(new Font("Bell MT", Font.BOLD, 20));
    FontMetrics metrics = g.getFontMetrics(new Font("Bell MT", Font.BOLD, 20));
    int hgt = metrics.getHeight();

    String initialMessage;
    String followupMessage;

    if (nextWindow) {
      initialMessage = "You have gotten stronger.";
      followupMessage = player.getName() + " is now level " + player.getLevel() + "!";
    } else {
      initialMessage = "You survived!";
      followupMessage = "You and your allies gain " + totalExperience + " experience!";
    }

    // Hgt = 26
    int adv = metrics.stringWidth(initialMessage);
    g.drawString(initialMessage, getWidth() / 2 - adv / 2, 234 + hgt);
    adv = metrics.stringWidth(followupMessage);
    g.drawString(followupMessage, getWidth() / 2 - adv / 2, 269 + hgt);
  }
Ejemplo n.º 12
0
  public void keyReleased(KeyEvent key) {

    if (key.getKeyCode() == 37) {

      leftcheck = false;
      if (rightcheck) {
        player.ta = changet;
      } else {
        player.ta = 0;
      }
    }

    if (key.getKeyCode() == 39) {

      rightcheck = false;
      if (leftcheck) {
        player.ta = -changet;
      } else {
        player.ta = 0;
      }
    }

    if (key.getKeyCode() == 32) {

      grav = false;
    }
  }
Ejemplo n.º 13
0
 public void keyReleased(KeyEvent evt) {
   keys[evt.getKeyCode()] = false;
   // reset the counters for for the sprite s
   player1.resetCounter();
   if (!player1.getPower().equals("Balloon")) {
     player1.resetPicCounter();
   }
 }
Ejemplo n.º 14
0
 // paints the player, items, and rooms
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   Environment Layout = new Environment();
   Layout.drawRoom(mapX, mapY, g);
   Player PlayerSprite = new Player();
   PlayerSprite.drawPlayer(x, y, g);
   Layout.items(x, y, g, getItem);
 }
Ejemplo n.º 15
0
 private void assignCards() {
   player.clearCards();
   dealer.clearCards();
   for (int i = 0; i < 3; ++i) {
     player.assignCard(genNewCard());
     dealer.assignCard(genNewCard());
   }
 }
Ejemplo n.º 16
0
 /**
  * Update changing components.
  *
  * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
  */
 @Override
 public void paintComponent(Graphics g) {
   money.setText(String.valueOf(player.getMoney()));
   record.setText(String.valueOf(bestScore));
   dealerPanel.removeAll();
   playerPanel.removeAll();
   for (Card dealerCard : dealer.getCards()) dealerPanel.add(dealerCard);
   for (Card playerCard : player.getCards()) playerPanel.add(playerCard);
   revalidate();
 }
Ejemplo n.º 17
0
  private void final_scores(Match m) {
    int numPlayers = 0;
    int playerTotal = 0;
    int gameNum = 0, maxGameNum = 0;
    Player p;

    // Create window
    final JFrame f = new JFrame();
    JPanel titles = new JPanel();
    titles.setLayout(new BorderLayout());
    JLabel maintitle = new JLabel("Yahtzee World!");
    maintitle.setFont(new Font("SansSerif", Font.ITALIC, 24));
    JLabel instr = new JLabel("Final Scores (total of game scores).");
    instr.setFont(new Font("SansSerif", Font.PLAIN, 16));
    titles.add(maintitle, "North");
    titles.add(instr, "South");

    JPanel names = new JPanel();
    JLabel l[] = new JLabel[Match.MAXPLAYERS];
    final JTextField t[] = new JTextField[Match.MAXPLAYERS];

    numPlayers = m.getNumPlayers();
    names.setLayout(new GridLayout(numPlayers, 2));
    for (int playerNum = 0; playerNum < numPlayers; playerNum++) {
      p = m.getPlayer(playerNum);
      playerTotal = 0;
      l[playerNum] = new JLabel(p.getName());
      t[playerNum] = new JTextField(20);
      names.add(l[playerNum]);
      names.add(t[playerNum]);
      maxGameNum = (m.getGameNum() >= Match.MAXGAMES) ? (Match.MAXGAMES - 1) : m.getGameNum();
      for (gameNum = 0; gameNum <= maxGameNum; gameNum++) {
        playerTotal += p.getScoreCell(gameNum, CellCodes.GRANDTOTAL);
      }
      t[playerNum].setText(String.valueOf(playerTotal));
    }

    JButton quit = new JButton("Quit");
    quit.addActionListener(
        new ActionListener() {
          // This method is called when the user clicks the JButton
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    f.add(titles, "North");
    f.add(names, "Center");
    f.add(quit, "South");
    f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
    f.setResizable(false);
  }
Ejemplo n.º 18
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);
 }
Ejemplo n.º 19
0
 private void movePlayers() {
   onePlayerAlive = false;
   Iterator i = players.iterator();
   while (i.hasNext()) {
     Player p = (Player) i.next();
     if (p.getLives() == 0) {
       p.setActive(false);
     }
     if (p.isActive()) {
       onePlayerAlive = true;
       p.move();
     }
   }
 }
Ejemplo n.º 20
0
  private void setup() {
    playerSetup();

    deathLocation = new int[4];
    Arrays.fill(deathLocation, -1);

    menu.setVisible(false);
    this.revalidate();

    audioSetup();

    Iterator i = players.iterator();
    Player p;
    while (i.hasNext()) {
      p = (Player) i.next();
      p.resetLives(3);
      p.setActive(true);
    }

    BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
    Cursor blank =
        Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "BLANK");
    this.setCursor(blank);

    reset();

    ballN = 1;
    level = 1;
    timeLast = 0;
    score = 0;
    counterN = 10;
    timeCircle = 0;
    timeCircleSwitch = 0;
    programLoopCounter = 1;
    programSpeedAdjust = 1;

    onePlayerAlive = true;
    countdownF = true;
    circular = true;
    spawnIncrease = true;
    spawnCircleB = false;
    spawnMonsterB = false;
    spawnRandomersB = false;

    levelSetup();
    countdown();
    animate();
  }
Ejemplo n.º 21
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (scene == OVERWORLD) g.drawImage(background, 0, 0, this);
   if (scene == BATTLE) {
     if (battleBG == 1) g.drawImage(background, 0, -130, this);
     else g.drawImage(background, 0, 0, this);
   }
   int loop;
   for (loop = 0; loop < enemies.size(); loop++) {
     if (scene == OVERWORLD) {
       enemies.get(loop).drawEnemy(g);
     }
     if (scene == BATTLE) {
       if (enemies.get(loop).getActivity()) {
         enemies.get(loop).drawEnemy(g);
       }
     }
   }
   for (loop = 0; loop < spellsThrown.size(); loop++) {
     spellsThrown.get(loop).drawSpell(g);
   }
   player.drawPlayer(g);
   for (loop = 0; loop < enemies.size(); loop++) {
     enemies.get(loop).drawSpells(g);
   }
   if (scene == BATTLE) {
     drawMenu(g);
     if (battleWon) drawVictory(g);
     else if (battleLost) drawDefeat(g);
   }
 }
Ejemplo n.º 22
0
 // -------------------------------------------------------------------------------------------------------------------------------------------------------
 public String getPowerUp() {
   if (!player1.getPower().equals("")) {
     return ("P1");
   } else {
     return "none";
   }
 }
  public void captureImage() {
    String savepath =
        this.saveDirectory + "\\cam" + this.getDateFormatNow("yyyyMMdd_HHmmss-S") + ".jpg";
    System.out.println("Capturing current image to " + savepath);

    // Grab a frame
    FrameGrabbingControl fgc =
        (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
    buf = fgc.grabFrame();

    // Convert it to an image
    btoi = new BufferToImage((VideoFormat) buf.getFormat());
    img = btoi.createImage(buf);

    // save image
    saveJPG(img, savepath);

    // show the image
    // imgpanel.setImage(img);

    // images.add(img);
    images.add(savepath);

    if (images_lastadded.size() >= lastadded_max) {
      // Remove last
      images_lastadded.remove(images_lastadded.size() - 1);
    }

    images_lastadded.add(0, images.size() - 1);
    images_nevershown.add(0, images.size() - 1);

    forceNewImage();
  }
Ejemplo n.º 24
0
  public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
      p5.add(mortgage);
      Slot pobject;
      pobject = Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())];
      if (pobject instanceof Property) {
        ((Property) (pobject)).monopolizeProperty();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Rent Price:" + pobject.getRentPrice());
        pr3.setText("House Price:" + pobject.getHousePrice());
        pr4.setText("Hotel Price:" + pobject.getHotelPrice());
        pr5.setText("Mortgaged:" + pobject.getMortgage());
      } else if (pobject instanceof Railroad) {
        pobject.adjustRentPrice();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Rent Price:" + pobject.getRentPrice());
        pr3.setText("");
        pr4.setText("");
        pr5.setText("");

      } else {
        pobject.adjustDiceFactor();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Dice Factor:" + pobject.getDiceFactor());
        pr3.setText("");
        pr4.setText("");
        pr5.setText("");
      }
    }
  }
Ejemplo n.º 25
0
 static int isEnd(Player player) {
   int i;
   for (i = 1; i <= 5; i++) {
     if (player.haveHide("End" + i)) return i;
   }
   return 0;
 }
Ejemplo n.º 26
0
 private void judge() {
   if (player.numOfSpecialCards() > dealer.numOfSpecialCards()) {
     player.win();
     dealer.lose();
   } else if (player.numOfSpecialCards() < dealer.numOfSpecialCards()) {
     dealer.win();
     player.lose();
   } else {
     int playerScore = 0, dealerScore = 0;
     for (Card card : player.getCards()) {
       if (!card.isSpecial()) playerScore += card.getValue();
       playerScore %= 10;
     }
     for (Card card : dealer.getCards()) {
       if (!card.isSpecial()) dealerScore += card.getValue();
       dealerScore %= 10;
     }
     if (playerScore > dealerScore) {
       player.win();
       dealer.lose();
     } else {
       dealer.win();
       player.lose();
     }
   }
 }
Ejemplo n.º 27
0
 protected void show_scoreSheet(Player p, int gameNum) {
   int score = 0;
   for (int g = 0; g <= gameNum; g++) {
     for (int but = CellCodes.ONES; but <= CellCodes.GRANDTOTAL; but++) {
       score = p.getScoreCell(g, but);
       if (score < 0) tfs[but][g].setText("");
       else tfs[but][g].setText(String.valueOf(score));
     }
   }
 }
Ejemplo n.º 28
0
  public void keyPressed(KeyEvent key) {

    if (key.getKeyCode() == 37) {

      leftcheck = true;
      player.ta = -changet;
    }

    if (key.getKeyCode() == 39) {

      rightcheck = true;
      player.ta = changet;
    }

    if (key.getKeyCode() == 32) {

      grav = true;
    }
  }
Ejemplo n.º 29
0
  public void playLoop() {

    if (sequence != null) {
      double playStartTime = (player.getSeekTime() / 100) * (playGetLength());
      sequencer.setMicrosecondPosition((long) playStartTime);
      if (playState != PLAYING) {
        sequencer.start();
        playState = PLAYING;
      }
    }
  }
Ejemplo n.º 30
0
  public void battleEnd() {
    scene = OVERWORLD;
    ImageIcon bg = new ImageIcon("OverworldBG.jpg");
    background = bg.getImage();
    player.battleEnd();
    totalExperience = 0;
    nextWindow = false;
    battleWon = false;

    enemies.add(new Stalker(175, 200));
  }