Taylor Dorman was playing "Over the Line," an improvised softball game, during gym class Wednesday when he was struck in the chest with a ball, Ramona High School Principal Tony Newman said.
"After being hit Taylor complained of his chest hurting then he collapsed," he said.
Fellow students told KFMB-TV, San Diego, that Dorman continued playing the game and seemed fine for about 20 minutes, even joking with the student who had hit the ball at him before collapsing.
A helicopter transferred Dorman to Palomar Medical Center in Escondido where he died a few hours later, KFMB reported.
The cause of Dorman's death was not reported.
Friends of the student, who played football, said his father died of a heart attack when he was young, KSWB-TV, San Diego, reported.
Students and faculty gathered at the school Wednesday evening to mourn Dorman's death and also celebrate his birthday, which was Wednesday, KSWB said.