private Collection < CollisionFormula > checkConstraints ( TileCollision tile , int h , int v ) { final Tile top = map . getTile ( h , v + 1 ) ; final Tile bottom = map . getTile ( h , v - 1 ) ; final Tile left = map . getTile ( h - 1 , v ) ; final Tile right = map . getTile ( h + 1 , v ) ; final Collection < CollisionFormula > toRemove = new ArrayList <> ( ) ; for ( final CollisionFormula formula : tile . getCollisionFormulas ( ) ) { final CollisionConstraint constraint = formula . getConstraint ( ) ; if ( checkConstraint ( constraint . getConstraints ( Orientation . NORTH ) , top ) || checkConstraint ( constraint . getConstraints ( Orientation . SOUTH ) , bottom ) || checkConstraint ( constraint . getConstraints ( Orientation . WEST ) , left ) || checkConstraint ( constraint . getConstraints ( Orientation . EAST ) , right ) ) { toRemove . add ( formula ) ; } } return toRemove ; }
Check the tile constraints and get the removable formulas .