Example #1
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);
  }
Example #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;
 }
Example #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) {

    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;
  }