A Spaulding man was formally charged Friday in Sangamon County court with two Class X felonies for allegedly shooting at local police officers.

William Cooper, 44, faces up to 45 years in prison after he was charged with two counts of aggravated discharge of a firearm at a police officer. He was arrested Aug. 20 after he fled his residence, according to court documents.

Ten shell casings were found at the scene, said Sangamon County State’s Attorney Dan Wright. Cooper was also charged with aggravated assault with a motor vehicle, a Class 4 felony, for allegedly driving through a metal gate and almost hitting multiple officers as he attempted to flee the scene.

Cooper was arrested hours after Riverton and Spaulding police responded to a report of a possible overdose at his residence on Devine Drive, according to the Sangamon County Sheriff’s Office.

After his alleged escape, he apparently ditched his vehicle near the intersection of Mary Lane and Francis Drive. He then fled to the woods before being arrested at a house less than a mile away, according to Sangamon County Sheriff Jack Campbell.

A motion by Cooper’s attorney to lower his $1 million bond was denied. A conditional release with a minimum payment of $100,000 was established.

The Class X felony charges come with a 10- to 45-year prison term if convicted.