Beispiel #1
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);
    }
  }
Beispiel #2
0
 public Surface getSurfaceUnderVivaeObject(VivaeObject actor) {
   Vector<Surface> surfacesActorIsOn = new Vector<Surface>();
   Surface srfc = null;
   for (Surface surface : surfaces) {
     srfc = surface;
     Area actArea = actor.getArea();
     actArea.intersect(srfc.getArea());
     if (!actArea.isEmpty()) {
       surfacesActorIsOn.add(srfc);
     }
   }
   if (surfacesActorIsOn.isEmpty()) {
     return null;
   }
   srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1);
   return srfc;
 }
Beispiel #3
0
 /**
  * Returns a coefficient of the surface the VivaeObject is on or 0 if there is no surface.
  *
  * @param actor
  */
 public float getFrictionOfSurface(VivaeObject actor) {
   Vector<Surface> surfacesActorIsOn = new Vector<Surface>();
   Surface srfc;
   for (Surface surface : surfaces) {
     srfc = surface;
     Area actArea = actor.getArea();
     actArea.intersect(srfc.getArea());
     if (!actArea.isEmpty()) {
       surfacesActorIsOn.add(srfc);
     }
   }
   if (surfacesActorIsOn.isEmpty()) {
     return 0f;
   }
   srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1);
   return srfc.getFriction();
 }
Beispiel #4
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 (Active active : actives) {
      active.paintComponent(bufferGraphics, isObjectsOnSightBlinking);
    }
    // bufferGraphics.draw(new Rectangle(10,10,100,100));
    // frictionBuffer.paintSensorBuffer(bufferGraphics);
    g.drawImage(offscreen, 0, 0, this);
  }
Beispiel #5
0
  /**
   * Returns a coefficient of the surface the VivaeObject is on or 0 if there is no surface.
   *
   * @param actor
   */
  public float getFrictionOfSurface(VivaeObject actor) {

    ArrayList<Surface> surfacesActorIsOn = new ArrayList<Surface>();
    Surface srfc;
    Area actArea = actor.getArea();

    for (Surface surface : surfaces) {
      srfc = surface;
      Area actor2intersect = (Area) actArea.clone();
      actor2intersect.intersect(srfc.getArea());
      if (!actor2intersect.isEmpty()) {
        surfacesActorIsOn.add(srfc);
      }
    }
    if (surfacesActorIsOn.isEmpty()) {
      return 0f;
    }
    srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1);

    float res = srfc.getFriction();
    //        System.out.println("Surface = " + srfc.getClass().toString() + " has friction " +
    // res);
    return res;
  }
Beispiel #6
0
 /**
  * Sets up whether the Surfaces in the arena are antialiased.
  *
  * @param isAntialiased
  */
 public void setSurfacesAntialiased(boolean isAntialiased) {
   for (Surface surface : surfaces) {
     surface.setAntialiased(isAntialiased);
   }
 }