Skip to content

bitbrain/chunx

Repository files navigation

ChunkX logo

Java 2D chunk engine to generate "infinite" worlds.

How it works

chunx-video

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);
}

Getting started

Read the official wiki for more information.

Download

You can download the newest bundle here.

Credits

chunx has been developed by Miguel Gonzalez.