Beispiel #1
0
  public void drawBoxBody(Graphics g, Body body, Box box) {
    Vector2f[] pts = box.getPoints(body.getPosition(), body.getRotation());

    Vector2f v1 = pts[0];
    Vector2f v2 = pts[1];
    Vector2f v3 = pts[2];
    Vector2f v4 = pts[3];

    g.translate(camX, camY);
    g.setColor(new Color(255, 255, 255));
    g.drawLine((int) v1.x, (int) v1.y, (int) v2.x, (int) v2.y);
    g.drawLine((int) v2.x, (int) v2.y, (int) v3.x, (int) v3.y);
    g.drawLine((int) v3.x, (int) v3.y, (int) v4.x, (int) v4.y);
    g.drawLine((int) v4.x, (int) v4.y, (int) v1.x, (int) v1.y);
    g.translate(-camX, -camY);
  }
Beispiel #2
0
  public void pinta(Graphics g) {
    float ancho_anterior = g.getLineWidth();
    Color color_anterior = g.getColor();
    // /////////////////////////////////
    g.setLineWidth(3);
    this.actualizaAngulo();
    g.setColor(new Color(1, 0, 0, 0.2f));
    g.fillArc(
        this.centroX - radio, this.centroY - radio, radio * 2, radio * 2, 270, this.angulo - 90);

    g.setAntiAlias(true);

    g.setColor(this.color_reloj);
    g.drawOval(this.centroX - radio, this.centroY - radio, radio * 2, radio * 2);
    float px = 0, py = 0;

    px = (float) (this.centroX + radio * 8 / 10 * Math.cos(Math.toRadians(angulo) - Math.PI / 2));
    py = (float) (this.centroY + radio * 8 / 10 * Math.sin(Math.toRadians(angulo) - Math.PI / 2));
    g.setColor(color_manilla);
    g.drawLine(centroX, centroY, px, py);
    g.setAntiAlias(false);

    // /////////////////////////////////
    g.setLineWidth(ancho_anterior);
    g.setColor(color_anterior);
  }
Beispiel #3
0
 public void render(Graphics g, int[] interpolated, int xStep, int idx, int middle) {
   for (int resIdx = 0; resIdx < xStep - 1; resIdx++) {
     g.drawLine(
         (xStep * idx) + resIdx,
         middle + interpolated[resIdx],
         (xStep * idx) + resIdx + 1,
         middle + interpolated[resIdx + 1]);
   }
 }
Beispiel #4
0
  @Override
  public void renderWindowCloseButton(Graphics gfx, Button w) {
    int x = w.getAbsoluteX();
    int y = w.getAbsoluteY();

    gfx.setColor(borderColor);
    gfx.setLineWidth(2);
    gfx.drawRect(x, y, w.getWidth(), w.getHeight());

    if (w.isMouseOver()) gfx.setColor(Color.white);
    else gfx.setColor(Color.black);

    gfx.drawLine(x, y, x + w.getWidth(), y + w.getHeight());
    gfx.drawLine(x, y + w.getHeight(), x + w.getWidth(), y);
  }
  /**
   * Renders the player to the screen
   *
   * @param x the x position to render the player to
   * @param y the y position to render the player to
   * @param g the graphics context
   * @param viewerRole the role of the one viewing this player
   */
  public void draw(float x, float y, Graphics g, Role viewerRole) {

    if (Role.isRestriced(viewerRole) && "Fuzzi_Traitor.png".equals(texture)) {
      image = RessourceManager.loadImage("Fuzzi_Innocent.png");
    } else image = RessourceManager.loadImage(texture);

    image.rotate(lookAngle - image.getRotation() + 90);
    image.draw(x, y);

    if (this.getInventory()[this.getCurrentWeapon()] != null)
      this.getInventory()[this.getCurrentWeapon()].draw(x, y);

    g.setColor(Color.black);
    g.drawRect(x, y - 12, 32, 8);
    g.setColor(Color.red);
    g.fillRect(x + 1, y - 11, lifepoints * 0.31f, 7);

    Vector2f v = new Vector2f(x + 16, y + 16);
    Vector2f v1 = new Vector2f(getLookAngle()).scale(130f);
    Vector2f v2 = v.copy().add(v1);

    g.drawLine(v.x, v.y, v2.x, v2.y);
  }
Beispiel #6
0
 public void drawPoint(float x, float y) {
   g.drawLine(x, y, x, y);
 }
Beispiel #7
0
  /** Renderiza el juego, uso interno */
  @Override
  public void render(GameContainer gc, Graphics g) throws SlickException {
    double escalaTemporal = 0;
    if (autoescala) {
      escalaTemporal = escala;
      if (!noAutoEscalar) {
        escala = Math.min(escala, escalaAjustada);
        if (partido.getIteracion() < 50) {
          escalaGradual = escalaGradual + (escala - escalaGradual) * 0.01;
        } else {
          escalaGradual = escalaGradual + (escala - escalaGradual) * 0.2;
        }
      }

      escala = escalaGradual;
    }
    Position p = new Position(px, py);
    if (entorno) {
      pc.pintaEntorno(g, p, escala);
    }
    pc.pintaCancha(g, p, escala);
    Position[][] pos = partido.getPosiciones();
    if (!partido.esGol() && partido.estanSacando()) {
      double zoom = 1 * escala * (1 + 0.02 * (double) iterSaca);
      rel =
          Transforma.transform(
              pos[2][0],
              Constants.centroCampoJuego,
              -Transforma.transform(px, escala) + sx2,
              -Transforma.transform(py, escala) + sy2,
              escala);
      g.drawImage(
          xImage.getScaledCopy((int) zoom, (int) zoom),
          rel[0] - (int) (zoom / 2),
          rel[1] - (int) (zoom / 2));
    }
    Position ball = partido.getPosVisibleBalon();
    for (int i = 0; i < 11; i++) {
      rel =
          Transforma.transform(
              pos[0][i],
              Constants.centroCampoJuego,
              -Transforma.transform(px, escala) + sx2,
              -Transforma.transform(py, escala) + sy2,
              escala);
      pjLocal.pintaSombra(i, iteraciones[i][0], angVisible[i][0], escala, rel[0], rel[1], g);
      rel =
          Transforma.transform(
              pos[1][i],
              Constants.centroCampoJuego,
              -Transforma.transform(px, escala) + sx2,
              -Transforma.transform(py, escala) + sy2,
              escala);
      pjVisita.pintaSombra(i, iteraciones[i][1], angVisible[i][1], escala, rel[0], rel[1], g);
    }
    z = partido.getAlturaBalon(); // 16*Math.sin(Math.abs(ang % Math.PI));

    if (partido.estaRebotando() || z == 0) {
      ang = -balon0.angle(ball);
      velgiro = balon0.distance(ball) * 1.5;
    }
    if (partido.estanRematando()) {
      ang = rand.nextDouble() * Math.PI * 2;
      velgiro = rand.nextDouble();
    }

    balon0 = ball;
    giro = giro + velgiro * 1.5;
    if (giro < 0) {
      giro = 6 + giro;
    }
    rel =
        Transforma.transform(
            ball,
            Constants.centroCampoJuego,
            -Transforma.transform(px, escala) + sx2,
            -Transforma.transform(py, escala) + sy2,
            escala);
    pb.pintaSombra(escala, rel[0], rel[1], z, g);
    if (partido.getAlturaBalon() <= 2) {
      pb.pintaBalon((int) (giro), ang, escala, rel[0], rel[1], z * 2, g);
    }
    pp.pintaPublicidad(g, p, escala);

    if (jugador3d) {
      lista.clear();
      for (int i = 0; i < 11; i++) {
        rel =
            Transforma.transform(
                pos[0][i],
                Constants.centroCampoJuego,
                -Transforma.transform(px, escala) + sx2,
                -Transforma.transform(py, escala) + sy2,
                escala);
        lista.add(
            new Object[] {pjLocal, i, iteraciones[i][0], angVisible[i][0], escala, rel[0], rel[1]});
        rel =
            Transforma.transform(
                pos[1][i],
                Constants.centroCampoJuego,
                -Transforma.transform(px, escala) + sx2,
                -Transforma.transform(py, escala) + sy2,
                escala);
        lista.add(
            new Object[] {
              pjVisita, i, iteraciones[i][1], angVisible[i][1], escala, rel[0], rel[1]
            });
      }
      Object[] tmp1, tmp2;
      for (int i = 0; i < lista.size() - 1; i++) {
        for (int j = i + 1; j < lista.size(); j++) {
          tmp1 = lista.get(i);
          tmp2 = lista.get(j);
          if ((Integer) tmp1[6] > (Integer) tmp2[6]) {
            lista.set(i, tmp2);
            lista.set(j, tmp1);
          }
        }
      }

      for (Object obj[] : lista) {
        PintaJugador pj = (PintaJugador) obj[0];
        pj.pintaJugador(
            (Integer) obj[1],
            (Integer) obj[2],
            (Double) obj[3],
            (Double) obj[4],
            (Integer) obj[5],
            (Integer) obj[6],
            g);
      }

      for (int i = 0; i < 11; i++) {
        rel =
            Transforma.transform(
                pos[0][i],
                Constants.centroCampoJuego,
                -Transforma.transform(px, escala) + sx2,
                -Transforma.transform(py, escala) + sy2,
                escala);
        if (tipoTexto == 3 || (pos[0][i].distance(pos[2][0]) < 8 && tipoTexto == 1)) {
          pjLocal.pintaNumero(i, rel[0], rel[1], g);
        }
        if (tipoTexto == 4 || (pos[0][i].distance(pos[2][0]) < 8 && tipoTexto == 2)) {
          pjLocal.pintaNombre(i, rel[0], rel[1], g);
        }
        rel =
            Transforma.transform(
                pos[1][i],
                Constants.centroCampoJuego,
                -Transforma.transform(px, escala) + sx2,
                -Transforma.transform(py, escala) + sy2,
                escala);
        if (tipoTexto == 3 || (pos[1][i].distance(pos[2][0]) < 8 && tipoTexto == 1)) {
          pjVisita.pintaNumero(i, rel[0], rel[1], g);
        }
        if (tipoTexto == 4 || (pos[1][i].distance(pos[2][0]) < 8 && tipoTexto == 2)) {
          pjVisita.pintaNombre(i, rel[0], rel[1], g);
        }
      }
    } else {
      for (int i = 0; i < 11; i++) {
        rel =
            Transforma.transform(
                pos[0][i],
                Constants.centroCampoJuego,
                -Transforma.transform(px, escala) + sx2,
                -Transforma.transform(py, escala) + sy2,
                escala);
        pjLocal.pintaJugador(i, iteraciones[i][0], angVisible[i][0], escala, rel[0], rel[1], g);
        if (tipoTexto == 3 || (pos[0][i].distance(pos[2][0]) < 8 && tipoTexto == 1)) {
          pjLocal.pintaNumero(i, rel[0], rel[1], g);
        }
        if (tipoTexto == 4 || (pos[0][i].distance(pos[2][0]) < 8 && tipoTexto == 2)) {
          pjLocal.pintaNombre(i, rel[0], rel[1], g);
        }
        rel =
            Transforma.transform(
                pos[1][i],
                Constants.centroCampoJuego,
                -Transforma.transform(px, escala) + sx2,
                -Transforma.transform(py, escala) + sy2,
                escala);
        pjVisita.pintaJugador(i, iteraciones[i][1], angVisible[i][1], escala, rel[0], rel[1], g);
        if (tipoTexto == 3 || (pos[1][i].distance(pos[2][0]) < 8 && tipoTexto == 1)) {
          pjVisita.pintaNumero(i, rel[0], rel[1], g);
        }
        if (tipoTexto == 4 || (pos[1][i].distance(pos[2][0]) < 8 && tipoTexto == 2)) {
          pjVisita.pintaNombre(i, rel[0], rel[1], g);
        }
      }
    }

    rel =
        Transforma.transform(
            ball,
            Constants.centroCampoJuego,
            -Transforma.transform(px, escala) + sx2,
            -Transforma.transform(py, escala) + sy2,
            escala);
    if (partido.getAlturaBalon() > 2) {
      pb.pintaBalon((int) (giro), ang, escala, rel[0], rel[1], z * 2, g);
    }
    pc.pintaArcos(g, p, escala);
    if (estadio) {
      pc.pintaEstadio(g, p, escala);
    }
    if (marcador) {
      pm.pintaMarcador(
          partido.getGolesLocal(),
          partido.getGolesVisita(),
          partido.getIteracion(),
          partido.getPosesionBalonLocal(),
          g);
    }
    if (golIter > 0) {
      double zoom = 1 + 0.05 * (golIter % 3);
      g.drawImage(
          golImage.getScaledCopy((int) (361d * zoom), (int) (81d * zoom)),
          sx2 - (int) (180d * zoom),
          sy2 - (int) (40d * zoom));
    }

    if (offSideIter > 0) {
      g.drawImage(offSideImage, sx2 - 70, sy2 - 20);
      // g.drawImage(offSideImage, offSideIter - 300, sy2 - 20);
    }

    if (saqueIter > 0) {
      g.drawImage(cambioImage, saqueIter - 300, sy2 - 20);
    }
    if (autoescala) {
      escala = escalaTemporal;
    }
    if (guardado && iteracionControl > 0) {
      Image img = paImage;
      if (incremento > 0) {
        img = avImage;
      }
      if (incremento < 0) {
        img = reImage;
      }
      g.drawImage(img, sx2 - 10, sy2 - 10);
      g.setColor(Color.white);
      g.drawString("" + incremento + "x", sx2 + 20, sy2 - 10);
    }
    if (guardado && progreso) {
      g.setColor(Color.black);
      g.drawRect(sx - 20, 20, 10, sy - 40);
      g.setColor(Color.darkGray);
      g.fillRect(sx - 19, 21, 8, sy - 42);
      int valor =
          (int) (((double) sy - 41.0) * ((double) pg.getTiempo() / (double) pg.getIterciones()));
      int valorInicio =
          (int) (((double) sy - 42.0) * ((double) inicio / (double) pg.getIterciones()));
      int valorFin = (int) (((double) sy - 42.0) * ((double) fin / (double) pg.getIterciones()));
      g.setColor(Color.red);
      g.fillRect(sx - 19, sy - 21 - valor, 8, valor);
      g.setColor(Color.white);
      g.drawLine(sx - 19, sy - 22 - valorFin, sx - 12, sy - 22 - valorFin);
      g.drawLine(sx - 19, sy - 21 - valorFin, sx - 18, sy - 21 - valorFin);
      g.drawLine(sx - 13, sy - 21 - valorFin, sx - 12, sy - 21 - valorFin);
      g.drawLine(sx - 19, sy - 22 - valorInicio, sx - 12, sy - 22 - valorInicio);
      g.drawLine(sx - 19, sy - 23 - valorInicio, sx - 18, sy - 23 - valorInicio);
      g.drawLine(sx - 13, sy - 23 - valorInicio, sx - 12, sy - 23 - valorInicio);
    }
    if (showTexto) {
      if (partido.getIteracion() < 50) {
        g.setColor(Color.black);
        g.drawString(partido.getDetalleVisita().getTacticName() + " (Visita)", sx2 + 11, sy2 + 11);
        g.drawString("vs", sx2 + 41, sy2 + 41);
        g.drawString(partido.getDetalleLocal().getTacticName() + " (Local)", sx2 + 71, sy2 + 71);
        g.setColor(Color.white);
        g.drawString(partido.getDetalleVisita().getTacticName() + " (Visita)", sx2 + 10, sy2 + 10);
        g.drawString("vs", sx2 + 40, sy2 + 40);
        g.drawString(partido.getDetalleLocal().getTacticName() + " (Local)", sx2 + 70, sy2 + 70);
      }
    }
    if (showTexto) {
      if (partido.getIteracion() > Constants.ITERACIONES) {
        g.setColor(Color.black);
        g.drawString("Gana", sx2 + 11, sy2 + 11);
        if ((partido.getGolesLocal() > partido.getGolesVisita())
            || (partido.getGolesLocal() == partido.getGolesVisita()
                && partido.getPosesionBalonLocal() >= .5d)) {
          g.drawString(partido.getDetalleLocal().getTacticName(), sx2 + 41, sy2 + 41);
        } else {
          g.drawString(partido.getDetalleVisita().getTacticName(), sx2 + 41, sy2 + 41);
        }
        g.setColor(Color.white);
        g.drawString("Gana", sx2 + 10, sy2 + 10);
        if ((partido.getGolesLocal() > partido.getGolesVisita())
            || (partido.getGolesLocal() == partido.getGolesVisita()
                && partido.getPosesionBalonLocal() >= .5d)) {
          g.drawString(partido.getDetalleLocal().getTacticName(), sx2 + 40, sy2 + 40);
        } else {
          g.drawString(partido.getDetalleVisita().getTacticName(), sx2 + 40, sy2 + 40);
        }
      }
    }
    /*if (isRain) {
        g.setColor(lluvia);
        for (int i = 0; i < 200; i++) {
            double an = rand.nextDouble() * Math.PI * 2d;
            double rad = rand.nextDouble() * 1024;
            int x0 = (int) (sx2 + Math.sin(an) * rad);
            int y0 = (int) (sy2 + Math.cos(an) * rad);
            int x1 = (int) (sx2 + Math.sin(an) * rad * 1.1d);
            int y1 = (int) (sy2 + Math.cos(an) * rad * 1.1d);
            g.drawLine(x0, y0, x1, y1);
        }
        if (rand.nextDouble() < 0.05) {
            g.setColor(relampago);
            g.fillRect(0, 0, sx, sy);
        }
        isRain = rand.nextDouble() < 0.995;
    } else {
        isRain = rand.nextDouble() < 0.005;
    }*/
  }
Beispiel #8
0
 /**
  * Draw the line to the provided graphics context
  *
  * @param g The graphics context on which to draw the line
  */
 public void draw(Graphics g) {
   g.drawLine(oldx, oldy, newx, newy);
 }
Beispiel #9
0
  @Override
  public void render(GameContainer container, StateBasedGame game, Graphics g)
      throws SlickException {
    // TODO Graphics?
    g.drawString("Distance: " + distance, 10, 25);
    g.drawString("Speed: " + ((double) ((int) (speed * 10000.0))) / 10000.0, 10, 40);

    // all the graphics below will be affected by the translation
    g.translate(spX, 0);

    // The smoke
    ((ConfigurableEmitter) trail.getEmitter(0))
        .setPosition(dudeWidth - dudeSize.width / 2 - spX, dudeHeight);
    trail.render();
    // the death explosion
    ((ConfigurableEmitter) explosion.getEmitter(0))
        .setPosition(dudeWidth - dudeSize.width / 2 - spX, dudeHeight);
    ((ConfigurableEmitter) explosion.getEmitter(1))
        .setPosition(dudeWidth - dudeSize.width / 2 - spX, dudeHeight);
    explosion.render();

    // the walls
    // upper wall
    for (int i = 0; i < upperWall.size() - 1; i++) {
      for (int j = 0; j < 5; j++) {
        g.drawLine(
            i * WALL_RES + wallOffset - spX,
            upperWall.get(i) - j,
            (i + 1) * WALL_RES + wallOffset - spX,
            upperWall.get(i + 1) - j);
      }
    }
    // lower wall
    for (int i = 0; i < lowerWall.size() - 1; i++) {
      for (int j = 0; j < 5; j++) {
        g.drawLine(
            i * WALL_RES + wallOffset - spX,
            lowerWall.get(i) + j,
            (i + 1) * WALL_RES + wallOffset - spX,
            lowerWall.get(i + 1) + j);
      }
    }
    // The object
    g.fillRect(
        dudeWidth - dudeSize.width / 2 - spX,
        (int) dudeHeight - dudeSize.height / 2,
        dudeSize.width,
        dudeSize.height);

    // if(dead) g.drawString("Le jeu est terminé, appuyez sur Entrée pour continuer", 250, 150);

    // Sounds
    AlUtils.setAlListenerPosition((float) (WALL_RES + dudeSize.width / 2), dudeHeight, 0f);

    if (movingUp) AlUtils.setAlListenerVelocity((float) (WALL_RES + dudeSize.width / 2), -20, 0f);
    else AlUtils.setAlListenerVelocity((float) (WALL_RES + dudeSize.width / 2), 20, 0f);
    enterSound.setSourcePosition((float) (WALL_RES + dudeSize.width / 2), dudeHeight, 0f, 0);
    sonG.setSourcePosition((float) (WALL_RES + dudeSize.width / 2), actualUpperWall, 0f, 0);
    sonD.setSourcePosition((float) (WALL_RES + dudeSize.width / 2), actualLowerWall, 0f, 1);
    sonG.setSourceVelocity(
        (float) (WALL_RES + dudeSize.width / 2),
        upperWall.get(currentWallNo - 1) - upperWall.get(currentWallNo),
        0f,
        0);
    sonD.setSourceVelocity(
        (float) (WALL_RES + dudeSize.width / 2),
        lowerWall.get(currentWallNo) - lowerWall.get(currentWallNo - 1),
        0f,
        1);

    distSonBas = (float) (1.0 / ((actualLowerWall - dudeHeight) / 50.0));
    distSonHaut = (float) (1.0 / ((dudeHeight - actualUpperWall) / 50.0));
    sonG.setPitch(distSonHaut);
    sonD.setPitch(distSonBas, 1);
  }