Search in sources :

Example 11 with FeaturableModel

use of com.b3dgs.lionengine.game.feature.FeaturableModel in project lionengine by b3dgs.

the class TileCollidableModelTest method testFromLeft.

/**
 * Test the collidable from left.
 */
@Test
void testFromLeft() {
    final Transformable transformable = createObject(new FeaturableModel(services, setup));
    final AtomicReference<Tile> collided = new AtomicReference<>();
    final TileCollidableListener listener = createListener(collided);
    collidable.addListener(listener);
    transformable.teleport(-1.0, 0.0);
    transformable.moveLocation(1.0, 2.0, 0.0);
    collidable.update(1.0);
    assertEquals(map.getTile(0, 0), collided.get());
}
Also used : Transformable(com.b3dgs.lionengine.game.feature.Transformable) Tile(com.b3dgs.lionengine.game.feature.tile.Tile) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Example 12 with FeaturableModel

use of com.b3dgs.lionengine.game.feature.FeaturableModel in project lionengine by b3dgs.

the class TileCollidableModelTest method testFromTop.

/**
 * Test the collidable from top.
 */
@Test
void testFromTop() {
    final Transformable transformable = createObject(new FeaturableModel(services, setup));
    final AtomicReference<Tile> collided = new AtomicReference<>();
    final TileCollidableListener listener = createListener(collided);
    collidable.addListener(listener);
    transformable.teleport(0.0, 3.0);
    transformable.moveLocation(1.0, 0.0, -2.0);
    collidable.update(1.0);
    assertEquals(map.getTile(0, 2), collided.get());
}
Also used : Transformable(com.b3dgs.lionengine.game.feature.Transformable) Tile(com.b3dgs.lionengine.game.feature.tile.Tile) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Example 13 with FeaturableModel

use of com.b3dgs.lionengine.game.feature.FeaturableModel in project lionengine by b3dgs.

the class TileCollidableModelTest method testDisabled.

/**
 * Test the collidable disabled.
 */
@Test
void testDisabled() {
    final Transformable transformable = createObject(new FeaturableModel(services, setup));
    final AtomicReference<Tile> collided = new AtomicReference<>();
    final TileCollidableListener listener = createListener(collided);
    collidable.addListener(listener);
    collidable.setEnabled(false);
    transformable.teleport(0, 2);
    transformable.moveLocation(1.0, 0.0, -1.0);
    collidable.update(1.0);
    assertNull(collided.get());
}
Also used : Transformable(com.b3dgs.lionengine.game.feature.Transformable) Tile(com.b3dgs.lionengine.game.feature.tile.Tile) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Example 14 with FeaturableModel

use of com.b3dgs.lionengine.game.feature.FeaturableModel in project lionengine by b3dgs.

the class TileCollidableModelTest method testRemoveListener.

/**
 * Test the collidable with remove listener.
 */
@Test
void testRemoveListener() {
    final Transformable transformable = createObject(new FeaturableModel(services, setup));
    final AtomicReference<Tile> collided = new AtomicReference<>();
    final TileCollidableListener listener = createListener(collided);
    collidable.checkListener(transformable);
    collidable.checkListener(listener);
    transformable.teleport(0.0, 2.0);
    transformable.moveLocation(1.0, 0.0, -1.0);
    collidable.update(1.0);
    assertNotNull(collided.get());
    collided.set(null);
    collidable.removeListener(listener);
    collidable.update(1.0);
    assertNull(collided.get());
}
Also used : Transformable(com.b3dgs.lionengine.game.feature.Transformable) Tile(com.b3dgs.lionengine.game.feature.tile.Tile) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Example 15 with FeaturableModel

use of com.b3dgs.lionengine.game.feature.FeaturableModel in project lionengine by b3dgs.

the class TileCollidableModelTest method testFromRight.

/**
 * Test the collidable from right.
 */
@Test
void testFromRight() {
    final Transformable transformable = createObject(new FeaturableModel(services, setup));
    final AtomicReference<Tile> collided = new AtomicReference<>();
    final TileCollidableListener listener = createListener(collided);
    collidable.addListener(listener);
    transformable.teleport(3.0, 0.0);
    transformable.moveLocation(1.0, -2.0, 0.0);
    collidable.update(1.0);
    assertEquals(map.getTile(2, 0), collided.get());
}
Also used : Transformable(com.b3dgs.lionengine.game.feature.Transformable) Tile(com.b3dgs.lionengine.game.feature.tile.Tile) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Aggregations

FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)33 Test (org.junit.jupiter.api.Test)20 Featurable (com.b3dgs.lionengine.game.feature.Featurable)18 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)18 Transformable (com.b3dgs.lionengine.game.feature.Transformable)16 Setup (com.b3dgs.lionengine.game.feature.Setup)14 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)7 Media (com.b3dgs.lionengine.Media)6 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)6 Services (com.b3dgs.lionengine.game.feature.Services)5 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)5 Medias (com.b3dgs.lionengine.Medias)4 Identifiable (com.b3dgs.lionengine.game.feature.Identifiable)4 Animation (com.b3dgs.lionengine.Animation)3 UtilAssert.assertEquals (com.b3dgs.lionengine.UtilAssert.assertEquals)3 UtilAssert.assertTrue (com.b3dgs.lionengine.UtilAssert.assertTrue)3 AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)3 UtilTransformable (com.b3dgs.lionengine.game.feature.UtilTransformable)3 MapTile (com.b3dgs.lionengine.game.feature.tile.map.MapTile)3