TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Doom Inside an SVG

69 pointsby chrisdalke7 months ago

5 comments

chrisdalke7 months ago
I got nerd sniped by a tweet talking about JavaScript in SVG, and set out to find out if I could run DOOM inside an image. And it works, with some caveats.<p>This is <i>technically</i> an SVG that plays DOOM, including audio and interactivity. Pretty cool, although I&#x27;m not sure who had the bright idea to allow Javascript in SVG...<p>The SVG is just using &lt;foreignObject&gt; to create an HMTL namespace, creating a canvas, and then running js-dos &#x2F; DOSBox in the canvas.<p>The big caveat, probably a good thing, is that JavaScript in SVG only works if you load the SVG directly and not inside an &lt;img&gt;, since browsers block this as an XSS prevention.<p>So this is not portable and can&#x27;t be embedded in a webpage, but I guess was a fun use of a few hours...
评论 #41902071 未加载
anthk7 months ago
Heh, first the ZMachine runs under a PostScript file with the GhostScript interpreter, now this.<p>But this is a bit of cheating, because it&#x27;s spawning HTML+JS inside a SVG as a foreign interface in a browser.<p>zmachine.ps has the whole interpreter in the PS file itself, as it&#x27;s a Turing Complete language. Yes, you can play Zork on it.
8mobile7 months ago
one word, exceptional. Kudos for just thinking that. Doom is a classic and deserves this.
logicallee7 months ago
For me, this works on iPhone after tapping the svg and waiting a bit. It runs through a demo in this mode (since there is no mouse or keyboard) and is very impressive! It includes sound as well!
lovegrenoble7 months ago
Crazy idea, i like it