Search in sources :

Example 11 with Point

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 transformable The transformable reference.
 * @param collidable The collidable reference.
 */
private void removePoints(Transformable transformable, Collidable collidable) {
    final int oldMinX = getIndex(transformable.getOldX() - collidable.getMaxWidth());
    final int oldMinY = getIndex(transformable.getOldY() - collidable.getMaxHeight());
    final int oldMaxX = getIndex(transformable.getOldX() + collidable.getMaxWidth());
    final int oldMaxY = getIndex(transformable.getOldY() + collidable.getMaxHeight());
    for (int x = oldMinX; x <= oldMaxX; x++) {
        for (int y = oldMinY; y <= oldMaxY; y++) {
            removePoint(cache(x, y), collidable);
        }
    }
}
Also used : Point(com.b3dgs.lionengine.geom.Point)

Example 12 with Point

use of com.b3dgs.lionengine.geom.Point in project lionengine by b3dgs.

the class ComponentCollision method getPoints.

/**
 * Get point representing the area.
 *
 * @param area The area reference.
 * @return The area divided in point depending of reduce factor.
 */
private Collection<Point> getPoints(Area area) {
    final Collection<Point> points = new HashSet<>(4);
    final int oldMinX = getIndex(area.getX() - area.getWidth());
    final int oldMinY = getIndex(area.getY() - area.getHeight());
    final int oldMaxX = getIndex(area.getX() + area.getWidth());
    final int oldMaxY = getIndex(area.getY() + area.getHeight());
    for (int x = oldMinX; x <= oldMaxX; x++) {
        for (int y = oldMinY; y <= oldMaxY; y++) {
            points.add(cache(x, y));
        }
    }
    return points;
}
Also used : Point(com.b3dgs.lionengine.geom.Point) Point(com.b3dgs.lionengine.geom.Point) HashSet(java.util.HashSet)

Aggregations

Point (com.b3dgs.lionengine.geom.Point)12 HeadlessException (java.awt.HeadlessException)2 PointerInfo (java.awt.PointerInfo)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2