Example #1
0
  public void keyPressed(KeyEvent e) {

    switch (e.getKeyCode()) {
      case KeyEvent.VK_Z:
        skill_id = 0;
        break;
      case KeyEvent.VK_X:
        skill_id = 1;
        break;
      case KeyEvent.VK_C:
        skill_id = 2;
        break;
      case KeyEvent.VK_V:
        skill_id = 3;
        break;
      case KeyEvent.VK_SPACE:
        if (arena.game == Constant.GameStatus.PAUSE) {
          arena.game = prevGameStatus;
        } else {
          prevGameStatus = arena.game;
          arena.game = Constant.GameStatus.PAUSE;
        }
        break;
      case KeyEvent.VK_ESCAPE:
        arena.game = Constant.GameStatus.END;
        break;
      default:;
    }
  }
Example #2
0
 /* mouse events */
 public void mousePressed(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   /* left click */
   if (e.getButton() == MouseEvent.BUTTON1) {
     if (x >= posX && x < posX + Constant.BATTLEFIELD_WIDTH) {
       if (y >= posY) {
         if (y < posY + Constant.BATTLEFIELD_HEIGHT) {
           battle_field.doPress((x - posX), (y - posY));
           return;
         } else if (y < posY + Constant.BATTLEFIELD_HEIGHT + Constant.CARDPANEL_HEIGHT) {
           card_panel.doDrag(x - posX, y - (posY + Constant.BATTLEFIELD_HEIGHT));
           return;
         }
       }
     }
     /* right click */
   } else if (e.getButton() == MouseEvent.BUTTON3) {
     if (x >= posX && x < posX + Constant.BATTLEFIELD_WIDTH) {
       if (y >= posY) {
         if (y < posY + Constant.BATTLEFIELD_HEIGHT) {
           Skill skill = arena.player.useSkill(skill_id, x - posX, y - posY);
           if (skill != null) {
             arena.addSkill(skill);
           }
           return;
         } else if (y < posY + Constant.BATTLEFIELD_HEIGHT + Constant.CARDPANEL_HEIGHT) {
           card_panel.changeDetail(x - posX, y - (posY + Constant.BATTLEFIELD_HEIGHT));
           return;
         }
       }
     }
   }
 }