I was sitting on a young woman's bed when two men burst in and slammed hard into my shoulder, sending us all sprawling in a heap of arms and legs.

I was watching two near-naked men caressing each other, and a football, when a gunman ordered me out amid a cacophony of howls and screams.

I was perched on a hotel toilet when a golden-robed transvestite lying in the bath extracted a swab of my saliva and fragment of my fingernail.

But perhaps more unusual than any of these, I was white, middle-class and walking around Hillbrow in inner-city Johannesburg and Kliptown in Soweto.

The reason was X Homes Johannesburg, a weird and wonderful public art project co-produced by the Goethe Institut in South Africa and Christopher Gurk of the Hebbel Am Ufer Theatre in Berlin.

It involved a walking tour of two to three hours, stopping at private houses, flats, hotels and other nooks and crannies to watch oddball performances by local and international artists, some of which were highly interactive.

Hillbrow has seen better days and now has a notoriety reminiscent of the Bronx in 1970s New York. Louis Theroux, clad in body armour, shot a documentary there that portrayed a dystopia of drug lords, vigilantism and the hijacking of entire buildings. I've met people in Johannesburg who would sooner visit Kabul or Mogadishu.

The mission of X Homes, however, was "to change the perception of urban spaces, which many inhabitants of Johannesburg know only from rumours in the media, and to produce images beyond the projection of violence and fear ever present in this country".

That didn't prevent us from having to sign a responsibility waiver form before the tour began. In a group of four we were led into a grim and grimy block of flats with graffiti and shattered windows.

Inside one of them an actress spoke a lament for Hillbrow's golden age, recalling the clubs, the jazz, the arthouse cinemas showing films like Paris, Texas and The Last Picture Show.

A member of the group mentioned that she used to live here and walk the streets until two in the morning. She pointed to the once beautiful Chelsea Hotel and said it's now a Nigerian drugs den. I gazed around at the shells of elegant art deco buildings that now reminded me of decaying shipwrecks on the ocean floor.

We carried on to performance after performance, up nine floors of stairs in decrepit buildings where the lifts had long ceased to work, on to roofs where baby clothes hung on washing lines, down past sparring boxers to the basement of a gym. Here, with a TV blaring and red candles glowing from the floor, a man paraded in high heels, his face and torso obscured by a huge cluster of balloons.

Later we shuffled through body-height turnstiles and squeezed into a lift that struggled upwards with noises that suggested the rumbling belly of a beast. We walked along a corridor similar to tower blocks in Britain's sink estates.

Through a doorway, a woman in World Cup regalia greeted us while others blew vuvuzelas. We were ushered into the living room where a television showed clips of football — interspersed, occasionally, with snatches of explicit gay porn.

Then two men, one black, one white, stripped and began a strange sexual dance with a football pressed between their bare flesh.

Eventually they leaped into bed and began to heave and groan. But we were taken to the window, the curtain lowered behind us, and told to watch everyday Hillbrow life take its course in the park below. Then we were chased away by intruders waving pistols.

This sketch was the work of Bruce LaBruce, a "Canadian avant-garde gay porn filmmaker". "This is so hardcore," he said of the X Homes project in an interview with South Africa's Mail and Guardian.

"It's not for sissies. And it's not politically correct. It's not tiptoeing around race and culture issues.

"On those terms there's nothing bleeding-heart liberal about it. It's not about outreach, you know, trying to improve the lives of these poor, underprivileged people. It's nothing like that at all."

In another Hillbrow flat a woman recounted her experience at the hands of a gang who threatened to shoot her. On the table, the photograph of her bruised face suggested this story was real.

As we walked among the traffic and street markets there were some curious glances in our direction but nothing more. "I haven't felt threatened once," one of our group said. But it's facile to say that crime in Hillbrow is purely a mythical demon conjured by middle-class dinner parties in the northern suburbs. It's real and I've met some of the victims. But yes, it is hyped and exaggerated too.

Soweto was no less surreal. In a brick house around the corner from the Soweto country club I sat on a sofa watching a man peel off innumerable T-shirts while humming Mozart and dancing like a puppet.

In Kliptown I was filmed enacting a single line from Quentin Tarantino's movie Jackie Brown to a man in a woman's wig.

I was led on a walk over some railway lines to a settlement of shacks and dirt tracks, more District 9 than sanitised township tour. A young woman hurled rubbish over a fence, a child with a squint wandered aimlessly and a solitary water tap leaked into the mud. One deserted building looked like a ruin from a warzone, but most of the houses were small structures improvised from chunks of corrugated metal.

This desperate setting was a stage too. A woman studied me nervously from behind her front door, then demanded what I wanted, then thrust a leg, and a bottom, and a breast at me before slamming it shut. Nearby, amid pockmarked walls and peeling paint, a poet told the story of a devil's daughter, accompanied by a stirring drumbeat and a woman's soulful songs.

It is said that the World Cup helped force middle-class South Africans out of their cars, and their customary security bubbles, into public transport and public spaces where they rarely venture. X Homes took the process one step further. It was imaginative, irreverent and at times rather insane, with several candidates for pseuds' corner. I hope it comes back.