Michelle Monaghan and Jake Gyllenhaal star in the mind-bending sci-fi fantasy Source Code, now playing at the AMC Van Ness and the Regal Jack London in Oakland.

Jake Gyllenhaal is no stranger to working with mad scientists – or, at least, mad science. It was a decade ago that he played schizophrenic teen Donnie Darko in Richard Kelly’s memorably offbeat feature about wormholes, time travel, a diabolical rabbit and an impending apocalypse.

Now Gyllenhaal, 30, is back on semi-familiar ground, playing Air Force Colonel Colter Stevens, badly wounded in the Middle East but kept alive as the star guinea pig in a top-secret – aren’t they all? – government experiment. The movie is Source Code, the second offering (after 2009’s Moon) from sci-fi surrealist Duncan Jones.

As in Darko, the Los Angeles-born son of director Stephen Gyllenhaal and writer-producer Naomi Foner (Losing Isaiah) is once again navigating alternate realities, this time to gather information crucial to preventing a terrorist attack. It’s the kind of story that keeps you guessing, not only about what’s going to happen, but whether what has already happened follows the movie’s own rules.

Don’t worry, you’re not alone. “First and foremost, I needed to know that the science was at least conceptually logical,” Gyllenhaal says of Code, which opened Friday at the AMC Van Ness. “The ideas had to make sense enough that I bought it, ‘cause movies like this sometimes veer off in an absurdist way. But the story is solid scientifically, even as it raises interesting questions on a philosophical level.”

Gyllenhaal trusted his instincts in pursuing Code as much as he did in recommending Jones, 39, to direct. Impressed by Moon, in which the son of rock legend David Bowie directed Sam Rockwell to a tour-de-force performance as an astronaut stuck on an endless mission worthy of Major Tom, Gyllenhaal saw Jones as a “cosmic” fit for the material.

Did he consider Kelly? “I thought Duncan might not do it because he writes the things he wants to direct, and Richard is the same way,” he says. “Richard is always doing something odd, but Duncan kept coming up to me saying, ‘Make it weirder.’ Maybe Richard’s stuff is already too inherently weird.

“As a person, Richard is more mysterious than Duncan. With the press, Duncan is so outgoing, but when he’s on set, he reminds me of Ang Lee. He’s very quiet. He hardly says a thing, and when he does, it’s very simple and specific. You’d think English was his second language, but it’s not. Being British, he’d probably argue it’s our second language.”

Gyllenhaal credits Jones with being open to creative input, to the extent that the director shot an alternate ending that Jake suggested on a whim. The actor, who describes himself as being “a little out there,” attributes his enthusiasm to his passion for the story, in which his character is repeatedly thrust into catastrophic scenarios, with only minutes to stave off disaster.

“Obviously this is entertainment, but I hope there’s a 13-year-old kid who sees this movie and it inspires him to invent something like [the source code],” he says. “It’s weird, wishful thinking. But if I had only had a minute to live, I think I’d call my family and try to have a good laugh. It’s nice to laugh entering and nice to laugh exiting.”