It’s a sweltering day in June last year. The air in Albuquerque still smells burnt from wildfires along the Arizona border. Inside the rusting hulk of an abandoned train depot on the edge of downtown, The Avengers has turned the empty space into a New York City battlescape.

Flames and smoke rise from heaps of rubble along a strip made to look like a Manhattan street. Smashed cars are wheeled around on forklifts, and guys in alien motion-capture suits strut in to rehearse an attack on Captain America. Scarlett Johansson has just finished a scene where wires swing her leather-clad form through the air, and Mark Ruffalo is in a far corner looking at digital effects for an upcoming scene with him as The Hulk.

Sitting alone in a folding chair amid the chaos is writer-director Joss Whedon, whose mind probably looks a lot like the scene around him: overheated, frenzied, and full of weird characters.

The Avengers premiered to raves this week, and opens nationwide on May 4. (Meanwhile, Cabin the Woods, the horror film he co-wrote, debuts today). Here’s what it was like to be present at creation on The Avengers set, when Whedon let EW poke around that brain of his…

ENTERTAINMENT WEEKLY: Basic question in the midst of filming: How’s it going?JOSS WHEDON: I’m pretty into it. I don’t know, I don’t want to jinx myself but it seems to be coming together. Every day I make some boneheaded mistake, either in the process or in what I shoot, and I go, ‘Really? Wow. So no learning curve, huh?’ But in spite of that, it’s kind of infectious. Everybody is very excited. The actors are really working for each other. They’re a bunch. In fact, it’s not actually how the movie is supposed to work. They’re not supposed to get along.

Ruffalo said they get along better than the actual Avengers.
[Laughs] I was like, well, if they hate each other, I guess we can use that. But they don’t. The only problem I have is sometimes I need to shut them up so we can make movies and stop chatting. That’s really been my biggest problem.

Better than drama off camera?
Oh, I’m just fine without drama off camera. I really only have drama trying to figure out everybody’s schedule.

Is there anything about making The Avengers that you didn’t expect before you started?What surprised me most is it’s more like making an Internet musical than anything. [Laughs] You’re constantly going, ‘Okay, this is what I’ve got. I have a horse. I have Albuquerque.’ It really is this weird, seat-of-your-pants thing. There’s a lot of prepping while writing – and I’m still writing. [Laughs] It means that there is a weird element of, they handed me one of the biggest movies of all time, and I’m making it up as I go.
You’re talking punch up, right? I assume most of the story must be mapped out.
Obviously there’s a huge amount of prep, and there’s a huge amount of pre-visualization and all that sort of stuff, but the day is the day. What happens during it is still very fluid, and it has to be, because otherwise it gets ossified. What you’re trying to do all the time is up the stakes, emotionally and physically. I wrote an enormous climax – an unfilmable climax – and just proceeded to keep filming it instead of not. So I’m constantly going, ‘Oh, these don’t connect enough, here’s where we need to be a little bloodier, a little dirtier. Here’s where we need to be a little grander.’ It’s all happening all the time.

Is it better to have uncertainty on the day?Well, I’m not a big fan of uncertainty – it does give me a stomach ache. So I’m going to go with ‘fluidity’ over ‘uncertainty.’ But yes, you do need that sort of X factor. That sort of ‘I don’t know exactly what [the actor’s] going to bring, I don’t know if the comedy is going to play harder here, or the drama, or the fear, or what the mix is going to be.’ Occasionally you have to think of things beforehand – like props. But you’re living in that moment. You have to think about the big picture all the time and also get tiny tunnel vision and think this scene is the only scene. Not that they’re all climaxes, but they all have to have their own flow and beauty and reason for being – or else there won’t be later on.

And that scene ends up on the DVD.
There’s nothing that doesn’t end up somewhere nowadays.

Now that you’re directing, is there anything you wish you could go back in time to say to Joss the writer?
Write faster. Oh my God, I lost so much time to problems that didn’t matter. But coming at a script like this is very difficult. After I did Serenity, it was all these characters that had already been established, and we were trying to make it for people who hadn’t seen any of that, and I’m just like, ‘NEVER doing that again. That was so hard.’ Then I started writing this and I was like, ‘How stupid am I? How did I not know this was the same movie?’