use of com.b3dgs.lionengine.game.Cursor in project lionengine by b3dgs.
the class UtilAssignable method createServices.
/**
* Create the services.
*
* @param clicked The click flag.
* @param clickNumber The click number recorded.
* @return The services.
*/
public static Services createServices(AtomicBoolean clicked, AtomicReference<Integer> clickNumber) {
final Services services = new Services();
final Camera camera = services.create(Camera.class);
camera.setView(0, 0, 32, 32, 32);
services.add(new ContextMock());
final Cursor cursor = services.add(new Cursor(services) {
@Override
public boolean isPushedOnce(Integer click) {
clickNumber.set(click);
return clicked.get();
}
});
cursor.setArea(0, 0, 64, 64);
cursor.setLocation(0, 1);
return services;
}
use of com.b3dgs.lionengine.game.Cursor in project lionengine by b3dgs.
the class UtilActionnable method createServices.
/**
* Create the services.
*
* @param clicked The click flag.
* @param clickNumber The click number recorded.
* @return The services.
*/
public static Services createServices(final AtomicBoolean clicked, final AtomicInteger clickNumber) {
final Services services = new Services();
final Cursor cursor = new Cursor() {
@Override
public boolean hasClickedOnce(int click) {
clickNumber.set(click);
return clicked.get();
}
};
cursor.setArea(0, 0, 32, 32);
cursor.setLocation(0, 1);
services.add(cursor);
return services;
}
use of com.b3dgs.lionengine.game.Cursor in project lionengine by b3dgs.
the class UtilAssignable method createServices.
/**
* Create the services.
*
* @param clicked The click flag.
* @param clickNumber The click number recorded.
* @return The services.
*/
public static Services createServices(final AtomicBoolean clicked, final AtomicInteger clickNumber) {
final Services services = new Services();
final Camera camera = services.create(Camera.class);
camera.setView(0, 0, 32, 32, 32);
final Cursor cursor = services.add(new Cursor() {
@Override
public boolean hasClickedOnce(int click) {
clickNumber.set(click);
return clicked.get();
}
});
cursor.setArea(0, 0, 64, 64);
cursor.setLocation(0, 1);
return services;
}
use of com.b3dgs.lionengine.game.Cursor 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));
}
use of com.b3dgs.lionengine.game.Cursor 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);
}
Aggregations