October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How Patrick Trainer Used DuckDB-WASM to Build a Doom-Inspired Game in SQL

A browser-based Doom-inspired text game pushes SQL into game simulation and raycasting, without pretending JavaScript or a conventional game engine is obsolete.
WorldSQL Length3 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Patrick Trainer’s browser-based experiment puts the game world in DuckDB tables and uses SQL to calculate raycasts and draw an ASCII-style scene. It is a Doom-inspired text game, not a game engine written entirely in SQL: JavaScript still handles keyboard input, the asynchronous game loop, sprite work and the final display.

What the DuckDB-WASM experiment does

In his April 20, 2025 write-up, Trainer describes a 16×16 map alongside player position and direction, enemies, bullets and settings stored in DuckDB tables running in the browser. SQL statements update movement and collisions; DELETE operations can remove bullets or enemies. The design treats the database as more than a place to save data: queries participate directly in the game simulation.

As an Amazon Associate I earn from qualifying purchases.

DuckDB-WASM is an in-process analytical SQL database for browsers, powered by WebAssembly. DuckDB’s 2021 overview describes its browser architecture and use of web workers for query execution, as well as support for data sources including Parquet, CSV and JSON. That article is useful background on the project’s platform, rather than current setup instructions: DuckDB’s overview of DuckDB-Wasm.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How SQL draws the scene

The unusual part is the rendering query. Trainer uses a SQL VIEW with recursive common table expressions (CTEs) to cast rays, locate walls, calculate distances and combine text characters into rows for a frame. In broad strokes, the query performs the work that a conventional raycasting renderer would do to turn a grid map and a viewing direction into a first-person scene.

#1 Best Overall
DOOM Eternal: Standard Edition - PlayStation 4
  • Gain access to the latest demon-killing Tech with the DOOM Slayer's advanced praetor suit, including a shoulder-mounted flamethrower and the retractable wrist-mounted DOOM Blade
  • Upgraded guns and mods, such as the Super shotgun's new distance-closing meat hook attachment, and abilities like the double Dash make you faster, stronger, and more versatile than ever
  • You can't Kill demons when you're Dead, and you can't stay alive without resources. These tools are the key to your survival and becoming the ultimate demon-slayer
  • A new class of (destructible) demon
  • Battle mode is the new 2 versus 1 multiplayer experience built from the ground up at id software

The result is text-based rather than a conventional textured 3D image. Although Trainer calls it a “primitive, text-based Doom clone,” some Hackaday commenters felt the raycasting looked closer to Wolfenstein 3D. That is a useful distinction when describing its visual style: it is Doom-inspired, but the experiment’s grid-based raycasting evokes the earlier Wolfenstein-style approach.

What JavaScript still handles

SQL does not replace the browser game loop. JavaScript handles keyboard input, runs the asynchronous loop and sends queries to DuckDB. It also retrieves game entities, projects sprites, checks their visibility with a Z-buffer, and writes the finished text frame into a <pre> element. The project’s central trick is therefore a division of labor: SQL calculates important parts of the world and background rendering, while JavaScript connects player input, database work, sprites and display.

Rank #2
Sale
DOOM: The Dark Ages – Xbox Series X
  • Developed by id Software, DOOM: The Dark Ages is the prequel to the critically acclaimed DOOM (2016) and DOOM Eternal that tells the epic cinematic origin story of the DOOM Slayer’s rage.
  • In this third installment of the modern DOOM series, players will step into the blood-stained boots of the DOOM Slayer, in this never-before-seen dark and sinister medieval war against Hell.
  • A dark fantasy/sci-fi single-player experience that delivers the searing combat and over-the-top visuals of the incomparable DOOM franchise, powered by the latest idTech engine. With a customizable difficulty system, it’s the perfect entry point whether you’re new to the franchise or a long time fan.
  • As the super weapon of gods and kings, shred enemies with devastating favorites like the Super Shotgun while also wielding a variety of new bone-chewing weapons, including the versatile Shield Saw.
  • Experience the origin story of the DOOM Slayer’s rage in this epic, cinematic, and action-packed story.

Performance and implementation trade-offs

Trainer reported about 6–7 frames per second on a modern laptop, with the SQL raycasting view taking about 80–100 milliseconds to execute. Those are his observations on his setup, not an independent benchmark or a general performance guarantee for DuckDB-WASM. The figures help explain the experiment’s appeal and its limits: running substantial rendering logic as SQL is a striking demonstration, but the reported frame rate is not evidence that this is a practical rendering pipeline for a production game.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Trainer also recounts implementation friction in his project: browser WASM loading failures, SQL dialect differences (including AUTOINCREMENT behaving differently than expected), query-planner restrictions involving table functions, and overlapping asynchronous interval callbacks. His fixes included using DuckDB’s bundle helpers, sequences, restructuring a generated range and adding a processing lock. These are project-specific lessons, not guarantees about how every version of DuckDB-WASM will behave.

Rank #3
DOOM: The Dark Ages – PlayStation 5
  • Developed by id Software, DOOM: The Dark Ages is the prequel to the critically acclaimed DOOM (2016) and DOOM Eternal that tells the epic cinematic origin story of the DOOM Slayer’s rage.
  • In this third installment of the modern DOOM series, players will step into the blood-stained boots of the DOOM Slayer, in this never-before-seen dark and sinister medieval war against Hell.
  • A dark fantasy/sci-fi single-player experience that delivers the searing combat and over-the-top visuals of the incomparable DOOM franchise, powered by the latest idTech engine. With a customizable difficulty system, it’s the perfect entry point whether you’re new to the franchise or a long time fan.
  • As the super weapon of gods and kings, shred enemies with devastating favorites like the Super Shotgun while also wielding a variety of new bone-chewing weapons, including the versatile Shield Saw.
  • Experience the origin story of the DOOM Slayer’s rage in this epic, cinematic, and action-packed story.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the experiment is useful for

Trainer does not recommend this approach for a production game; he presents it as a learning exercise. The project makes several topics concrete by putting them together in a browser: SQL query optimization and execution planning, raycasting and 3D projection, asynchronous JavaScript, and the capabilities and limits of WebAssembly in the browser. The code and project details are available in Trainer’s DuckDB Doom repository; his account of the implementation is at hey.earth. Hackaday also covered the project at Hackaday.

Quick Recap

Bestseller No. 1
DOOM Eternal: Standard Edition - PlayStation 4
DOOM Eternal: Standard Edition - PlayStation 4
A new class of (destructible) demon
$27.49
SaleBestseller No. 2
Bestseller No. 4
Bestseller No. 5
DOOM + DOOM II (Limited Run Games #144) - for Playstation 5
DOOM + DOOM II (Limited Run Games #144) - for Playstation 5
DOOM + DOOM II on a region-free physical disc.; A new Deathmatch map pack featuring 25 maps
$44.48
Best Value
DOOM + DOOM II (Limited Run Games #144) - for Playstation 5
  • DOOM + DOOM II on a region-free physical disc.
  • Includes: DOOM, DOOM II, TNT: Evilution, The Plutonia Experiment, Master Levels for DOOM II, No Rest for the Living, Sigil & Sigil II, Legacy of Rust (a new episode created in collaboration by id Software, Nightdive Studios and MachineGames).
  • A new Deathmatch map pack featuring 25 maps
  • Total of 187 mission maps and 43 deathmatch maps in DOOM + DOOM II
  • # of Players: Single System 1-4, Local wireless 1-8, Online 1-16
Rank #4
Doom - Xbox One
  • A Relentless Campaign: There is no taking cover or stopping to regenerate health as you beat back Hell's raging demon hordes
  • Return of id Multiplayer: Dominate your opponents in DOOM's signature, fast-paced arena-style combat
  • Near-Limitless Gameplay: Doom SnapMap – A Powerful, but Easy-to-Use Game and Level Editor That Allows for Limitless Gameplay Experiences on Every Platform
  • Entertainment Software Rating Board (ESRB) Content Description: Blood and gore, intense violence, strong language

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.