A shooter opened fire on two NYPD officers as they patrolled the roof of a Brooklyn housing development, blasting a bullet into a door just moments after the officers emerged from it, police said.

The officers were doing a floor-by-floor “vertical” patrol of the Stuyvesant Garden Houses on Gates Ave. in Bedford-Stuyvesant at about 10:30 p.m. Monday night when they heard gunfire from across the way, according to officers.

Police believe the shooter was firing from another rooftop, the New York Daily News reports.