コード例 #1
0
  public void windowOpened(WindowEvent e) {

    torneo.addPropertyChangeListener(this);

    for (Ronda ronda : torneo.getRondas()) ronda.addPropertyChangeListener(this);

    for (Tanque tanque : torneo.getTanques()) tanque.addPropertyChangeListener(this);

    crearPanelesTanque();

    repintar();

    animador = new PAnimador(vista.getPanelJuego());
    animador.setFps(24);
    animador.antialiasing(true);
    animador.setFondo(Color.GRAY);
    animador.agregarAnimable(torneo);
  }
コード例 #2
0
  private JPanel crearPanelJugador(Tanque tanque) {
    JPanel p = new JPanel();

    p.setLayout(null);
    p.setBorder(BorderFactory.createLineBorder(Color.gray));
    p.setPreferredSize(new Dimension(140, 71));
    JLabel lblImagenTanque = new JLabel(new ImageIcon(tanque.getMiniaturaTanque(50, 50)));
    lblImagenTanque.setBounds(0, 10, 50, 50);
    p.add(lblImagenTanque);
    cargarDatosTanque(p, tanque);
    return p;
  }
コード例 #3
0
ファイル: Disparo.java プロジェクト: rvcolmenares/miniguerras
 public void calcularDisparo(ITanque tanque) {
   if (objetivo == null
       || objetivo.getVida() <= 0
       || tanque.getPosicion().distance(objetivo.getPosicion()) > 100)
     objetivo = Tanque.tanqueMasCercano(tanque);
   if (objetivo != null && tanque.getEnergia() > 6) {
     tanque.setAnguloDisparo(
         -Math.atan2(
             objetivo.getPosicion().y - tanque.getPosicion().y,
             objetivo.getPosicion().x - tanque.getPosicion().x));
     tanque.setDisparara(true);
   } else tanque.setDisparara(false);
 }
コード例 #4
0
 private void cargarDatosTanque(JPanel panel, Tanque tanque) {
   JLabel lblNombreTanque = new JLabel(tanque.getNombre());
   lblNombreTanque.setBounds(53, 3, 90, 15);
   panel.add(lblNombreTanque);
   JLabel lblVida = new JLabel("Vida:");
   lblVida.setBounds(53, 21, 50, 15);
   panel.add(lblVida);
   JLabel lblEnergia = new JLabel("Energía:");
   lblEnergia.setBounds(53, 34, 50, 15);
   panel.add(lblEnergia);
   JLabel lblPuntos = new JLabel("Puntos:");
   lblPuntos.setBounds(53, 47, 50, 15);
   panel.add(lblPuntos);
   JLabel lblValorVida = new JLabel(new Integer(tanque.getVida()).toString());
   lblValorVida.setBounds(83, 21, 35, 15);
   panel.add(lblValorVida);
   JLabel lblValorEnergia = new JLabel(new Integer(tanque.getEnergia()).toString());
   lblValorEnergia.setBounds(101, 34, 35, 15);
   panel.add(lblValorEnergia);
   JLabel lblValorPuntos = new JLabel(new Integer(tanque.getPuntuacion()).toString());
   lblValorPuntos.setBounds(99, 47, 35, 15);
   panel.add(lblValorPuntos);
 }
コード例 #5
0
 public void mostrarBarras(boolean condicion) {
   for (Tanque tanque : torneo.getRondaActual().getTanques()) tanque.setEstadoBarras(condicion);
 }