/chocolatekeen

Chocolate Keen is a reverse engineering of Commander Keen in C/C++ and SDL. The goal is to be super accurate versus the original

Primary LanguageC

Chocolate Keen

Chocolate Keen is a reverse engineering of Commander Keen in C and SDL. The goal is to be super accurate versus the original

How to Play

  • You can play directly in the browser! Click here
  • If you want to download and play offline, see the Releases section below

Controls

  • Arrows - Move Keen around
  • Ctrl - Jump
  • Alt- Use Pogo/Stop Pogo (if you have one)
  • Ctrl AND Alt - Fire raygun (if it has charges)

Releases

Downloadable game packages available in Releases. All versions come packaged as zip files with game data. Just extract and run. On Linux, you'll need the SDL 2.0 runtime installed. Other versions come pre-packaged with SDL

Episodes Two and Three

The downloadable releases above come packaged with Commander Keen "Invasion of the Vorticons" Episode One: Marooned on Mars. But the engine supports the entire Vorticons trilogy. If you have Episode Two or Three, drop the level/data files into the GAMEDATA folder as follows:

.
├── chocolate-keen.exe
└── GAMEDATA
    ├── KEEN1
    |   └── ... Episode One level data (pre-packaged)
    ├── KEEN2
    |   └── ... Episode Two level data
    └── KEEN3
        └── ... Episode Three level data

You can then start each episode via chocolate-keen.exe -startkeen1, chocolate-keen.exe -startkeen2 and chocolate-keen.exe -startkeen3 respectively

Building

You can clone or download the chocolatekeen repo and build it yourself

Linux

For Linux builds you'll need a C compiler (e.g. gcc) and toolchain. The setup varies between distros. For Ubuntu you can install the build-essential package via sudo apt-get install build-essential. Once you have that setup:

  1. Install the SDL 2.0 development libraries. This varies between Linux distros. For Ubuntu it's sudo apt-get install libsdl2-dev. More info here
  2. Launch a shell
  3. Navigate to /build/linux
  4. Run ./build_linux.sh

WebAssembly

To build for WebAssembly, you'll need the Emscripten SDK. Find setup instructions here

  1. Launch a shell with emscripten build tools (emsdk) in the PATH
  2. Navigate to /build/emscripten
  3. Run ./build_emscripten.sh

Windows (MinGW)

This is a Makefile project. To build for Windows you'll need something like MSYS2 and a gcc toolchain. Find setup instructions here

  1. Download and unzip SDL 2.0 development libraries: https://www.libsdl.org/download-2.0.php
  2. Launch a UNIX shell
  3. Navigate to /build/MingGW
  4. Run build script that corresponds to your platform:
  • Windows x86:
    • ./build_mingw32.sh /path/to/SDL2
    • e.g. ./build_mingw32.sh /d/Development/SDL2-2.0.9/i686-w64-mingw32/
  • Window x64:
    • ./build_mingw-w64.sh /path/to/SDL2
    • e.g. ./build_mingw-w64.sh /d/Development/SDL2-2.0.9/x86_64-w64-mingw32/

Windows (Visual Studio)

Build and Debug with Microsoft Visual Studio / Visual C++

  1. Navigate to /build/Visual C++
  2. Open Solution file (ChocolateKeen.sln) in Visual Studio
  3. Restore NuGet dependencies (Project -> Manage NuGet Dependencies > Restore)
  4. Build (Build > Build Solution)
  5. Run (Debug > Start Without Debugging) or Debug (Debug > Start Debugging)

Game data is automatically copied to the Target Directory as part of build - so everything should "just run"

Authors

The original authors of Chocolate Keen are NY00123, QuantumG and Lemm. The project started with a reverse engineering of the original Keen code, and the goal is complete authenticity to the original - bugs and all. For more info see https://pckf.com/viewtopic.php?f=4&t=2536

Since bringing this to GitHub, I've ported to WebAssembly and I intend to support other platforms too

Developer Notes

WebAssembly Notes

Performance

The WebAssembly build of Chocolate Keen relies on Emterpreter. This hinders performance significantly vs using Emscripten loops. If you don't have a sufficiently fast machine you may notice audio stutters or frame skips

Graphics

Although the original game supports both EGA and VGA graphics modes, the WebAssembly build is hardcoded to VGA. The original game resolution is 320x200, which is internally scan-doubled to 320x400. The x-axis is then doubled also to preserve the aspect ratio, yielding 640x400. Once overscan borders are added, the internal game resolution jumps to 672x414. This is rendered into the HTML canvas to provide a pixel perfect image, and then aspect-ratio corrected to 4:3 via CSS

Some parts of the game (initial load and exit screen) use VGA text mode. Internally this renders at 720x400 (or 736x414 with overscan) and is nearest-neighbour downsampled to the game resolution of 672x414. It looks ugly, but we have to live with this for now to preserve crisp game visuals