use of com.b3dgs.lionengine.graphic.ColorRgba in project lionengine by b3dgs.
the class MinimapConfig method exports.
/**
* Export tiles colors data to configuration media.
*
* @param configMinimap The configuration media output (must not be <code>null</code>).
* @param tiles The tiles data (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Media configMinimap, Map<Integer, ColorRgba> tiles) {
Check.notNull(configMinimap);
Check.notNull(tiles);
final Map<ColorRgba, Collection<Integer>> colors = convertToColorKey(tiles);
final Xml nodeMinimap = new Xml(NODE_MINIMAP);
for (final Map.Entry<ColorRgba, Collection<Integer>> entry : colors.entrySet()) {
final ColorRgba color = entry.getKey();
final Xml nodeColor = nodeMinimap.createChild(NODE_COLOR);
nodeColor.writeInteger(ATT_COLOR_RED, color.getRed());
nodeColor.writeInteger(ATT_COLOR_GREEN, color.getGreen());
nodeColor.writeInteger(ATT_COLOR_BLUE, color.getBlue());
for (final Integer number : entry.getValue()) {
final Xml nodeTile = TileConfig.exports(number.intValue());
nodeColor.add(nodeTile);
}
}
nodeMinimap.save(configMinimap);
}
use of com.b3dgs.lionengine.graphic.ColorRgba in project lionengine by b3dgs.
the class PathfindableModel method render.
@Override
public void render(Graphic g) {
if (renderDebug && path != null) {
final ColorRgba oldColor = g.getColor();
g.setColor(ColorRgba.GREEN);
renderPath(g);
g.setColor(oldColor);
}
}
use of com.b3dgs.lionengine.graphic.ColorRgba in project lionengine by b3dgs.
the class MinimapTest method testMinimap.
/**
* Test the minimap.
*/
@Test
void testMinimap() {
final MapTileGame map = new MapTileGame();
map.loadSheets(Arrays.asList(Drawable.loadSpriteTiled(new ImageBufferMock(80, 80), 40, 40)));
map.create(40, 40, 3, 3);
map.setTile(0, 0, 0);
final Minimap minimap = new Minimap(map);
final Media config = Medias.create("minimap.xml");
final Map<Integer, ColorRgba> tiles = new HashMap<>();
tiles.put(Integer.valueOf(0), ColorRgba.RED);
tiles.put(Integer.valueOf(1), ColorRgba.BLUE);
tiles.put(Integer.valueOf(0), ColorRgba.GREEN);
minimap.automaticColor(config);
minimap.loadPixelConfig(config);
minimap.setOrigin(Origin.BOTTOM_LEFT);
assertEquals(0.0, minimap.getX());
assertEquals(0.0, minimap.getY());
assertNull(minimap.getSurface());
assertFalse(minimap.isLoaded());
minimap.load();
minimap.prepare();
minimap.setLocation(1.0, 2.0);
minimap.load();
assertTrue(minimap.isLoaded());
assertEquals(1.0, minimap.getX());
assertEquals(-1.0, minimap.getY());
assertEquals(3, minimap.getWidth());
assertEquals(3, minimap.getHeight());
minimap.setLocation(new ViewerMock(), Geom.createLocalizable(2.0, 3.0));
assertEquals(2.0, minimap.getX());
assertEquals(234.0, minimap.getY());
minimap.dispose();
assertTrue(config.getFile().delete());
}
Aggregations