Wizard of Wor

There seems to be a trend of re-creating classic 8-bit games in JavaScript at the moment, including the recent and excellent Survivor. But this time Hungarian developer Krisztián Tóth brings us a faithful re-creation of the Commodore 64 version of Wizard of Wor, itself a port of the 1981 Midway arcade title. The overall concept of the game is a simple one: you and an optional friend, battle your way through a series of dungeon mazes fighting the baddies that dwell within. These include the Burwors, blue wolf-like creatures, Thorwors, red scorpions and the titular Wizard of Wor, a deadly wizard who appears after every 3rd dungeon.

It’s up to the players to decide if they want to play co-operatively or against each other, as their shots are fatal. This creates an interesting dynamic rarely found in a game over three decades old. As this JavaScript re-creation is as true to the C64 version as you can get without plugging in a real Commodore or emulator, I was keen to find out more from Krisztián about the reason for making the game and the process involved:

“When I was 7 years old my parents bought a Commodore 64 and this was the first game I really fell in love with. I was enthralled, both by the game and by the computer. After being so fully infected I think my mission was to just give something back in return. This is my fourth C64 JavaScript conversion. First was Domino, then Tetris. The third as biggest was Boulder Dash with the complete construction kit and now Wizard of Wor.

In order to convert Wizard of Wor to JavaScript I just played the original, a lot, and looked carefully at what I was seeing. No disassembly of the original code was used, it was all done by eye. These games always seem so simple at first, but when you look deeper you realise that isn’t true. Their primitive graphics and sound effects hide a lot of complexity. In this game for example the most difficult algorithms are found in the enemies and player movements. But I always aspire to create a perfectly faithful adaptation. That’s the whole point of it for me.”

When questioned about how he built the game from a technical perspective, Krisztián  had this to say:

“I used my own engine to create the game. Obviously I use jQuery and a few other plugins,  jStorage for handling local score saving for example. But my principal aim is that the program code should be as simple as possible. To ensure that the code doesn’t contain unnecessary functions, which I would almost certainly have if I used a framework. The JavaScript in my Tetris game for example is < 12Kb. I’m an old school programmer. I fight for every byte of memory, and I love that :)

The game uses a combination of canvas and CSS. The main game area is of course canvas. Canvas is the solution if you want fast animations. I tried using animated divs and cells but this was a dead-end in erms of speed. My computer is 10 years old, so I am forced to optimize my code otherwise I cannot play my own games! Of course using canvas meant I lost all SEO, so the intro screen, instructions and all text are plain HTML styled with CSS. I never re-draw the whole canvas either, only the areas I need, which of course helps increase speed.”

With four C64 games already under his belt I wondered if there were plans for any more?

“I have a lot of plans but very little free time. I always make a rule to never start a new project, but I cannot keep it! There are a lot of great games, not only C64 ones, that I would like to try: Impossible Mission 2, Dune 2, over-head RPG games like Ultima 1, platform games like Prince of Persia and more. There’s plenty of choice. It’ll be a surprise!

My basic programming principle is this: We should write code in such a way that the players do not have to focus on the technical details. I want the players to become addicted to the game world that the code created, and the developer should be prepared to make the code do anything to keep this illusion alive.”

Play Wizard of Wor