Пример #1
0
  public void step() {
    for (int i = 0; i < worldStepsPerLoop; i++) {
      world.step();
      //                if (stepsDone % 100 == 0) {
      //                    System.out.println("println = "+stepsDone);

      //                }
      if (capture) {
        if (stepsDone % 5 == 0) {
          String s = String.format("%06d", stepsDone);
          this.captureToSVG("step" + s + ".svg");
        }
      }
      stepsDone++;
    }

    for (Active active : getActives()) {
      active.setDamping(getFrictionOfSurface(active)); // speedup
      //            active.setDamping((float) frictionBuffer.getFriction((int) active.getX(), (int)
      // active.getY()));
    }
    for (Passive passive : getPassives()) {
      passive.setDamping(getFrictionOfSurface(passive)); // speedup
      //            passive.setDamping((float) frictionBuffer.getFriction((int) passive.getX(),
      // (int) passive.getY()));

    }
    moveVivaes();

    repaint();
  }
Пример #2
0
 /** Sets up new coordinates and rotation of all VivaeObjects according to their movement. */
 public void moveVivaes() {
   //        for (Active active : actives) {
   //            active.moveComponent();
   //        }
   for (Passive passive : passives) {
     passive.moveComponent();
   }
   for (VivaeController controller : controllers) {
     controller.moveControlledObject();
   }
 }
Пример #3
0
  /**
   * Initializates the World and adds all the actives and passives and physical boundaries inside.
   */
  public void initWorld() {
    encloseWithWalls(50);

    for (Passive passive : getPassives()) {
      world.add(passive.getBody());
    }

    for (Active active : actives) {
      world.add(active.getBody());
    }
    world.setGravity(0, 0);
    setAllArenaPartsAntialiased(isAllArenaPartsAntialiased);
  }
Пример #4
0
  /**
   * Paints up the arena and all the surfaces and objects inside without DoubleBuffering.
   *
   * @param svgGraphics
   */
  public void paintUnbuffered(Graphics svgGraphics) {

    svgGraphics.setColor(Color.WHITE);
    svgGraphics.fillRect(this.getX(), this.getY(), screenWidth, screenHeight);

    for (Surface vivaeObject : surfaces) {
      vivaeObject.paintComponent(svgGraphics);
    }
    for (Passive vivaeObject : getPassives()) {
      vivaeObject.paintComponent(svgGraphics, false);
    }
    for (Active active : actives) {
      active.paintComponent(svgGraphics, false);
    }
  }
Пример #5
0
  @Override
  /** Paints up the arena and all the surfaces and objects inside using DoubleBuffering. */
  public void paint(Graphics g) {
    if (offscreen == null) {
      return;
    }
    bufferGraphics.setColor(Color.WHITE);
    bufferGraphics.fillRect(this.getX(), this.getY(), screenWidth, screenHeight);

    for (Surface vivaeObject : surfaces) {
      vivaeObject.paintComponent(bufferGraphics);
    }
    for (Passive vivaeObject : getPassives()) {
      vivaeObject.paintComponent(bufferGraphics, isObjectsOnSightBlinking);
    }
    for (VivaeObject vivaeObject : getPaintable()) {
      vivaeObject.paintComponent(bufferGraphics, isObjectsOnSightBlinking);
    }
    for (Active active : actives) {
      active.paintComponent(bufferGraphics, isObjectsOnSightBlinking);
    }
    g.drawImage(offscreen, 0, 0, this);
  }
Пример #6
0
 /**
  * Sets up whether the Passive objects in the arena are antialiased.
  *
  * @param isAntialiased
  */
 public void setPassivesAntialiased(boolean isAntialiased) {
   for (Passive passive : passives) {
     passive.setAntialiased(isAntialiased);
   }
 }