Esempio n. 1
0
 public void CenterUpdate() {
   if (Level.keysPressed[3] == 1)
     // && Level.leftPlatform != true) {
     x -= Player.getMoveX();
   // }
   if (Level.keysPressed[2] == 1)
     // && Level.rightPlatform != true) {
     x += Player.getMoveX();
   // }
   if (Level.onPlatform == false) {
     y += Level.gravityStrength + Level.yMove;
   }
   y -= Level.yAdjust;
   x -= Level.xAdjust;
   DrawQuadTex(tex, x, y, width, height);
 }
Esempio n. 2
0
  @Override
  public void draw(Graphics2D g2d, Surface s) {

    g2d.setPaint(getColor());
    g2d.fill(getSurface());

    if (getHover() && !selected) {
      Stroke outl = new BasicStroke(2f);
      g2d.setStroke(outl);
      if (getColor() != Color.red) g2d.setPaint(Color.red);
      else g2d.setPaint(Color.BLACK);
      g2d.drawPolygon(getSurface());
    } else if (selected) {
      float[] dash = {4f, 0f, 2f};
      BasicStroke outl =
          new BasicStroke(
              2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash, getFramesAlive() * .2f);
      g2d.setStroke(outl);

      if (ownedby.equals(Player.NONE)) {
        g2d.setPaint(Color.black);
      } else if (ownedby.equals(Player.COMPUTER)) {
        g2d.setPaint(Color.RED);
      } else if (ownedby.equals(Player.PLAYER)) {
        g2d.setPaint(Color.BLUE);
      }

      g2d.drawPolygon(getSurface());
    }

    g2d.setPaint(Color.BLUE.brighter());
    for (Territory t : neighbors) {
      double distance;
      if (CalculateDistance(this.capital.x, this.capital.y, t.GetCapital().x, t.GetCapital().y)
          < 800) g2d.drawLine(this.capital.x, this.capital.y, t.GetCapital().x, t.GetCapital().y);
      else {
        if (CalculateDistance(this.capital.x, this.capital.y, 0, 0) < 500) {
          g2d.drawLine(this.capital.x, this.capital.y, 0, 70);
        } else if (CalculateDistance(this.capital.x, this.capital.y, 0, 0) > 500) {
          g2d.drawLine(this.capital.x, this.capital.y, 1280, 70);
        }
      }
    }

    if (ownedby.equals(Player.NONE)) {
      g2d.setPaint(Color.black);
    } else if (ownedby.equals(Player.COMPUTER)) {
      g2d.setPaint(Color.RED);
    } else if (ownedby.equals(Player.PLAYER)) {
      g2d.setPaint(Color.BLUE);
    }

    g2d.setFont(new Font("TimesRoman", Font.PLAIN, 18));
    g2d.setStroke(new BasicStroke(1f));
    g2d.fillOval(capital.x - 10, capital.y - 10, 20, 20);
    g2d.setPaint(Color.BLACK);
    g2d.drawOval(capital.x - 10, capital.y - 10, 20, 20);
    g2d.setPaint(Color.WHITE);
    g2d.drawString("" + armies, capital.x - 5, capital.y + 5);
  }