The 18-year-old German-Iranian gunmanwho killed nine people in Munich on Friday began planning the attack a year ago after visiting the German city of Winnenden where another teenager killed 15 people in 2009, Bavarian officials said on Sunday.
Materials found at the gunman's home also showed he had been hospitalised for psychiatric care for three months around the same time, and was an avid player of violent video games, the officials told a news conference.
One of the games was "Counter Strike: Source", Robert Heimberger, president of the state crime office, said. He said it was "a game played by nearly every known rampage killer".
The gunman - identified by sources as David Sonboly - called himself "Ali" and once described the 17-year-old killer in the 2009 attack as a good person, according to a 16-year-old youth with whom he played video games in an online club, the German magazine Spiegel reported.
He frequently used online video handles such as "Hate" and "Rampage Killer", expressed nationalistic views, and was eventually excluded from the club because the other members were afraid of him, the magazine cited the other youth as saying.
"We always expected something like what happened, but we never thought he could get a gun and then use it," he said.
The gunman was also evidently inspired by Norwegian mass killer Anders Breivik, and likely deliberately staged the shooting on thefifth anniversary of Breivik's massacre of 77 people, Heimberger said.