Пример #1
0
 public void buttonPressed(Button b) {
   if (b == Button.START) enterPresenter(oldPresenter);
   else if (b == Button.DOWN) {
     if (pkmn) {
       if (pkmnCursorIndex != 5) {
         pkmnCursorIndex++;
       } else {
         topIndex++;
         if (topIndex == Species.all().size()) topIndex = 0;
       }
     } else {
       if (menuCursorIndex != 3) menuCursorIndex++;
     }
   } else if (b == Button.UP) {
     if (pkmn) {
       if (pkmnCursorIndex != 0) {
         pkmnCursorIndex--;
       } else {
         topIndex--;
         if (topIndex == -1) topIndex = Species.all().size() - 1;
       }
     } else {
       if (menuCursorIndex != 0) menuCursorIndex--;
     }
   } else if (b == Button.LEFT || b == Button.RIGHT) pkmn = !pkmn;
 }
Пример #2
0
  public void drawOn(Graphics2D g) {
    g.drawImage(ii.getImage(), 0, 0, null);
    // trying to find right placement for names
    int Y = 75;
    int inc = 40; // increment for y
    int X = 50;
    g.setColor(Color.BLACK);
    g.setFont(new Font("Courier New", Font.BOLD, 25));
    // drawString (str, x, y)

    ArrayList<Species> speciesList = new ArrayList<Species>();
    for (int x = 0; x < Species.all().size(); x++) {
      speciesList.add(Species.all().get(x));
    }
    for (int i = 0; i < 6; i++) {

      Species s = speciesList.get((i + topIndex) % (speciesList.size()));

      g.drawString(player().pokedex().hasSeen(s) ? s.name() : "----------", X, Y);
      if (player().pokedex().hasCaught(s)) g.drawImage(pokeball.getImage(), X - 20, Y - 15, null);
      Y += inc;
    }

    g.drawString("" + player().pokedex().allSeen().size(), 270, 75);
    g.drawString("" + player().pokedex().allCaught().size(), 270, 75 + 50);

    ImageIcon pkmnArrow, menuArrow;
    if (pkmn) {
      pkmnArrow = arrow;
      menuArrow = idleArrow;
    } else {
      pkmnArrow = idleArrow;
      menuArrow = arrow;
    }
    g.drawImage(pkmnArrow.getImage(), X - 40, 60 + pkmnCursorIndex * inc, null);
    g.drawImage(menuArrow.getImage(), 240, 158 + menuCursorIndex * 31, null);
  }