This sounds like *Rodomonte's Revenge (World of Adventure)* by Gary Paulsen. I read this ages ago.

Anyway, a synopsis from the [Barnes & Noble website][1]:

> As Brett watched, one hand slipped loose, then the other. Tom dropped, screaming, into the flames. His body, all red and bubbled, boiled up once to the surface, then was gone.
PLAYER ONE HAS ONE LIFE REMAINING. GAME CONTINUES.
 
>Flaming fire rivers. Divebombing buzz-bugs. A cruel king waiting to do battle in his computer-generated castle. Video game whizzes Brett Wilder and Tom Houston think that new virtual reality game Rodomonte’s Revenge is awesome-until it takes over their minds. Then the game playing becomes dangerously real, and one wrong move could be the last.

[![Rodomonte's Revenge][2]][2]

  [1]: http://www.barnesandnoble.com/w/rodomontes-revenge-gary-paulsen/1008772190
  [2]: https://i.sstatic.net/soD1r.jpg