Esempio n. 1
0
  /**
   * Create a new board
   *
   * @param c
   */
  public Board(Game c) {
    // add leap motion controller
    leapAdapter = new SensorAdapter(c);
    sensorListener = new SensorListener(leapAdapter);
    shootListener = new ShootListener(leapAdapter);
    leapController = new Controller();
    leapController.addListener(sensorListener);
    leapController.addListener(shootListener);

    addKeyListener(new KeyboardAdapter(c, this));

    this.menu = new Menu(this, c);
    setFocusable(true);
    setDoubleBuffered(true);
    this.c = c;
    c.setPlayer(ItemFactory.createPlayer());
    c.setBackground(ItemFactory.createBackground());
  }
Esempio n. 2
0
 private void paintLifes(Graphics2D g2d) {
   int lifes = c.getLifes();
   for (int i = 0; i < lifes; i++) {
     ImageIcon imageIcon =
         new ImageIcon(
             ItemFactory.class.getResource(Config.getImagePath() + Level.getLevel().getLife()));
     Life life =
         ItemFactory.createLife(
             Config.getBoardDimension().getLength() - (2 + i) * imageIcon.getIconWidth(),
             0,
             imageIcon);
     g2d.drawImage(life.getImage(), life.getPosition().getX(), life.getPosition().getY(), this);
   }
 }