TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Doom Inside an SVG

69 点作者 chrisdalke7 个月前

5 条评论

chrisdalke7 个月前
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 个月前
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 个月前
one word, exceptional. Kudos for just thinking that. Doom is a classic and deserves this.
logicallee7 个月前
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 个月前
Crazy idea, i like it