protected void init() { super.init(); // populate grid for (LinPos p : grid.getLinGrid()) { grid.set(p.i, new Square()); } { Block block = new Block().setPos(2.3f, 3); blocks.add(block); } { follower = new Follower(); follower.textureRegion = T.blockTextureRegion.get(4); follower.setPos(8f, 3); blocks.add(follower); } { Slider slider = new Slider(); slider.textureRegion = T.blockTextureRegion.get(3); slider.setPos(5, 6.4f); slider.target.set(5, 6); blocks.add(slider); } { Slider slider = new Slider(); slider.textureRegion = T.blockTextureRegion.get(3); slider.setPos(5, 6.4f); slider.target.set(2, 6); blocks.add(slider); } }
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(); }