Java 2D chunk engine to generate "infinite" worlds.
To create a chunk system, simply look at the following code:
ChunkTarget target = new Character(); // You have to write your own implementation
ContentProvider provider = new World(); // You have to write your own implementation
CachedChunkConfiguration configuration = new SimpleCachedChunkConfiguration();
configuration.setFocused(target);
configuration.setContentProvider(provider);
configuration.setCacheSize(4);
ChunkSystem chunkSystem = new ConcurrentChunkSystem(new SimpleCachedChunkSystem(configuration));
chunkSystem.start();
Now you can work with the chunk system in your game code:
Chunk chunk = chunkSystem.getActiveChunk();
// The system is focused and has an active chunk
if (chunk != null) {
int indexX = chunk.getIndexX();
int indexY = chunk.getIndexY();
System.out.println("The current index is: " + indexX + "|" + indexY);
}
Read the official wiki for more information.
You can download the newest bundle here.
chunx has been developed by Miguel Gonzalez.