Media playback is unsupported on your device Media caption "A legend": Kendrick Castillo died after lunging at one of the shooters

A teenager died in a shooting at a Colorado high school - days before his graduation - while charging one of the attackers, his classmates say.

Eighteen-year-old Kendrick Castillo was the only fatality in Tuesday's assault allegedly by two students near Denver.

Eight other pupils were injured before the assailants were arrested.

The attack took place just 8km (5 miles) from Columbine High School, the site of one of the country's most notorious shootings 20 years ago.

America's latest school shooting unfolded at the STEM - science, technology, engineering and math - School Highlands Ranch in an affluent suburb of Denver.

Image copyright The Denver Post via Getty Images Image caption A school staff member comforts a child after the shooting

Three heroic students

Classmate Nui Giasolli told US media she was in her British literature class when one of the suspects turned up late and pulled out a gun.

Kendrick lunged at the gunman, "giving us all enough time to get underneath our desks to get ourselves safe, to run across the room to escape", she said.

John Castillo, Kendrick's father, described him as "the best kid in the world", in an interview with the Denver Post.

He said it was not surprising to him that Kendrick was said to have charged one of the shooters as they entered a classroom.

"I wish he had gone and hid," said Mr Castillo, "but that's not his character.

"His character is about protecting people, helping people."

Kendrick was an only child. Mr Castillo said he and his wife are "in a haze".

The 18-year-old was passionate about science and robotics.

He was going to study at a local college in the autumn, planning to major in engineering, his father said.

Two other students in the class are being credited with helping subdue one of the attackers.

One of them was Joshua Jones, who is now at home recovering after being shot twice, according to a statement from his family.

Brendan Bialy was also praised as a hero.

Image copyright Brendan Bialy/Instagram Image caption Brendan tackled one of the gunmen

Brendan is a recruit for the US Marine Corps, but was not trained specifically on active shooter protocols.

Marine Capt Michael Maggitti said in a statement that Brendan's admirable courage "resulted in the safety and protection of his teachers and fellow classmates".

Kendrick, Brendan and Joshua are not the only examples of student heroism recently during a shooting.

Last month at the University of North Carolina at Charlotte, a 21-year-old student, Riley Howell, died while tackling a gunman, buying classmates crucial moments to escape, said police.

Image copyright Facebook, courtesy of Devon Erickson Image caption Devon Erickson, 18, has been named as one of the suspects

How did the Colorado shooting unfold?

Douglas County Sheriff Tony Spurlock said the attack happened just before 14:00 local time (20:00 GMT) on Tuesday.

He told reporters the two attackers came in through an entrance that did not have a metal detector and attacked students in two locations.

Both suspects were pupils at the charter school.

There were around 1,800 students on campus at the time of the attack, Sheriff Spurlock said.

Officers arrived on scene within minutes.

"We did struggle with the suspects to take them into custody," the sheriff said.

More on US gun violence

Media playback is unsupported on your device Media caption How much do US students fear school shootings?

What is known about the suspects?

Police initially misidentified the younger one - a juvenile not named by police - as male.

"We originally thought the juvenile was a male by appearance," Sheriff Spurlock said.

He declined to comment on local media reports that the suspect is transgender and transitioning from female to male.

The other suspect has been identified by police as 18-year-old Devon Erickson.

He made his first court appearance on Wednesday, facing one count of first-degree murder and 29 of attempted first-degree murder.

The defendant hung his head as he sat between two lawyers.

Image copyright Reuters/Courtesy Shreya Nallapati Image caption Students and staff wait outside near the STEM School during the shooting

The sheriff said it is not yet clear if anyone was deliberately targeted. Search warrants have been issued for both suspects' homes.

One student at the school told CBS News Mr Erickson had talked about inflicting harm and sadness.

"I always thought he was just messing around and stuff, but sometimes he did hint at it here and there," Michael Schwartz said.

One parent, named in local media as Fernando Montoya, said his 17-year-old son was shot three times and wounded.

"He said a guy pulled a pistol out of a guitar case and started to shoot," Mr Montoya told ABC affiliate Denver 7.

Josh Dutton, 18, told AP news agency he used to be friends with Mr Erickson at a former school but had not seen him in four years.

He said he bumped into Mr Erickson, who was wearing all black, at a railway station on Sunday and he was much thinner and did not seem interested in talking.