use of com.b3dgs.lionengine.game.feature.tile.Tile 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());
}
use of com.b3dgs.lionengine.game.feature.tile.Tile 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());
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class TileCollidableModelTest method testSelfListener.
/**
* Test the collidable self listener.
*/
@Test
void testSelfListener() {
final ObjectSelf self = new ObjectSelf(services, setup);
final Transformable transformable = createObject(self);
final AtomicReference<Tile> collided = new AtomicReference<>();
final TileCollidableListener listener = createListener(collided);
collidable.addListener(listener);
transformable.teleport(0.0, 2.0);
transformable.moveLocation(1.0, 0.0, -1.0);
collidable.removeListener(listener);
collidable.update(1.0);
assertNull(collided.get());
assertTrue(self.called.get());
}
use of com.b3dgs.lionengine.game.feature.tile.Tile 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());
}
use of com.b3dgs.lionengine.game.feature.tile.Tile 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());
}
Aggregations