(BLOOMINGTON) - A gunman who was naked when police say he shot more than 30 rounds from a semi-automatic handgun in a neighborhood near the Indiana University campus has been released from a hospital and jailed on preliminary felony charges including attempted murder.

21-year-old Indiana University student Corey Joseph Hamersley was booked into the Monroe County Jail on Tuesday afternoon and held on no bond.

He was shot in the legs by Bloomington police officers Friday morning a few blocks southwest of Memorial Stadium. Hamersley underwent surgery to both of his legs at IU Health Bloomington Hospital.

He also faces preliminary charges of criminal recklessness, pointing a firearm, possession of a controlled substance and possession of marijuana. It wasn't immediately clear if he has an attorney.

"During an interview at the hospital, Hamersley acknowledged the encounter with the first officer and knew it was a police officer because of the uniform the officer was wearing. He indicated that he thought about how 'cool' it would be to say he shot a cop. He also acknowledged pointing a loaded weapon at the first officer, pulling the trigger and trying to shoot the officer in the chest," Bloomington Capt. Joe Qualters stated in the news release.

Hamersley lives in building C of Terra Trace Apartments, right across the street from the home of Margaret and David Greischar, who called police to report a naked man was firing a gun into their back door at 309 E. 15th St. Other neighbors in the area also called police to report the gunfire.

Police say Hamersley fired 32 rounds from a 9mm semi-automatic firearm, hitting both a house and three cars, in the 300 block of East 15th Street.

Bloomington police officers confronted, Hamersley, who was naked, firing a gun and shouting profanities, and two officers shot him when he did not drop his weapon and continued to point and wave the gun at police. No police officers or bystanders were shot.

Mark Land, an Indiana University spokesman says Hamersley is a junior at IU, studying exercise science.

Bloomington Police Sgt. Joe Qualters says the two officers involved in the police-action shooting are on administrative leave until an internal investigation is complete. The names of the officers involved have not been released.

Hamersley was shot after police received a call just before 7 a.m. Friday, reporting of a naked man was firing a gun. The first officer to arrive reported Hamersley fired a gun into the air and fire multiple rounds into the back door of a house. Hamersley ignored commands by the officer to drop the weapon and shot at the officer twice. Hamersley then walked down an alley toward East 15th Street, where another officer saw him with the gun. That officer shot Hamersley causing him to fall to the ground. Hamersley moved to a sitting position, eventually stood and pointed the gun at that officer. A third officer then shot Hamersley, hitting him a second time.

Hamersley went down again. Officers secured his weapon and took him into custody after a brief struggle.

According to Monroe County Circuit Court records, Hamersley faced a misdemeanor charge of possession of marijuana and an infraction for possession of paraphernalia in the summer of 2010.

A Bloomington police officer pulled over a vehicle on a seat belt violation in the 400 block of West Sixth Street about 10:20 a.m. June 21, 2010. The officer reported finding Hamersley to be in possession of marijuana and paraphernalia, and he was given a misdemeanor citation, according to police records.

He entered a pretrial diversion program for the charges to be dismissed and paid a $403 fee.