Rexpaint file loading example

If you don’t have a project set up just yet you can download either the Java or the Kotin skeleton project to get started.

The code of this example can be found in the zircon.examples project here.

In order for this example to work please download the cp437_table.xp file from here and copy it to the src/main/resources/rex_files folder in your project.

Loading Rexpaint (.xp) files is very simple in Zircon. The following is a runnable code snippet which you can copy and paste into your project and run:

import org.hexworks.zircon.api.*;
import org.hexworks.zircon.api.application.Application;
import org.hexworks.zircon.api.grid.TileGrid;
import org.hexworks.zircon.api.resource.BuiltInCP437TilesetResource;
import org.hexworks.zircon.api.resource.REXPaintResource;
import org.hexworks.zircon.api.resource.TilesetResource;
import org.hexworks.zircon.api.screen.Screen;

import java.util.List;

public class RexLoaderExample {
    private static final int TERMINAL_WIDTH = 16;
    private static final int TERMINAL_HEIGHT = 16;
    private static final TilesetResource TILESET = BuiltInCP437TilesetResource.YOBBO_20X20;
    private static final Size SIZE = Sizes.create(TERMINAL_WIDTH, TERMINAL_HEIGHT);
    private static final InputStream RESOURCE = RexLoaderExample.class.getResourceAsStream("/rex_files/cp437_table.xp");

    public static void main(String[] args) {
        REXPaintResource rex = REXPaintResource.loadREXFile(RESOURCE);

        Application app = SwingApplications.startApplication(AppConfigs.newConfig()

        final TileGrid tileGrid = app.getTileGrid();


        final Screen screen = Screens.createScreenFor(tileGrid);
        List<Layer> layers = rex.toLayerList(TILESET);
        for (Layer layer : layers) {

After running this code you should see this on your screen:

Zircon Rexpaint Loading Example

Do you have questions? Ask us on our Discord Server.