Search in sources :

Example 21 with ViewerMock

use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.

the class SelectorRefresherTest method prepare.

/**
 * Prepare test.
 */
@BeforeEach
public void prepare() {
    services.add(new ContextMock());
    services.add(new Camera());
    services.add(new ViewerMock());
    cursor = services.create(Cursor.class);
    cursor.setSync(mouse);
    final Featurable featurable = new FeaturableModel(services, setup);
    featurable.addFeature(new LayerableModel(services, setup));
    featurable.addFeature(new TransformableModel(services, setup));
    featurable.addFeature(new CollidableModel(services, setup));
    refresher = new SelectorRefresher(services, model);
    refresher.addListener(listener);
    refresher.prepare(featurable);
}
Also used : CollidableModel(com.b3dgs.lionengine.game.feature.collidable.CollidableModel) ViewerMock(com.b3dgs.lionengine.ViewerMock) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Camera(com.b3dgs.lionengine.game.feature.Camera) ContextMock(com.b3dgs.lionengine.ContextMock) Cursor(com.b3dgs.lionengine.game.Cursor) Featurable(com.b3dgs.lionengine.game.feature.Featurable) SelectorRefresher(com.b3dgs.lionengine.game.feature.collidable.selector.SelectorRefresher) LayerableModel(com.b3dgs.lionengine.game.feature.LayerableModel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 22 with ViewerMock

use of com.b3dgs.lionengine.ViewerMock 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

ViewerMock (com.b3dgs.lionengine.ViewerMock)22 Test (org.junit.jupiter.api.Test)13 Test (org.junit.Test)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Media (com.b3dgs.lionengine.Media)3 Camera (com.b3dgs.lionengine.game.feature.Camera)3 ContextMock (com.b3dgs.lionengine.ContextMock)2 Xml (com.b3dgs.lionengine.Xml)2 Configurer (com.b3dgs.lionengine.game.Configurer)2 Cursor (com.b3dgs.lionengine.game.Cursor)2 Featurable (com.b3dgs.lionengine.game.feature.Featurable)2 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)2 Services (com.b3dgs.lionengine.game.feature.Services)2 Setup (com.b3dgs.lionengine.game.feature.Setup)2 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)2 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)2 Animation (com.b3dgs.lionengine.Animation)1 Animatable (com.b3dgs.lionengine.game.feature.Animatable)1 AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)1 Factory (com.b3dgs.lionengine.game.feature.Factory)1