Beispiel #1
0
 public void pointerDown(float x1, float y1) {
   final int x = MathUtils.floor(x1);
   final int y = MathUtils.floor(y1);
   follower.target.set(x, y);
   final Square square = grid.get(x, y);
   if (square != null) {
     square.count++;
   }
 }
Beispiel #2
0
  protected void draw(Matrix4 combined) {
    batch.setProjectionMatrix(combined);

    batch.begin();

    for (LinPos p : grid.getLinGrid()) {
      final Square square = grid.get(p.i);

      final int neighHash =
          GridUtils.getNeighHash(
              p,
              new Predicate<Pos>() {
                @Override
                public boolean evaluate(Pos pos) {
                  final Square nsquare = grid.get(pos);
                  if (nsquare == null) {
                    return false;
                  }
                  //                    return (pos.x + pos.y) % 2 == 0;
                  return nsquare.count > 0;
                }
              });

      if (square.count > 0) {

        final Sprite sprite = T.blockSprites[neighHash];

        sprite.setPosition(p.x, p.y);

        sprite.draw(batch);
      } else {
        int image = neighHash / 4;

        //            batch.draw(blockTextureRegion.get(square.image), p.x, p.y, 0.5f, 0.5f, 1, 1,
        // 1, 1, MathUtils.random(8)* 45);
        //            batch.draw(blockTextureRegion.get(square.image), p.x, p.y, 0.5f, 0.5f, 1, 1,
        // 1, 1, 45);
        batch.draw(T.blockTextureRegion.get(image), p.x, p.y, 1, 1);
      }
    }

    for (Block block : blocks) {
      block.draw(batch);
    }
    batch.end();
  }