一个开源项目实现了将经典游戏DOOM完整运行在Firebird SQL数据库内的壮举1。该项目通过将Firebird 6编译到WebAssembly,使得整个游戏能够完全在浏览器中执行1。游戏的每个逻辑帧由SQL存储过程调用驱动,每一帧的渲染则通过SELECT查询返回,JavaScript仅负责处理键盘输入和绘制画面1。
项目支持加载真实DOOM游戏的WAD文件,包括DOOM1.WAD、DOOM.WAD和DOOM2.WAD1。开发者在PSQL中使用VARCHAR存储每个屏幕列的solidsegs列表,通过CROSS JOIN LATERAL或LEFT JOIN等优化技术,将帧渲染时间从65秒大幅降低至0.2秒1。该实现配备了两种墙壁渲染器——BSP和暴力法,其中BSP渲染器在Freedoom的36张地图上的性能约为暴力法的3倍1。
为进一步提升性能,项目提供了低细节模式选项,可将屏幕列数降至160列,接近原始DOOM的配置1。在测试中,最繁忙的帧需要42个visplanes,仍低于原DOOM的128个MAXVISPLANES限制1。
An open-source project has achieved the remarkable feat of executing the classic game DOOM entirely within a Firebird SQL database compiled to WebAssembly, running directly in a web browser 1. The implementation leverages the database's native capabilities to handle both game logic and rendering, with each game frame driven by a stored procedure call and frame rendering returned through a SELECT query 1. JavaScript handles only keyboard input detection and screen drawing, leaving all computational work to the database engine 1.
The project supports authentic DOOM maps and offers two rendering approaches: a BSP renderer and a brute-force algorithm 1. Performance optimization has been substantial—through the use of CROSS JOIN LATERAL and LEFT JOIN techniques, rendering time was reduced from 65 seconds to 0.2 seconds 1. The system stores rendered column data as VARCHAR strings in PSQL, with one character per screen column 1. A low-detail mode operating at 160 columns, mirroring the original DOOM's resolution, further improves performance 1. Custom WAD files from DOOM, DOOM II, and Freedoom can be loaded, with testing on Freedoom's 36-map collection showing the BSP renderer performing approximately three times faster than the brute-force method 1. The most demanding frames during testing required 42 visible planes, comfortably within the original game's 128-plane limit 1.
评论
还没有评论,欢迎留下第一条。