use of com.b3dgs.lionengine.Localizable in project lionengine by b3dgs.
the class GeomTest method testNotSameLocalizable.
/**
* Test if localizable are not same.
*/
@Test
void testNotSameLocalizable() {
final Localizable localizable = Geom.createLocalizable(2.5, 3.5);
assertFalse(Geom.same(localizable, Geom.createLocalizable(1.5, 2.5)));
assertFalse(Geom.same(Geom.createLocalizable(1.5, 2.5), localizable));
assertFalse(Geom.same(Geom.createLocalizable(1.5, 2.5), Geom.createLocalizable(2.5, 3.5)));
assertFalse(Geom.same(Geom.createLocalizable(1.5, 1.5), Geom.createLocalizable(1.5, 2.5)));
assertFalse(Geom.same(Geom.createLocalizable(3.5, 2.5), Geom.createLocalizable(1.5, 2.5)));
final Coord coord = new Coord(2.5, 3.5);
assertFalse(Geom.same(coord, new Coord(1.5, 2.5)));
assertFalse(Geom.same(new Coord(1.5, 2.5), coord));
assertFalse(Geom.same(coord, Geom.createLocalizable(1.5, 2.5)));
}
use of com.b3dgs.lionengine.Localizable in project lionengine by b3dgs.
the class CameraTest method testIsViewable.
/**
* Test the camera viewable.
*/
@Test
void testIsViewable() {
camera.setView(0, 0, 2, 2, 2);
final Services services = new Services();
services.add(new ContextMock());
final Cursor cursor = new Cursor(services);
cursor.setArea(-2, -2, 4, 4);
cursor.setLocation(0, 0);
cursor.update(1.0);
assertTrue(camera.isViewable((Localizable) cursor, 0, 0));
assertFalse(camera.isViewable((Localizable) cursor, 0, -1));
assertFalse(camera.isViewable((Localizable) cursor, -1, 0));
assertFalse(camera.isViewable((Localizable) cursor, -1, -1));
assertTrue(camera.isViewable(cursor, 0, 0));
assertFalse(camera.isViewable(cursor, 0, -2));
assertFalse(camera.isViewable(cursor, -2, 0));
assertFalse(camera.isViewable(cursor, -2, -2));
cursor.setLocation(3, 3);
cursor.update(1.0);
assertFalse(camera.isViewable((Localizable) cursor, 0, 0));
assertFalse(camera.isViewable((Localizable) cursor, 0, 1));
assertFalse(camera.isViewable((Localizable) cursor, 1, 0));
assertTrue(camera.isViewable((Localizable) cursor, 1, 1));
assertFalse(camera.isViewable(cursor, -1, -1));
assertFalse(camera.isViewable(cursor, 0, -2));
assertFalse(camera.isViewable(cursor, -2, 0));
assertTrue(camera.isViewable(cursor, 0, 0));
assertTrue(camera.isViewable(cursor, 0, 0));
assertTrue(camera.isViewable(cursor, 1, 3));
cursor.setLocation(-2, -2);
cursor.update(1.0);
assertFalse(camera.isViewable(cursor, 0, 0));
assertFalse(camera.isViewable(cursor, 0, -1));
assertFalse(camera.isViewable(cursor, -1, 0));
assertTrue(camera.isViewable(cursor, 1, 1));
cursor.setLocation(0, -2);
cursor.update(1.0);
assertFalse(camera.isViewable(cursor, 0, 0));
assertFalse(camera.isViewable(cursor, -1, 0));
assertFalse(camera.isViewable(cursor, 0, -1));
assertTrue(camera.isViewable(cursor, 1, 1));
cursor.setLocation(-2, 0);
cursor.update(1.0);
assertFalse(camera.isViewable(cursor, 0, 0));
assertFalse(camera.isViewable(cursor, 0, -1));
assertFalse(camera.isViewable(cursor, -1, 0));
assertTrue(camera.isViewable(cursor, 1, 1));
cursor.setLocation(-2, 2);
cursor.update(1.0);
assertFalse(camera.isViewable(cursor, 0, 0));
assertFalse(camera.isViewable(cursor, -1, 0));
assertFalse(camera.isViewable(cursor, 0, -1));
assertTrue(camera.isViewable(cursor, 1, 1));
cursor.setLocation(2, -2);
cursor.update(1.0);
assertFalse(camera.isViewable(cursor, 0, 0));
assertTrue(camera.isViewable(cursor, 1, 1));
}
Aggregations