G-Engine #1: Introduction

“G-Engine” is a hobby project I’ve been kicking around for awhile. In December 2017, I finally took the dive and started in on it. This post (and those following it) document my progress and what I’m learning as I develop it.

At its core, the idea is to build a 3D game engine in C++. But building a game engine without also building a game can be difficult to do. So, for me, my goal is to use the engine to recreate a video game I’m a fan of: 1999’s Gabriel Knight 3 from Sierra Studios.

This post provides a background of how I came to focus on this project over the course of many years. It also provides an overview of what the project is and why I’m pursuing it.

The Gabriel Knight Series

Before diving into why I am interested in writing this engine, it might be helpful to review the history of how I got here. This is in large part due to the game series that I enjoyed playing so much as I was growing up. For those who are unfamiliar with the series, or who want a quick refresher, read on.

Gabriel Knight is a series of point-and-click adventure games developed by Sierra On-Line from 1993 to 1999. These days, Sierra is most remembered for their popular and iconic “Quest” adventure games, such as King’s Quest, Space Quest, Police Quest, and Leisure Suit Larry.

Sierra Logo

These games developed followings for their personalities, stories, and characters. They were also notorious for their difficulties and the unexpected/gruesome/funny ways you could die if you performed the wrong actions. Though the puzzles were difficult, and failure was common, they were fun.

The Gabriel Knight series is sometimes overlooked amongst Sierra’s extensive catalogue, but it is certainly my favorite (Space Quest is a close second). For me, the stories, graphics, characters, music of this series represent a high quality bar for Sierra’s output.

Gabriel Knight: Sins of the Fathers (1993)

The first entry, Gabriel Knight: Sins of the Fathers, is a critically acclaimed 2D murder-mystery adventure game released in 1993, when Sierra was at the height of their popularity and innovation in the games industry. In my opinion, it is the most masterful 2D point-and-click adventure game ever made. It was one of the last games Sierra made in their “classic” 2D style before starting to experiment with first-person, FMV, and 3D.

GK1 Gameplay

The game follows the eponymous Gabriel Knight, a struggling author in New Orleans’ French Quarter. Gabe’s suffering from intense nightmares, perhaps onset by the research he’s doing for a new novel about Voodoo. At the same time, a series of ritualistic murders have occurred in the New Orleans area, which seem like relevant material for his new book. In the course of his research, he stumbles into a dangerous Voodoo underworld and discovers that dark forces at play in New Orleans are linked to his own family’s haunted past. His assistant, Grace, becomes an unwilling accomplice. His buddy at the police department, Detective Mosley, is a useful source of insider info for his new book. By the end of the story, Gabriel discovers that his family line had a long history as “Schattenjägers”, or shadow hunters.

One thing this game does quite well is to blend real-world locations and facts with supernatural fiction. It uses the actual history of New Orleans to tell a compelling story of good vs. evil, ancient Voodoo curses, and a powerful family using Voodoo to secretly pull the strings in modern day New Orleans. The game was a critical and commercial success, so of course a sequel was on the way.

Gabriel Knight: The Beast Within (1995)

The second game in the series, The Beast Within, was released in 1995. Right around this time, the game industry was being heavily influenced by the sudden availability of streaming video on home PCs. A couple games, like the 7th Guest and Myst, used this technology to become smash hits. The result was a number of games experimenting with the use of real-life photography, video, and live actors. Included in this trend was GK2, which made the leap from hand-painted 2D to what is known as full-motion video (or FMV). Looking back, the results are not bad, but they also haven’t aged super well. To a modern game player, it must certainly seem bizarre!

GK2 Gameplay

At the time, it seemed that the future of games and interactive storytelling was to record live actors in interactive scenarios. In hindsight, this was a game design misstep, often resulting in limited interactivity and poor-quality acting and production design. Despite GK2 being made in this style, it is often touted as one of the successes of the format.

In this entry, Gabe must grow into his role as a shadow hunter as he investigates a series of animal attacks in Germany that may be related to Werewolves. New to this entry is the ability to play as Gabriel’s friend and assistant, Grace.

As with the first game, this game uses real-world locations and history to build a compelling supernatural mystery. The history of Bavaria, Mad King Ludwig, and Richard Wagner, as well as myths and legends surrounding werewolves, are used to spin a tale of primal instinct, fighting to stay human, and control the beast within! At the time of this game’s release, adventure games were still popular, and the game was both critically and commercially successful. Given Sierra’s penchant to create six or more sequels in a particular game series, a third entry was only natural.

Gabriel Knight 3: Blood of the Sacred, Blood of the Damned (1999)

The third and final entry in the series was released in 1999. It was a turbulent time for adventure games. After FMV games failed to make the grade, 3D was the next big trend in gaming, and frenetic first-person shooters dominated the market. To many gamers, the design of adventure games suddenly seemed antiquated and tedious. Adventure games often did not do themselves any favors, sometimes favoring arbitrary and logic-free puzzles over enjoyable gameplay experiences. Some high-profile adventure games, such as Grim Fandango, were released to good reviews and poor sales. Making an adventure game was suddenly considered a bad business decision.

At the same time, Sierra was undergoing a huge transition as a studio. Its original owners retired and sold the company. Employees were laid off and games were canceled. The studio would begin its descent from PC gaming titan to defunct studio. Some high profile sequels, such as Space Quest 7, were canceled. King’s Quest 8 was released, but fans complained that it didn’t retain the spirit of its predecessors, since it had more action-oriented gameplay to attract mainstream players.

As all that was happening, Gabriel Knight 3 was in development. Despite the turbulence in the industry and in the development studio itself, the game was released, it was critically well received, and it stayed true to it’s predecessors adventure gaming roots.

GK3 Gameplay

In this chapter of the story, we follow Gabriel and Grace to a rural region of France, where a high-profile kidnapping has occurred. They track the kidnappers to the small French town of Rennes-le-Chateau, which is home to a hundred-year-old missing treasure mystery. The town is hosting a treasure hunting tour group of colorful individuals - some are suspicious, all are suspects. Oh, and did I mention modern day vampires?

Several years before The Da Vinci Code became a best-selling novel, this game scratched the surface of that very same historical mystery, filled with religious symbolism, riddles, and conspiracies.

Gabriel Knight 3 moves the series from 2D to 3D. As an early 3D game, the graphics aren’t spectacularly good, but they also don’t look bad. From a nostalgic perspective, they have a certain amount of charm. It’s what you expect when you think of late-90s 3D games like Half-Life, Everquest, or Unreal.

The game was also innovative in its attempt to translate the 2D point-and-click adventure experience to a 3D world. The control system is novel: the player controls a first-person camera independently of the main character. When you click on items, you can instruct your character to interact with them. As a result, the game acts as a third-person/first-person hybrid.

A cool aspect of this for a mystery game was the ability to observe the scene in ways the main character could not. Though this is not utilized too heavily, the idea is that you might see a character is hiding something behind their back, or that someone is eavesdropping on your conversation.

A Hidden Puzzle

When Gabriel Knight 3 was released, I was only 10 years old, but I already had a fascination with video games, video game development, and adventure games. I particularly enjoyed Gabriel Knight 3 for its unique gameplay and compelling story. I enjoyed the historical mystery from this game so much that I continued to read about the real-life mysteries the game is based on (much of the mystery has been debunked at this point, but it’s still fun to think about in a fictional context).

At some point, I discovered that the game contained several easter eggs. Furthermore, if you access the in-game console and type a particular Extract command, a file named !!!README.TXT will appear in the game’s installation folder. It begins as follows:

GK3 is a data-driven game, meaning that very little of it is hard coded, requiring changes to the EXE. The majority of its scenes are completely run by scripts and configuration files. For the player, this means that much of GK3 can be customized or even rewritten… Interested?

The readme also specifies a few other Extract commands you could run from the in-game console to extract some technical and design documents that were bundled with the game. The readme suggests that, if you read and understand these docs, you could mod or even rewrite large parts of the game.

At the time, this seemed extremely cool to me. I was dreaming of becoming a game developer, and here was a “hidden message” from the developers of this game I really enjoyed. It was clear from the message that the developers were hoping someone might mod the game and do something cool with it. However, at the time, I didn’t know anything about game development, and I just didn’t have the know-how to make anything of it.

In 2000, Gamasutra published a postmortem of the game’s development, written by an engineer on the project, Scott Bilas. It’s a pretty interesting read, both from a technical perspective, but also to get a sense of the trials and tribulations surrounding the game’s release.

Revisiting the Mystery

Flash-forward 18 years, and I’ve now developed several mobile titles in Unity. I think I’m a pretty decent game developer, but I know that I could use more C++ exposure, and I want to learn more about building game engines.

Meanwhile, I’ve always been a fan of the Gabriel Knight games, and I’d sometimes think about those modding files bundled in with the GK3 assets. I’ve always liked the idea of working on some sort of fan project with GK3, but I wasn’t 100% sure how to best do that.

One day, I had a thought: GK3 is a heavily data-driven game. This means most of the game’s logic is not hard-coded in the game’s executable, but is instead encoded into the various assets bundled with the game. The engine itself is simply the glue that loads, parses, and interconnects those assets.

Some are the obvious types of game assets: textures, 3D meshes, and audio files. Others, however, are more interesting: the game’s scene data is stored in “Scene Initialization” files, the interaction data is stored in “Noun/Verb/Case” files, and the game’s logic is mostly stored in “Sheep” script files. Much of this data is stored in plain text, making it easily human-readable. Some is in binary, but it’s still readable if you can determine the data format (aka, reverse engineer the file formats).

GK3’s 1999 engine is a bit outdated now in 2018. The game only runs on Windows. The max resolution is fairly low. The game also has some technical problems on newer machines: failure to start if no CD drive is present, graphical artifacts if you minimize and maximize the game window, issues playing video files, and sometimes it just straight up crashes. This isn’t to say that the 1999 engine is bad - it just has compatibility issues with newer machines.

So, what if I write a game engine in C++ using a modern structure and architecture, and then on top of that, it can parse all the data files from GK3? Assuming the original game is mostly data-driven, you could theoretically write a new engine that knows how to read and interpret those assets, which reads the GK3 assets from the original game, and uses them to recreate the experience.

The initial goal would be to simply recreate the original game using a new engine, but the same assets. From there, though, there are a lot of cool things that could be done. If the engine is appropriately cross-platform, the game could now run on Mac or Linux in addition to Windows. You could add support for new features, like better lighting, or higher screen resolution. You could add support for new asset types, or replace existing assets with higher-fidelity ones (higher resolution textures, more detailed 3D meshes, etc). You could even create entirely new gameplay experiences using some of the gameplay architecture from GK3.


My primary motivation is to learn. By writing a 3D game engine from scratch, I will surely learn a lot more than I currently know about 3D math, graphics APIs, C++, and game engine architecture. For this reason, I’ll be focusing a lot of attention on understanding how things are working. For example, I’d rather write a math library than use a pre-existing one, since it would be informative.

My secondary motivation is to do something cool that relates to a game that I’m a big fan of. Working on this project will allow me to re-immerse myself in this game that I’ve enjoyed so much, and it’ll also let me peel back the curtain a bit to explore it more closely than I ever have before.

What About You, Dear Reader?

My plan is to chronicle my trials and tribulations on this very blog that you are now reading! With any luck, those posts will provide some guidance and insight into topics that you yourself are interested in learning more about. By following these posts, my hope is to provide a decent roadmap for developing a 3D game engine. It’s not going to be 100% comprehensive, but hopefully it will provide some insight and guidance.

Note that I’m posting this in October of 2018, and I’ve been working on the engine for about 10 months. But I will be going back and writing some posts about the work that I’ve already done up to this point.

comments powered by Disqus