Beispiel #1
0
 public void render(Mine mine) {
   Vector pos = mine.position().add(viewPoint);
   int radius = (int) mine.boundingRadius();
   int length = radius * 2;
   graphics.drawRect((int) pos.x() - radius, (int) pos.y() - radius, length, length);
   graphics.drawString(String.valueOf(mine.yield()), (int) pos.x() - 10, (int) pos.y());
 }
Beispiel #2
0
 public void render(BaseCamp baseCamp) {
   Vector pos = baseCamp.position().add(viewPoint);
   int radius = (int) baseCamp.boundingRadius();
   int length = radius * 2;
   graphics.drawRect((int) pos.x() - radius, (int) pos.y() - radius, length, length);
   graphics.drawString("Base", (int) pos.x() - 10, (int) pos.y());
 }
Beispiel #3
0
 private void renderEnergyBar(Entity entity, int x, int y) {
   int yPos = y + ((int) entity.boundingRadius() + 10);
   graphics.drawRect(x - 15, yPos, 30, 7);
   Color originalColor = graphics.getColor();
   graphics.setColor(Color.BLUE);
   double energyBarLength = 29.0 * entity.energy();
   graphics.fillRect(x - 14, yPos + 1, (int) energyBarLength, 6);
   graphics.setColor(originalColor);
 }
Beispiel #4
0
 private void renderHealthBar(Entity entity, int x, int y) {
   int yPos = y - ((int) entity.boundingRadius() + 10);
   graphics.drawRect(x - 15, yPos, 30, 7);
   Color originalColor = graphics.getColor();
   double health = entity.health();
   graphics.setColor(getColorFor(health));
   double healthBarLength = 29.0 * health;
   graphics.fillRect(x - 14, yPos + 1, (int) healthBarLength, 6);
   graphics.setColor(originalColor);
 }
Beispiel #5
0
  public void render(Miner miner) {
    Vector adjustedPosition = miner.position().add(viewPoint);
    int x = (int) adjustedPosition.x();
    int y = (int) adjustedPosition.y();

    AffineTransform orig = graphics.getTransform();
    AffineTransform rot =
        AffineTransform.getRotateInstance(miner.heading().x(), miner.heading().y(), x, y);
    graphics.transform(rot);
    graphics.drawRect(
        x - (int) miner.boundingRadius(),
        y - ((int) miner.boundingRadius() / 2),
        (int) miner.boundingRadius() * 2,
        (int) miner.boundingRadius());
    graphics.setTransform(orig);
    renderHealthBar(miner, x, y);
    renderEnergyBar(miner, x, y);
  }