Duke Nukem 1’s collision detection

So far, we’ve looked at how the game renders its world and the characters and objects inhabiting it. But one key ingredient is still missing in the engine layer: There’s not much gameplay to be had if objects can’t interact with each other and the world. For that, we need collision detection. And just like rendering, it has its fair share of quirks in this game.

Duke gets hit by an enemy
Continue reading “Duke Nukem 1’s collision detection”

Duke Nukem 1’s sprite rendering

Last time, we looked at how the game renders its world – background and tiles. What really brings the game to life though are the sprites drawn on top. Almost everything interactive in the game is represented using sprites: Duke himself, enemies, pickups, doors, force fields, laser blasts, floating score numbers, explosions, etc.

In this post, we’ll have a closer look at how these things are rendered.

Continue reading “Duke Nukem 1’s sprite rendering”

Duke Nukem 1+2 Remastered

Duke Nukem 1 and 2 are getting an official remaster for the Evercade platform, and I was lead developer on the project. Here’s the official showcase video with an overview of all the new features:

And the announcement trailer:

If you’ve seen or used RigelEngine before, some of the new features will sound familiar – the project is in fact based on RigelEngine. But it very much goes above and beyond what the open-source version can offer, with additional features, a completely new menu system, new music and artwork, and of course the biggest one, a remaster of Duke Nukem 1 with the same enhancements and quality of life improvements as Duke 2.

Continue reading “Duke Nukem 1+2 Remastered”

RigelEngine v0.9.1 released

This release fixes a lot of bugs and inconsistencies with the original, adds demo playback, missing menu animations, and a new “Classic” mode based on my 100 % accurate source code reconstruction. The idea with this mode is to replicate all the bugs and quirks of the original perfectly, at the cost of not all enhancements being available (currently). See the full release notes on GitHub.

Continue reading “RigelEngine v0.9.1 released”

Full Duke Nukem II source code recreated

I’m still working on an in-depth post about this, so this is just a quick update: I’ve created a full recreation of Duke Nukem II’s entire source code. Unlike RigelEngine, this is targeting MS-DOS just like the original. Compiling it using the original toolchain produces a binary that’s 100% identical (matching hash) to the original one. Here’s an era-appropriate 486 66 MHz PC compiling the game:

There are more details in the GitHub repo’s README, and I also wrote a Twitter thread about the project.

I’ve also started work on integrating this code into RigelEngine, as an alternative “Classic” gameplay mode which is 100% accurate to the original. This finally makes it possible to accurately play back the game’s demo in RigelEngine:

This integration work is still in progress, but I expect to merge it to RigelEngine’s main branch pretty soon.

How Duke Nukem II’s parallax scrolling worked

Parallax scrolling – creating an illusion of depth in a 2D scene by having the background and foreground move at different speeds – is pretty much a staple of platformers and other 2D games nowadays. Popularized by the arcade game Moon Patrol in 1982, the effect was already quite common on arcades and home consoles by the early 90s. But PC games were a different story. Among the side-scrolling DOS games released from 1990 to 1993, very few have parallax scrolling (by 1993, it becomes a little more frequent, but still rare). There are also some very early examples, like the PC port of the aforementioned Moon Patrol from 1983, but it features only an outline of a background, not a graphical image. So by having this feature, Duke Nukem II stands out among Apogee’s catalog of platformers, along with its predecessor Duke Nukem from 1991 and the 1992 game Cosmo’s Cosmic Adventure (which shares a lot of code and file formats with Duke 2).

Duke Nukem II’s parallax scrolling in action

It’s worth noting that the vast majority of early Apogee games targeted EGA, to make the games accessible for people with older hardware (VGA is backwards compatible with EGA). Early DOS games featuring parallax scrolling were typically VGA games, and that’s for good reasons, as we’ll see.

Duke Nukem is kind of a hybrid. It requires a VGA card and features some 256-color scenes, but all the gameplay itself is using a 16-color EGA mode, just using the VGA palette to achieve custom colors that aren’t possible on EGA. But the rendering engine itself is still fundamentally EGA-based, and the game does in fact run on EGA cards – just with incorrect colors.

Before we dive into Duke Nukem’s implementation of the effect, let’s take a look at why parallax scrolling was generally hard to do in EGA games.

Continue reading “How Duke Nukem II’s parallax scrolling worked”

Video series: Refactoring 19-year old C++ code

I’ve started a video series on refactoring old C++ code. The goal is to provide practical examples for untangling and improving messy legacy code, while using a real code base instead of isolated toy examples. Concretely, I’m working with a 19-year old game project I did back in highschool, and improving the code.

Check out the YouTube playlist (I’ll add new videos as I publish them):

Continue reading “Video series: Refactoring 19-year old C++ code”

RigelEngine v0.8.4 released

The latest release improves the new smooth scrolling and motion mode by fixing a few issues and making moving level geometry smooth as well (falling rocks, crumbling platforms, doors etc.). This required a major overhaul of the map rendering code, which I’m planning to write a dedicated blog post on at some point. See it in action here:

As usual, there are other improvements and bug fixes as well. Most notable is a change to the HUD in widescreen mode. The HUD is shifted to the right in widescreen mode, which leaves a gap to the left of the HUD. Originally, this gap revealed more of the level. As of the latest release, it just shows a solid color instead.

Continue reading “RigelEngine v0.8.4 released”