The 17-year-old boy who killed 15 people in a gun rampage in south-west Germany yesterday had warned on an internet chat­room the night before that he would go to his old school and do something big the following day, German authorities said today.

Tim Kretschmer shot nine pupils and three teachers at the Albertville secondary school in Winnenden on Wednesday morning. He killed another three people before he was shot dead by police.

At a press conference this afternoon, police said Kretschmer had begun having psychiatric sessions last year but stopped attending in September. One of Kretschmer's killings was at the mental health clinic he had attended.

Heribert Rech, interior minister of the south-western state of Baden-Württemberg, said Kretschmer went on to an internet chatroom in the early hours of Wednesday where he wrote: "I've had enough. I'm fed up of this pointless life. Always the same. Everybody laughs at me. No one sees my potential. I'm serious. I have weapons and I will go to my old school in the morning and have a proper barbecue. Maybe I'll get away. Listen out. You will hear about me tomorrow. Remember the place's name: Winnenden."

A 17-year-old boy from Bavaria was in the chatroom at the time and last night told his father, who reported it to the police.

According to a police spokesman, Klaus Hinderer, analysis of Kretschmer's computer has shown that the teenager had become an avid player of shoot-em-up video games, particularly one called Counter-Strike, in recent months.

It emerged in German reports today that the headteacher was able to warn teachers with a pre-arranged code over the public address system when Kretschmer burst in, possibly preventing him from killing any more than 12 .

Students said the principal quickly broadcast a coded message to teachers: "Frau Koma is coming."

"Then our teacher closed the door and said we should close the windows and sit on the floor," a student, identified only as Kim S, told ZDF television.

In German the word "amoklauf" is used to describe mass shootings, and "koma" is the reverse of the word "amok." Germany's Bild newspaper reported the coded alert was worked out by German educators after a deadly school shooting in Erfurt in 2002 as a way to warn teachers.

An amateur video has emerged showing Kretschmer's final moments. The boy, wearing dark clothing, can be seen walking unsteadily between parked cars in front of a car dealership. Minutes before, Kretschmer had shot a sales assistant and a customer inside. He left the showroom and was confronted by waiting police marksmen. Kretschmer can be seen on the video apparently reloading his gun before he slumps to the floor, hit in the leg by a police bullet.

It emerged today that Kretschmer sent a letter to his parents saying he was desperately unhappy and "couldn't go on".

Kretschmer wrote the note three weeks ago and gave it to his mother and father, said Fabienne Böhm, who met Kretschmer recently through a friend. "He wrote to his parents that he's suffering and he can't go on," she told the Associated Press.

As investigators began their first full day of inquiries into the massacre, German media began to release the names of Kretschmer's victims, but local police refused to confirm the details.

Flags are flying at half-mast across Germany in mourning for the 15 people killed by the 9mm Beretta pistol police believe he took from his parents' bedroom.

A shrine of flowers and candles has formed in front of the three-storey school building where Kretschmer killed eight girls, one boy and three female teachers. Many cards left there paid tribute to those lost. One, pinned down by a cherub statuette and two single flowers, read simply: "Why?"

That question, among others, will be foremost in the minds of police as they attempt to establish what could have motivated an apparently normal young man to perpetrate an act of such horror.

Despite 11 of the victims being female, officials remained reticent about the possibility that Kretschmer had deliberately targeted girls, suggesting instead the gender imbalance could have been due to positioning in the classroom. "I don't want to speculate too much about this at this point," said Heribert Rech, the interior minister of Baden-Württemberg. "The pupils sitting nearest the door were girls."

Testimonies of friends and acquaintances today portray the table tennis champion as a lonely and frustrated person who felt rejected by society. A 17-year-old who gave his name as Aki said he had been studying alongside Kretschmer at a private business school in the region and described him as a quiet and reserved boy who enjoyed playing Counter-Strike, a multi-player game that involves carrying out assassinations to complete missions. "He was good," he said.

Other friends said he had kept dozens of air guns in his bedroom and had taken after his father in his love of guns and weaponry. According to Böhm, 12, Kretschmer had complained of being teased by his fellow students and ignored by his teachers while at Albertville.

Today a team of school and police psychologists was due to arrive in Baden-Württemberg to assist the bereaved and survivors of the attack. One trauma specialist, Christian Luedke, told the Neue Presse newspaper the current site of Albertsville school should be closed for good. "The school has become a crime scene," he said. "No more lessons can take place there."