When Mojang approached him to write a Minecraft novel in fall 2015, Mr. Brooks already had a track record as a best-selling author. The son of the actor Mel Brooks and the actress Anne Bancroft, Max Brooks turned to fiction after a brief and unremarkable career in comedy writing, which included a stint as a writer for “Saturday Night Live.”

After he was fired from the show, he started writing chillingly realistic zombie fiction and found his calling. Two of his previous books, “World War Z” and “The Zombie Survival Guide,” have collectively sold more than 3.5 million copies, and “World War Z,” a faux oral history about the aftermath of a zombie apocalypse, was adapted into a feature film starring Brad Pitt.

Other successful authors might have brushed off an invitation to write a video game tie-in novel, an unabashedly commercial genre that some say amounts to little more than elaborate product placement. But Mr. Brooks happens to be an avid Minecraft player and jumped at the opportunity. He was determined to write a story that mirrored the experience of playing the game. He developed a plot that conformed to the Minecraft universe so closely that someone reading the book could recreate the narrative within the game and play along.

“I war-gamed out everything,” Mr. Brooks said in a recent interview from his home in Los Angeles. “My biggest fear was that somebody tries to play out my book and finds out it won’t work.”

In the process, he may have also created a strange new entertainment category, one that hovers somewhere between fan fiction, role-playing games and literature — a novel set in a game, that can itself be played within the game.

Like reverse adaptations of movies and TV shows (see, for example, novels based on “Buffy the Vampire Slayer” and “CSI”), novels based on gaming franchises have long been a lucrative niche within the publishing industry.

Publishers have been releasing novels based on popular video games for decades, hoping to capture a slice of the medium’s huge fan base. Gallery Books, an imprint of Simon & Schuster, has published fictional series based on games like Halo, Doom and World of Warcraft, and has millions of copies of its video game tie-in novels in circulation. Other publishers have built fictional franchises based on games like Gears of War, Starcraft, BioShock and Tomb Raider.