Updated 2023-05-11: I added additional steps to get it to run on shinyapps.io.
Motivation
I’ve been playing with the idea of running Doom on Shiny for a while. If Doom runs “everywhere”, it must run on Shiny, right?
Doom was released in 1993 and since then it has been ported to many different platforms including:
The result
I was able to run Doom on Shiny!
Here is the result on shinyapps.io.
I have uploaded a short demo to YouTube. In some countries the video is only for +18 audiences because of the original game parental advisory.
Here’s a picture of the game running on Shiny:
How it works
I created what I think is a simple Shiny app that I released on GitHub.
Here is the code:
library(shiny)
library(httpuv)
# Define the path to the directory containing your Doom game files
<- "./doom-wasm/src"
doom_directory
# Start a server to serve Doom files
startServer("127.0.0.1", 1234, list(
call = function(req) {straightforward
<- paste0(doom_directory, req$PATH_INFO)
filePath if (file.exists(filePath)) {
return(list(
status = 200,
headers = list(
"Content-Type" = "text/html"
),body = readBin(filePath, "raw", file.info(filePath)$size)
))else {
} return(list(
status = 404,
headers = list(
"Content-Type" = "text/html"
),body = "File not found"
))
}
}
))
<- fluidPage(
ui $h1("Doom in Shiny"),
tags$p("Space: fire; E: open door; up/down/left/right: move; 1-4: change weapon; Esc: release mouse/go to menu; F: full screen"),
tags$iframe(style = "width:850px; height:640px;", src = "http://127.0.0.1:1234/index.html")
tags
)
<- function(input, output, session) { }
server
# Run the Shiny app
shinyApp(ui, server, options = list(port = 4321))
To run the app, you need to build Doom from source. The same repository contains the instructions.
If you like what I do as a content creator, you can donate on Buy Me a Coffee.