Search in sources :

Example 1 with MapTileRenderer

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileRenderer in project lionengine by b3dgs.

the class MapTileViewerModelTest method testViewer.

/**
 * Test the viewer functions.
 */
@Test
void testViewer() {
    map.loadSheets(Arrays.asList(Drawable.loadSpriteTiled(new ImageBufferMock(80, 80), 40, 40)));
    mapViewer.render(g);
    map.create(40, 40, 2, 2);
    map.setTile(0, 0, 0);
    map.setTile(1, 1, 1);
    final AtomicBoolean rendered = new AtomicBoolean();
    final MapTileRenderer renderer = (g, tile, x, y) -> rendered.set(true);
    mapViewer.render(g);
    assertFalse(rendered.get());
    mapViewer.addRenderer(renderer);
    mapViewer.render(g);
    assertTrue(rendered.get());
    rendered.set(false);
    mapViewer.removeRenderer(renderer);
    mapViewer.render(g);
    assertFalse(rendered.get());
    mapViewer.addRenderer(renderer);
    mapViewer.render(g);
    assertTrue(rendered.get());
    rendered.set(false);
    mapViewer.clear();
    mapViewer.render(g);
    assertFalse(rendered.get());
    map.clear();
    mapViewer.render(g);
}
Also used : Medias(com.b3dgs.lionengine.Medias) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) UtilAssert.assertFalse(com.b3dgs.lionengine.UtilAssert.assertFalse) Graphic(com.b3dgs.lionengine.graphic.Graphic) MapTileRenderer(com.b3dgs.lionengine.game.feature.tile.map.MapTileRenderer) GraphicMock(com.b3dgs.lionengine.graphic.GraphicMock) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ViewerMock(com.b3dgs.lionengine.ViewerMock) AfterAll(org.junit.jupiter.api.AfterAll) Test(org.junit.jupiter.api.Test) Drawable(com.b3dgs.lionengine.graphic.drawable.Drawable) Services(com.b3dgs.lionengine.game.feature.Services) BeforeAll(org.junit.jupiter.api.BeforeAll) UtilAssert.assertTrue(com.b3dgs.lionengine.UtilAssert.assertTrue) ImageBufferMock(com.b3dgs.lionengine.graphic.ImageBufferMock) Camera(com.b3dgs.lionengine.game.feature.Camera) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ImageBufferMock(com.b3dgs.lionengine.graphic.ImageBufferMock) MapTileRenderer(com.b3dgs.lionengine.game.feature.tile.map.MapTileRenderer) Test(org.junit.jupiter.api.Test)

Aggregations

Medias (com.b3dgs.lionengine.Medias)1 UtilAssert.assertFalse (com.b3dgs.lionengine.UtilAssert.assertFalse)1 UtilAssert.assertTrue (com.b3dgs.lionengine.UtilAssert.assertTrue)1 ViewerMock (com.b3dgs.lionengine.ViewerMock)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 Graphic (com.b3dgs.lionengine.graphic.Graphic)1 GraphicMock (com.b3dgs.lionengine.graphic.GraphicMock)1 ImageBufferMock (com.b3dgs.lionengine.graphic.ImageBufferMock)1 Drawable (com.b3dgs.lionengine.graphic.drawable.Drawable)1 Arrays (java.util.Arrays)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AfterAll (org.junit.jupiter.api.AfterAll)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1