Numerous works of fiction use the premise of a character stuck inside a game (including a few holodeck episodes in the various STAR TREK series). If you enjoy that kind of thing, try the Japanese "light novels" (a generic label based mainly on books' length, not the "light" or "dark" tone of their stories) in the "Sword Art Online" series by Reki Kawahara. In the first sub-series, the protagonist, Kirito, one of the beta testers for a cutting-edge virtual reality game, gets trapped inside the game world along with hundreds of other players who log in on release day. The game designer has fixed it so that nobody can log out, and anyone who dies in the game dies for real because of the way the creator covertly rigged the brain-machine interface. Thanks to Kirito's experience as a beta tester, he becomes one of the survivors. The main appeal of this story lies in his Intimate Adventure journey from his original stance as a self-reliant loner to friendship with a fellow player, Asuna, and ultimately to deep mutual love with her. The game, Sword Art Online, feels like a three-dimensional, physical experience in most ways but with many game-based factors. For instance, getting injured drains points but doesn't cause true pain. So, despite the total immersion effect, because of details such as this the players have no trouble remaining aware that they're playing a game.
The latest sub-series, which I'm reading now, introduces Kirito to a new VR system that's far advanced over Sword Art Online. The new game, still in the testing phase, simulates the physical world in such extreme detail that the environment can't be distinguished from reality. When Kirito inexplicably wakes up in this environment with no memory of how he got there (no awareness of returning to the test facility, logging in, etc.), he feels hunger, thirst, fatigue, and pain as if in his real body. The only way he can confirm his guess that he's inside a hitherto unexplored version of the game is by opening status windows for objects in the environment. To the people he meets, these windows are simply a form of magic, "sacred arts."
If such a virtual world existed, simulating the primary world in the finest details, how could you know (unless you could access game features such as status windows) whether you were in a real environment or a fictive one? Would there be any way to prove either hypothesis? Furthermore, if you experienced all the effects of living in normal reality, would it make any difference whether you were or weren't?
This scenario brings to mind the problem of solipsism, the one view of the universe that's impossible to refute. If I believe all people and objects I observe are figments of my imagination, how could you refute that belief? The fact that things I can't control and/or don't enjoy happen around me doesn't provide a valid counter-argument, because uncontrollable and unpleasant events often happen in dreams, too. The solipsist hypothesis is completely untestable. Robert Heinlein seems fascinated with this world-view. One of his classic works has a protagonist who (thanks to time travel) is all the characters in the story, including his/her own father and mother. It ends with the chilling sentence, "I know where I came from, but where did all you zombies come from?" I've read a short story (can't recall author or title) set on an interstellar spaceship, in which one character begins to doubt that his memories of Earth are real. Maybe he and his crew mates have always been on the ship? He deteriorates from doubting the reality of Earth to believing that the other people on the ship cease to exist when not in his immediate presence. In THROUGH THE LOOKING GLASS, Alice ponders whether the sleeping Red King is a character in her dream or she's a character in his.
If "All that we see or seem is but a dream within a dream" (Poe), how would we know that? If we live within a perfect three-dimensional, multi-sensory simulation, we can't confirm or refute that possibility unless we can somehow get outside the simulation. As I read in some philosophy course long ago, "A difference that makes no difference is no difference." So it makes sense to operate on the working hypothesis that the universe and all its inhabitants actually exist.
By the way, I've written one "trapped inside a game" story, which appears in the collection DAME ONYX TREASURES, here:Dame Onyx Treasures
Margaret L. CarterCarter's Crypt