コード例 #1
0
 // method overload the constructor so you can have ImageIcon buttons, Image buttons, or String
 // buttons (like JButton);
 public BillyButton(ImageIcon img, String filename) {
   // set up images with the black one for when its selected
   this.img = img;
   enabled = true;
   image = img.getImage();
   this.filename = filename;
   BWimg = new ImageIcon("Real Pok Pics\\" + filename + "Chosen.gif");
   BWimage = BWimg.getImage();
   mode = "ImageIcon";
   visible = true;
 }
コード例 #2
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));
  }
コード例 #3
0
  public HotSMain() {
    // General
    setPreferredSize(new Dimension(800, 600));
    canvas.add(this);
    setBackground(Color.GRAY);
    frame.setResizable(false);
    frame.setTitle("Heroes of the Forest");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Overworld
    menuScreen.setPreferredSize(new Dimension(800, 150));
    menuScreen.setBackground(Color.DARK_GRAY);
    menuScreen.setVisible(false);

    menuButtons.add(itemsButton);
    menuButtons.add(equipButton);
    menuButtons.add(skillsButton);
    menuButtons.add(statusButton);
    menuButtons.add(settingsButton);
    menuButtons.add(dataButton);

    for (JButton button : menuButtons) {
      menuScreen.add(button);
      button.addActionListener(this);
    }

    canvas.add(menuScreen, BorderLayout.SOUTH);
    ImageIcon bg = new ImageIcon("OverworldBG.jpg");
    background = bg.getImage();

    frame.pack();
    frame.setVisible(true);
    player = new Player();
    enemies.add(new Stalker(375, 200));
    player.defaultPlayer();
    frame.addKeyListener(this);
    frame.addMouseListener(this);
    frame.addMouseMotionListener(this);
    moveTimer.start();
  }
コード例 #4
0
  // Transitions from Overworld to Battle scene
  public void battleBegin() {
    scene = BATTLE;
    moveUp = false;
    moveDown = false;
    moveLeft = false;
    moveRight = false;

    // Background changer
    int bgSelector = (int) (10 * Math.random() + 1);
    if (bgSelector > 5) {
      ImageIcon bg = new ImageIcon("BattleBG1.jpg");
      background = bg.getImage();
      battleBG = 1;
      player.battleBegin(235, 380);
      int placed = 0;
      for (int enemyNum = 0; enemyNum < enemies.size(); enemyNum++) {
        Enemy enemy = enemies.get(enemyNum);
        if (enemy.getActivity()) {
          enemy.battleBegin(440 - 20 * placed, 125);
          placed++;
          totalExperience += enemy.getEXP();
        }
      }
    } else {
      ImageIcon bg = new ImageIcon("BattleBG2.png");
      background = bg.getImage();
      battleBG = 2;
      player.battleBegin(650, 365);
      int placed = 0;
      for (int loop = 0; loop < enemies.size(); loop++) {
        if (enemies.get(loop).getActivity()) {
          enemies.get(loop).battleBegin(340 - 20 * placed, 145);
          placed++;
          totalExperience += enemies.get(loop).getEXP();
        }
      }
    }
    menuScreen.setVisible(false);
    staminaTimer.start();
  }