Code Hero (alpha)

Code Hero Alpha
Code Hero Alpha

Last year, or maybe the year before by now, I helped fund an innovative game on Kickstarter, Primer’s Code Hero. This game would teach you to create your own games using the cross-platform Unity game platform, UnityScript and JavaScript. UnityScript, JavaScript and Flash’s ActionScript are all closely related scripting languages, so knowing these things would be a Really Good Idea.

Instead of a more traditional approach, Code Hero is the world’s first FPC (First Person Coder) game. You don’t write a game. You create a game around you. With your Code Gun.

This might be the first shooter with a gun that doesn’t destroy. Unless, of course, you set it to GameObject.Destroy(). Then, I guess it’s like any other game.

Code Hero's humor: Doctor Evil by way of GladOS.
Code Hero’s humor: Doctor Evil by way of GladOS.

Code Hero is set in a Lawnmower Man-like virtual reality, guided by the ghost of Ada Lovelace, the world’s first computer programmer. (Computing would remain a woman’s occupation until the advent of electronic computers, but luminaries such as Grace Hopper would help it climb new heights even after).

You’re soon given your Code Gun, a portal to a simple text editor and console that can run code in the current scene by pressing a trigger. It can also “shoot” special code signs to suck the code into the gun, where it can be stored, modified, and shot out again.

Once in the gun, the code can be extended with additional UnityScript to do what you like. Scripts and physics can be attached to objects in a scene editor mode. You can build a world around you — just you and your code gun.

Code Gun editing screen
Code Gun editing screen

Code Hero is still in alpha, so I’m not going to get into any bugs. You expect those. The developers have recently completed a “FizzBoss” challenge, an implementation of the famous “FizzBuzz” basic programming test.

FizzBuzz asks programmers to write a program that prints out the numbers 1 through 100, each on a line of their own. However, if the number is divisible by three, it should instead print “Fizz”. If the number if divisible by five, it should instead print “Buzz”. But, if the number is divisible by both three AND five, it should instead print “FizzBuzz”. Mention of this problem online is usually followed by programmers posting their solutions. And those solutions being wrong. Merriment ensues.

So, as a test of what you have learned thus far, destroying a boss by implementing the FizzBuzz solution in UnityScript is first rate. But, before I met the boss, I took the advice of signs in the boss’ anteroom and went to brush up on my construction techniques. I sucked up the code to build some stairs and accidentally shot the code right next to me.

I was trapped, in the stairs. The stairs code was made of stretched, untagged, cubes. I wrote a routine to return the tags of any object I shot — they were all tagged “Cube”. I modified the script to destroy everything tagged “Cube”, but I made a mistake and ended up in an infinite loop and had to shut down the game from the task manager.

That’s the danger of getting inside your code. Infinite loops can ruin your day, and bad code can fall right on top of you.

Code can cause explosions!
Code can cause explosions!

I left feeling that I would have had a much better learning experience given a regular IDE and a test scene in which to experiment. I don’t know what sort of IDE Unity developers normally use, but we use MyEclipse (for web development) at work and that gives a lot of help. For instance, there’s an “Undo” key right there :-) And you can stop your programs, any time you like!

Primer wants you to learn the basics of UnityScript programming in Code Hero before moving into the Unity development environment for real. I’m not really seeing why you wouldn’t just want to _start_ in the official UnityScript environment. The Code Gun is really just a visual copy and paste (with modify). You can do that outside your game just as easy. Easier.

However, a Portal-like game where the solutions were based on implementing algorithms instead of creating portals — that could be fun. Some of the Code Hero challenges were exactly this — for instance, building a bridge over a pool of acidic laser sharks. Lose UnityScript with all its braces and object-oriented syntax, come up with a simpler, more visual language like Scratch or Blockly, and turn players into coders, if not UnityScript experts.