示例#1
0
文件: Arena.java 项目: pokus001/vivae
  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
文件: Arena.java 项目: pokus001/vivae
 /** 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
文件: Arena.java 项目: pokus001/vivae
  /**
   * 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
文件: Arena.java 项目: pokus001/vivae
  /**
   * 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
文件: Arena.java 项目: pokus001/vivae
  @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
文件: Arena.java 项目: pokus001/vivae
 /**
  * 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);
   }
 }