use of com.b3dgs.lionengine.geom.Point in project lionengine by b3dgs.
the class ComponentCollision method removePoints.
/**
* Remove point and adjacent points depending of the collidable max collision size.
*
* @param x The horizontal location.
* @param y The vertical location.
* @param collidable The collidable reference.
*/
private void removePoints(double x, double y, Collidable collidable) {
final int minX = (int) Math.floor(x / REDUCE_FACTOR);
final int minY = (int) Math.floor(y / REDUCE_FACTOR);
final int maxX = (int) Math.floor((x + collidable.getMaxWidth()) / REDUCE_FACTOR);
final int maxY = (int) Math.floor((y + collidable.getMaxHeight()) / REDUCE_FACTOR);
removePoint(new Point(minX, minY), collidable);
if (minX != maxX && minY == maxY) {
removePoint(new Point(maxX, minY), collidable);
} else if (minX == maxX && minY != maxY) {
removePoint(new Point(minX, maxY), collidable);
} else if (minX != maxX) {
removePoint(new Point(minX, maxY), collidable);
removePoint(new Point(maxX, minY), collidable);
removePoint(new Point(maxX, maxY), collidable);
}
}
use of com.b3dgs.lionengine.geom.Point in project lionengine by b3dgs.
the class MouseMoveAwt method getCursorLocation.
/**
* Get the buttons number.
*
* @return The buttons number.
*/
private static Point getCursorLocation() {
try {
final PointerInfo a = MouseInfo.getPointerInfo();
final java.awt.Point b = a.getLocation();
return new Point((int) b.getX(), (int) b.getY());
} catch (final HeadlessException exception) {
Verbose.exception(exception);
return new Point();
}
}
use of com.b3dgs.lionengine.geom.Point in project lionengine by b3dgs.
the class MouseMoveAwt method getCursorLocation.
/**
* Get the buttons number.
*
* @return The buttons number.
*/
private static Point getCursorLocation() {
try {
final PointerInfo a = MouseInfo.getPointerInfo();
final java.awt.Point b = a.getLocation();
return new Point((int) b.getX(), (int) b.getY());
} catch (final HeadlessException exception) {
Verbose.exception(exception);
return new Point();
}
}
use of com.b3dgs.lionengine.geom.Point in project lionengine by b3dgs.
the class ComponentCollision method getInside.
/**
* Get elements inside area.
*
* @param area The area used.
* @return The elements inside area.
*/
public Collection<Collidable> getInside(Area area) {
final Collection<Collidable> inside = new HashSet<>();
final Collection<Point> points = getPoints(area);
for (final Map<Point, List<Collidable>> groups : collidables.values()) {
for (final Point point : points) {
final List<Collidable> elements = groups.get(point);
if (elements != null) {
checkInside(elements, area, inside);
}
}
}
return inside;
}
use of com.b3dgs.lionengine.geom.Point in project lionengine by b3dgs.
the class ComponentCollision method addPoints.
/**
* Add point and adjacent points depending of the collidable max collision size.
*
* @param transformable The transformable reference.
* @param collidable The collidable reference.
*/
private void addPoints(Transformable transformable, Collidable collidable) {
final int minX = getIndex(transformable.getX() - collidable.getMaxWidth());
final int minY = getIndex(transformable.getY() - collidable.getMaxHeight());
final int maxX = getIndex(transformable.getX() + collidable.getMaxWidth());
final int maxY = getIndex(transformable.getY() + collidable.getMaxHeight());
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
addPoint(cache(x, y), collidable);
}
}
}
Aggregations