You are in a hospital room at sunset, the angular light casting long shadows across the blue and green walls. You’re wearing glasses and a rumpled green shirt, and your demeanor — even in this rough-hewn, pixelated form — is exhausted. You carry yourself as though you’ve got too much on your shoulders. Which you do.

Somewhere in this animated hospital room, a baby cries. Your baby.

The light fades, and the wailing gets worse. You can’t see your son, but you can hear his screaming — the terrible, animal howl of a child in so much pain. You click around the room, searching desperately for something that will soothe a small child dying of cancer — you bounce him, you feed him juice. “Shh Joel,” you say, “Shh.” But nothing works.

You slump in the chair, defeated. And you pray.

“Oh, God, I want him here with me,” you say. “Please.”

The crying stops. Joel is asleep, at peace — for the moment. The screen fades to black.

This is a scene from Ryan Green’s intimate and innovative new video game “That Dragon, Cancer” — a gut-wrenching exploration of what it’s like for a family to lose their young son to a terminal illness — which was released Tuesday.

But it’s also a scene from Green’s own life. It’s the experience that, four years ago, formed the kernel of the idea that would become “That Dragon, Cancer.” Not because of how much it resembled a classic video game — all vanquishing enemies and navigating perils — but because of how much it didn’t.

“At first [Joel’s diagnosis] was an adventure and I could be this caring father … this hero who was going to help fight the disease,” Green said Monday night, hours before the game’s release. “But there are parts of our lives where there’s just nothing we can do. We don’t know the answers. And that’s where we receive help.”

The scene in the hospital room was the one time in his life that Green — a devout Christian — had prayed and felt like he’d gotten a direct reply.

“It was a moment of grace,” he said, simply. “And I wanted to share it with people.”

Joel Green was diagnosed with an aggressive brain tumor in 2010, not long after his first birthday. He died on March 13, 2014, at age 5.

In between were the four most harrowing years that his parents, Amy and Ryan Green, had ever experienced. Turning those years into a video game was a way of preserving their memories of their beloved son, the profound and painful moments as well as all the mundane miracles of a small child’s life. It was a way of honoring Joel, of marking his presence in a world he barely got to see himself. And it was a way to give some narrative order to cancer’s chaos, to turn the story of a failed fight to slay a dragon into a message about grace.

Over the course of 14 five-to-10 minute episodes, players are introduced to Joel and guided through stages of his life and death from cancer. The animation is vivid but abstract. The character’s voices come from home videos or taped sessions in a studio. Baby Joel’s infectious giggle comes from recordings of Joel himself.

In one chapter, the player pushes Joel down the slide at a playground while the little boy laughs and laughs. In another, you watch as Amy and Ryan are shown an MRI of their son’s tumor, listen as they’re told that the prognosis is not good. Sometimes there’s something for the player to do — navigate a go-cart around a hospital hallway; direct a tiny Joel, dangling from balloons made of blown-up surgical gloves, as he wends through prickly projectiles representing his cancer.

The game most resembles a traditional video game during the chapter in which Ryan and Amy explain Joel’s illness to their other kids. It’s called, “Joel the baby knight.” Using the arrow keys, the player evades flaming fire balls and slays vicious beasts while journeying to slay the dragon called Cancer.

But mostly there’s a lot of watching and experiencing, letting emotion wash over you as you witness a family confront a child’s death, waiting for a moment of grace.

Green and co-developer Josh Larson started working on the game a year and a half before Joel passed away. They’d met online and bonded over a shared interest in nontraditional, spiritual games, ones less oriented toward risk and reward and more focused on cultivating empathy. The duo had built a few short projects together, but they were saving up for something bigger.

In November 2012, in the tearful scene in the hospital, almost two years old but still fresh in Green’s mind, he suggested to Larson: “Why not Joel?”

They started with a demo of that hospital scene: Ryan fruitlessly seeking to soothe the crying Joel, growing more and more desperate as the baby’s wails grow louder and louder. They brought it to a bunch of video-game conferences, not expecting much but hoping to find a financial backer or two.

The response was instantaneous and enormous.

“We will all meet this thing, or have already met it,” wrote game writer Jenn Frank after playing the demo at a 2013 conference in San Francisco. “Maybe that should be scary, but ‘That Dragon, Cancer’ is about sustaining the hope and joy of life for just as long as we can.”

Larson and the Greens got their funding, and “That Dragon, Cancer” became a cause celebre in the indie gaming world. It was the focus of a documentary, “Thank You for Playing.” It was written up on gaming sites and in the New York Times.

Meanwhile, Joel was not getting better. He would experience 15 tumors and nine rounds of radiation before ultimately succumbing to cancer two months after he turned 5.

After Joel died, there was no question that Green and Larson would keep going with their project. But they scrapped half their storyboard and changed the game’s focus. It would be less linear, less about narrative, less centered around moving through levels of play. And it would be more about Joel: being with him, watching him laugh, getting to experience what he loved.

“It was kind of this overwhelming desire to want to spend time with him again,” Green said.

During the excruciating months that followed, “That Dragon, Cancer” offered some sense of purpose and continuity amid the ache of Joel’s absence. It was the one thing in the Greens’ life that didn’t change with his death.

But now, even that source of solace has come to an end. Nearly two years after Joel’s death, on the day he would have turned 7, the Greens are celebrating with the release of their game and a birthday party of sorts. They’re asking friends and fans to share their experiences of the game, as well as their own stories of love and loss. They also encourage people to eat pancakes for dinner Tuesday night. Pancakes were Joel’s favorite food.

For Green, who has been pulling 80- to 90-hour weeks for the past few months to get the game ready for launch, there hasn’t been much time to contemplate what life will be like after “That Dragon, Cancer” — that last little piece of his son — has been released into the world.

But when he does pause, he feels fear, he says, fear that finishing the game will be like losing Joel all over again.

“I’ve spent so much time mourning Joel,” he said. “Remembering him, honoring him and building things for him. And the deep grieving — I almost wonder if I’ve put that off a bit.”

Green breathes, coughs — among other things, the long hours have him feeling under the weather. “I’m ready to be done. But it’s also scary because I think I might grieve in a new way.”

Nevertheless, Green is eager for this deeply personal project to become public, to hear from people who have played the game and connected with it in some way. Already, he’s gotten countless messages from strangers who were touched by his story. Razer Inc., the company that helped develop “That Dragon, Cancer,” announced Monday it will be donating much of the proceeds from its sales of the game to the Morgan Adams Foundation and the Family House SF, two cancer nonprofits that helped the Greens during Joel’s illness. The company is also hosting a pancake breakfast for all 600 of its employees on Tuesday, Green said.

Asked what he wants people to take away from the game, Green dreamed big.

“I hope that people allow it to change them,” he said. “Us inviting you as a friend into what we’ve gone through, it will allow you to share in our pain, but also share in our comfort. … I think that can take us really far. It can change how we treat each other, change how we talk about each other. Joel’s story can have such rippling effects, if we start with our hearts.”

He paused, then laughed.

“Everybody wants their child to change the world,” he continued. “I have unreasonably high hopes, just like any proud father would.”