Ejemplo n.º 1
0
 private void addTraversePoints(Point p, Point n, LinkedList<Point> pointsList) {
   float d = Point.distancePoint2Point(p, n);
   int k = (int) (d / renderingSegmentSize);
   int m = 0;
   Point t;
   while (k > 0) {
     t = new Point();
     t.x = (m * n.x + k * p.x) / (m + k);
     t.y = (m * n.y + k * p.y) / (m + k);
     pointsList.add(t);
     k--;
     m++;
   }
   return;
 }
Ejemplo n.º 2
0
  @Override
  public void render() {
    this.update(Gdx.graphics.getDeltaTime());

    for (int i = 0; i < chains.size(); i++) {
      ct = chains.get(i);

      for (int j = 1; j <= ct.getChildCount(); j++) {
        ct.getVertex(j - 1, vertex);
        ct.getVertex(j, v);

        p.setLocation(
            PhysicsHelper.ConvertToWorld(vertex.x) * LevelInfo.ratioX,
            PhysicsHelper.ConvertToWorld(vertex.y) * LevelInfo.ratioX);
        q.setLocation(
            PhysicsHelper.ConvertToWorld(v.x) * LevelInfo.ratioX,
            PhysicsHelper.ConvertToWorld(v.y) * LevelInfo.ratioX);

        //	if(Math.abs(p.getX() - GlobalVars.ge.getScreen().cam.position.x) >
        // Gdx.graphics.getWidth())
        //		continue;
        //	if(Math.abs(p.getY() - GlobalVars.ge.getScreen().cam.position.y) >
        // Gdx.graphics.getHeight())
        //		continue;

        if (q.x < Helper.getCameraLeft() && p.x < Helper.getCameraLeft()) continue;
        else if (p.x > Helper.getCameraRight() && q.x > Helper.getCameraRight()) continue;

        //				GlobalVars.ge.getScreen().getBatch()
        //						.setColor(0.1f, 0.1f, 0.1f, 0.8f);

        //				 Helper.println("Angle: " + j + " -> " + Helper.getAngle(p,
        // q));

        distance = p.distancePoint2Point(q);

        //				Helper.println("\nP: " + p);
        //				Helper.println("Q: " + q);
        // drawing road texture
        for (int k = 0; k < distance; k += 15 * LevelInfo.ratioX) {
          p.getPointAtDistance(p, Helper.getAngle(p, q) + 90, k, r);
          //					Helper.println("R: " + r);

          //					float f = GlobalVars.ge.getScreen().cam.position.y-Gdx.graphics.getHeight()/2f;
          float f = texturePathCarpet.getRegionHeight();
          //					float f = r.y - Helper.getCameraBottom();
          //					GlobalVars.ge.getRenderer().render(texturePathTexture,
          //							r.x, r.y - f,
          //							15* LevelInfo.ratioX, f);
          GlobalVars.ge
              .getRenderer()
              .render(
                  texturePathTexture,
                  r.x,
                  r.y - f,
                  15 * LevelInfo.ratioX,
                  f,
                  0,
                  texturePathTexture.getRegionHeight() - f,
                  texturePathTexture.getRegionWidth(),
                  f);
        }

        GlobalVars.ge
            .getRenderer()
            .render(
                texturePathCarpet,
                p.x,
                p.y - this.height / 2f,
                distance,
                /* GameMenuInfo.ratio_h* */ this.height * 2f,
                0,
                this.height,
                Helper.getAngle(p, q) + 90,
                1,
                1);

        //				GlobalVars.ge.getScreen().getBatch().setColor(1f, 1f, 1f, 1f);

      }
    }
  }