Search in sources :

Example 6 with Localizable

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)));
}
Also used : Localizable(com.b3dgs.lionengine.Localizable) Test(org.junit.jupiter.api.Test)

Example 7 with Localizable

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));
}
Also used : ContextMock(com.b3dgs.lionengine.ContextMock) Cursor(com.b3dgs.lionengine.game.Cursor) Localizable(com.b3dgs.lionengine.Localizable) Test(org.junit.jupiter.api.Test)

Aggregations

Localizable (com.b3dgs.lionengine.Localizable)7 Test (org.junit.jupiter.api.Test)7 ContextMock (com.b3dgs.lionengine.ContextMock)1 Cursor (com.b3dgs.lionengine.game.Cursor)1 Handler (com.b3dgs.lionengine.game.feature.Handler)1 Transformable (com.b3dgs.lionengine.game.feature.Transformable)1 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1