Internet pornography was likely to be behind the rape of a 10-year-old boy by a fellow pupil in the school toilets, a court has heard.
Karl Scholz, prosecuting, told Mold Crown Court the defendant was "acting out" what he had seen.
He claimed pornography was viewed by both the defendant and the complainant.
The 12-year-old pleaded not guilty to the rape two years ago, and inciting the boy to engage in sexual activity at the school in the Colwyn Bay area.
In March last year the complainant was spoken to by teachers following rumours in the school about his sexual behaviour.
It was during this time, the court heard, the boy told teachers what the defendant was alleged to have done to him.
That night he told his parents and the matter was reported to the police.
He told North Wales Police he disliked the defendant, who he described as "Mr Goody-Good" in front of teachers but who "speaks trash, rubbish" and was "mean and rude" in the playground.
He said the defendant would swear at him and call him gay.
Mr Scholz said the complainant withdrew himself from the playground at break times because he feared being bullied, and would wander up and down outside the boys' toilets alone.
The court was told the first alleged incident happened when the defendant asked the complainant during an English class if he wanted to have sex with him.
"It was an unusual question for a 10-year-old boy to ask another," said Mr Scholz.
The complainant replied "no way" and thought the defendant was joking.
After the lesson had finished and before the lunch break, the complainant went to the toilet but as he tried to leave, the defendant walked in and grabbed him before raping him, the jury was told.
The court heard the complainant told him to stop and scratched the defendant's arm.
Afterwards, the court was told, the complainant was embarrassed and feared that he would be called gay so did not tell anyone.
On a second occasion, it was alleged, the defendant tried to pull the complainant's trousers down as he washed his hands after using the toilet but the boy managed to hold on to his clothes.
"Why not? It's fun," the defendant is alleged to have told him.
During police interviews, the defendant admitted he had been mean to the complainant but had not bullied him.
He said he had never asked him for sex, nothing sexual had happened between them and he only asked him out as a joke.
The case continues.