Search in sources :

Example 11 with ImageBufferMock

use of com.b3dgs.lionengine.graphic.ImageBufferMock 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());
}
Also used : ImageBufferMock(com.b3dgs.lionengine.graphic.ImageBufferMock) ViewerMock(com.b3dgs.lionengine.ViewerMock) ColorRgba(com.b3dgs.lionengine.graphic.ColorRgba) HashMap(java.util.HashMap) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Aggregations

ImageBufferMock (com.b3dgs.lionengine.graphic.ImageBufferMock)11 Media (com.b3dgs.lionengine.Media)7 Test (org.junit.jupiter.api.Test)7 Test (org.junit.Test)4 ViewerMock (com.b3dgs.lionengine.ViewerMock)2 Medias (com.b3dgs.lionengine.Medias)1 UtilAssert.assertFalse (com.b3dgs.lionengine.UtilAssert.assertFalse)1 UtilAssert.assertTrue (com.b3dgs.lionengine.UtilAssert.assertTrue)1 Camera (com.b3dgs.lionengine.game.feature.Camera)1 Services (com.b3dgs.lionengine.game.feature.Services)1 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)1 MapTileRenderer (com.b3dgs.lionengine.game.feature.tile.map.MapTileRenderer)1 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1 GraphicMock (com.b3dgs.lionengine.graphic.GraphicMock)1 Drawable (com.b3dgs.lionengine.graphic.drawable.Drawable)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AfterAll (org.junit.jupiter.api.AfterAll)1