Search in sources :

Example 1 with SpreadFOV

use of util.SpreadFOV in project ultimate-java by pantinor.

the class TestJaxb method testFOV.

// @Test
public void testFOV() throws Exception {
    int dim = 25;
    int startx = 13;
    int starty = 13;
    float[][] vt = new float[dim][dim];
    for (int x = 0; x < dim; x++) {
        for (int y = 0; y < dim; y++) {
        // vt[x][y] = new Tile();
        // vt[x][y].setOpaque(true);
        }
    }
    vt[1][1] = 1f;
    vt[1][6] = 1f;
    vt[6][6] = 1f;
    vt[6][1] = 1f;
    SpreadFOV fov = new SpreadFOV(dim, dim, true);
    float[][] los = fov.calculateFOV(vt, startx, starty, 10);
    for (int y = 0; y < dim; y++) {
        for (int x = 0; x < dim; x++) {
            if (startx == x && starty == y) {
                // System.out.print("_");
                System.out.print(los[x][y] + "|");
            } else {
                // System.out.print(los[x][y] <= 0?"X":" ");
                System.out.print(los[x][y] + "|");
            }
        }
        System.out.println("");
    }
}
Also used : SpreadFOV(util.SpreadFOV)

Example 2 with SpreadFOV

use of util.SpreadFOV in project ultimate-java by pantinor.

the class TestJaxb method testMapShadows.

// @Test
public void testMapShadows() throws Exception {
    File file2 = new File("assets/xml/tileset-base.xml");
    JAXBContext jaxbContext = JAXBContext.newInstance(TileSet.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
    TileSet ts = (TileSet) jaxbUnmarshaller.unmarshal(file2);
    ts.setMaps();
    File file3 = new File("assets/xml/maps.xml");
    jaxbContext = JAXBContext.newInstance(MapSet.class);
    jaxbUnmarshaller = jaxbContext.createUnmarshaller();
    MapSet ms = (MapSet) jaxbUnmarshaller.unmarshal(file3);
    ms.init(ts);
    BaseMap m = Maps.BRITAIN.getMap();
    int startx = 2;
    int starty = 4;
    long t = System.currentTimeMillis();
    SpreadFOV fov = new SpreadFOV(32, 32, true);
    float[][] lightMap = fov.calculateFOV(m.getShadownMap(), startx, starty, 20);
    for (int y = 0; y < 32; y++) {
        for (int x = 0; x < 32; x++) {
            if (startx == x && starty == y) {
                System.out.print("_");
            } else {
                // System.out.print(lightMap[x][y] <= 0?"X":" ");
                System.out.print(lightMap[x][y]);
            }
        }
        System.out.println("");
    }
    System.out.println("testLOS2 time: " + (System.currentTimeMillis() - t));
}
Also used : SpreadFOV(util.SpreadFOV) MapSet(objects.MapSet) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File) TileSet(objects.TileSet) BaseMap(objects.BaseMap)

Aggregations

SpreadFOV (util.SpreadFOV)2 File (java.io.File)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 BaseMap (objects.BaseMap)1 MapSet (objects.MapSet)1 TileSet (objects.TileSet)1