コード例 #1
0
  void fetchCollidableRects2(int X, int Y) {
    int cWidth = Terrain.CurrentTerrain.chunkWidth;
    int cHeight = Terrain.CurrentTerrain.chunkHeight;

    int X2 = (int) (X % cWidth);
    int Y2 = (int) (Y % cHeight);

    if (LastX != (X / cWidth) || LastY != (Y / cHeight))
      tiles = Terrain.CurrentTerrain.GetCollisionData(X / cWidth, Y / cHeight);

    // Gdx.app.debug(""+LastX + " " +LastY, ""+(bobX/cWidth)+" "+(bobY/cHeight));
    // long nano = TimeUtils.nanoTime();

    if (X2 + (Y2 * cWidth) < cWidth * cHeight) {
      if (tiles[X2 + (Y2 * cWidth)] > 0) r[0].set(X, Y, 1, 1);
      else r[0].set(-1, -1, 1, 1);
    } else {
      if (Terrain.CurrentTerrain.GetTile(X, Y) > 0) {}
    }
    if ((X2 + 1) < cWidth && (Y2) < cHeight && X2 > 0 && Y2 > 0)
      if (tiles[(X2 + 1) + (Y2 * cWidth)] > 0) r[1].set(X + 1, Y, 1, 1);
      else r[1].set(-1, -1, 1, 1);
    else if (Terrain.CurrentTerrain.GetTile(X + 1, Y) > 0) r[1].set(X + 1, Y, 1, 1);

    if ((X2 + 1) < cWidth && (Y2 + 1) < cHeight && X2 > 0 && Y2 > 0)
      if (tiles[(X2 + 1) + ((Y2 + 1) * cWidth)] > 0) r[2].set(X + 1, Y + 1, 1, 1);
      else r[2].set(-1, -1, 1, 1);
    else if (Terrain.CurrentTerrain.GetTile(X + 1, Y + 1) > 0) r[2].set(X + 1, Y + 1, 1, 1);

    if ((X2) < cWidth && (Y2 + 1) < cHeight && X2 > 0 && Y2 > 0)
      if (tiles[X2 + ((Y2 + 1) * cWidth)] > 0) r[3].set(X, Y + 1, 1, 1);
      else r[3].set(-1, -1, 1, 1);
    else if (Terrain.CurrentTerrain.GetTile(X, Y + 1) > 0) r[3].set(X, Y + 1, 1, 1);
    // Gdx.app.debug("TOOKNANO", ""+X+ " " +Y);
    boolean changed;

    LastX = X / cWidth;
    LastY = Y / cHeight;
  }