#52WeeksOfCode Week 24 – Game Programming

Week: 24

Language: Game Programming

IDE(s): Twinery 2.0 Beta

History (official):

This is the only entry in this sequence which is completely open. Since I can use any language or platform I want, there’s nobody to pick on.

History (real):

When I was a program chair for our game software engineering program, I was given a lot of textbooks from optimistic publisher reps. One that stood out from the others was “Beginning C++ Game Programming”. (Dawson, Michael. Beginning C++ Game Programming (Game Development Series). Premier Press, 2004.)

We ended up not using the book because it didn’t target a particular platform like Windows or game programming framework like Unreal. But when I took a closer look at it, I realized it wasn’t actually about game programming.

It was about learning to code by programming games.  The book took you through basic programming concepts, such as control structures, loops, data structures and even object-oriented programming. These are all of the things that would be covered by a beginning to intermediate programming text. What made it different was that every piece of code was either a game or gaming-related (like a character generator for an RPG). It almost made me want to learn C++ over again because the book made it look like so much fun.

While technology and education methodologies have progressed substantially since I was a lad, programming textbooks still have really boring assignments. The success of gamification in learning as illustrated by Khan Academy, Code Academy  and Google’s Oppia project suggests that it’s time to bring that into the classroom at the college level.


The goal this week is to write a game. I can pick any language, framework or platform I want. I am, in fact, spoiled for choice.

When I was a lad and computers were the size of draft horses and ran on steam power, computer games were text-only. They were a lot like those “Choose Your Own Adventure” books and some of them, most notably from Infocom Games, were very sophisticated.

Though text adventures are not as popular as they once were, they’re still around, supported by an enthusiastic community of developers and storytellers. As a result, there are a number of software programs that make it easier for you to develop a text adventure and users post their files for others in the community to try.

At one time I wanted to try my hand at this and I used Inform, which was a powerful tool that included a scripting language and let you build very complex worlds. Unfortunately learning to program in Inform was definitely more work for me than my casual interest in creating a game so I did a quick project and never picked it up again.

We have more choices these days, however. A newcomer to the field is Twine, a tool that is more in the spirit of the Choose Your Own Adventure books and so not as sophisticated as Inform. Consequently, it’s much easier to build a game. There are two versions of Twine. One is a downloadable package for Windows or Mac OS X. The new version (which is still in beta) lets you do all of your development in a Web browser and then download your game as an HTML file. That looked like fun, so I started it up in a browser window.

Twine game editor

Twine Web-based game editor

The interface is a bit sparse so it took a bit of experimentation to get started. You are presented with a blank canvas. To begin you add a Passage, which is what I would have called a room. When you do, you’re presented with the Passage editor.

Passage edit window

Editing a Passage

You give the Passage a name. You can also add Tags, which contain information that is not visible to players but might be anything from a simple annotation to a link to run a custom script before the story starts. Tags are totally optional.

Unless you want the shortest story ever, you need to link to other Passages.  The easy way to do this is by adding the name of the Passage, surrounded by double square brackets, as you can see above. If the Passage you name doesn’t exist, it will be created and linked to the current Passage. You can put as many links as you want to other Passages. You can also create the new Passage directly in the editor and link to it later.

Continue creating and editing Passages until you reach an end point for your game. At any time you can play-test your game in the editor.

Starting the game

Starting up my game

Note that all of your data is saved locally in your Web browser so if you quit without saving then you’ve lost all of that work. Fortunately you can archive your work in progress by periodically clicking on the Home icon in your editor and going to your main work page.

Twine Web Main Page

Twine Web Editor home page

There you can also start a new story, import story files and work on other stories. Once you’ve completed your game, you can download it as an HTML file and either post it as a Web page or open it locally in a browser.

It was very quick and easy. Though I could have jazzed it up with stylesheets and javascripts, that’s totally optional. The thing is, I had so much fun putting using this that I can see myself coming back to it.

I may not have the Great American Novel inside me but there are plenty of short stories.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s