On the day that Sean Williams died, Colin Hatch, 21, had been waiting for a victim, the Old Bailey jury was told.
A 12-year-old boy was probably lucky to have escaped with his life after Hatch failed to entice him up to his flat where Sean was later killed, John Bevan QC, for the prosecution said.
Mr Bevan said that after Hatch's arrest 'dreadful writings' were found in a wardrobe in his mother's bedroom. They described in detail a fantasy where he tempted a 10- year-old girl to his bedroom, stripped, raped, strangled and finally dumped her body in two bin liners.
Hatch, unemployed, of East Finchley, north London, admits manslaughter on the grounds of diminished responsibility but denies murder on 19 July last year.
Sean, who lived nearby at The George public house which was run by his parents, was seen entering the block of flats where Hatch lived with his mother and older brother, Mr Bevan said.
Hatch told police that a boy had come to the flats looking for a friend. He said he would take the boy up to the friend's flat, but instead took him to his own flat where he sexually attacked him and strangled him. Sean's body was covered in bin liners and sticky tape and left in a lift.
Mr Bevan said Sean, a 'typical, lively young boy', had been out following the 'harmless pursuit of biking' when he was attacked and killed within a time span of 15 to 20 minutes. 'There was no time for conversation, no time for chat, no time for trying to seduce the boy.'
Hatch denied that he had intended to kill the boy, or that he derived any sexual pleasure from it, but it had happened because he panicked.
But Mr Bevan said: 'His writings include references to deliberately killing . . . In the fantasy story lack of consent is part of the story, that's part of the excitement. Killing and disposing of the body was part of the plan.'
The trial continues today.