Chapter I - Introduction

When I first created a game development website in 1997 I had some thought that it would either help me in my quest to build games or it would help me land a job in the game industry. On both counts I couldn't have been more wrong. Here is what I've learned in the past five years of working on Crystal Semiconductor's game developer site, XPlus, DevGames.com, and GameDev.net...

If you want to learn how to build games, start building games. If you want a job in the game industry, start building games (and start learning to live on a pathetic salary, the developers are usually underpaid). So that's what this article series is about, an attempt to get back to the roots of what I wanted to do in the first place, write games!

This series of articles, currently planned to be about ten to twelve parts, will cover the design and construction of the first real game that I've ever done. All previous games I've done were usually trivial and were often intended as a demonstration of some API or hardware or something. So this will be a departure for me.

This game will be followed through its design, problem solving, prototyping, and on to its final version. Unlike the vast majority of games started by hobbyists this one should have a high likelihood of being finished because:

The Game

The game that we will be building is pretty simple. It doesn't even provide an opponent for you to play against so we don't have to provide any artificial intelligence. You must have someone to play against on the Internet or a local network.

The game provides a virtual tabletop along with virtual cards, dice, and tokens. It is designed to allow players to play conventional card games (i.e. ones using the standard deck of 52 cards with spades, hearts, etc.) and collectable card games like Mythos, Magic The Gathering, Harry Potter, Pokemon, etc. over the Internet. It doesn't try to enforce any of the rules of a particular game but it will try to prevent cheating from looking at your own or your opponents cards, changing the value of a die roll, etc.

At this point I think a picture of what I hope to build would be helpful:

Lest you think that the idea for doing this is original with me, it's not. People have been trying to figure out how to play collectable card games (CCGs) over the Internet since they came out and have been using some incredibly awful methods to do it. I once ran across instructions for playing the Star Wars CCG over Internet Relay Chat (IRC) using abbreviations for the various card moves and both players had to either take notes on the cards the other player played or if they were very lucky they would have extra cards they could lay out on the table to represent the other player's cards. Needless to say, this provides ample opportunity for both cheating and loss of sanity if you realize you made a mistake in recording another player's moves at any point.

I personally have wanted to create a program like this since 1997 because I wanted to be able to play a game called Mythos and there weren't any opponents available. But I knew if I had a program to play CCGs over the net I could find somebody anytime. So I looked around at programs others wrote to address this need like CardTable and Apprentice (see the Reference section for links to each of the CCG playing programs). Here are some quick summaries of what I thought the pros and cons are for different software already out there:

Apprentice

Pros: Fairly attractive, officially endorsed by Wizards of the Coast (?)
Cons: Runs only on Windows, Magic: The Gathering oriented, no protection from cheating (?), not open source

CardTable

Pros: Open source, cross-platform
Cons: Unattractive, no protection from cheating, written in Tcl

Magic Online

Pros: Licensed for Magic: The Gathering, may have a mechanism to "buy" cards so that players cannot use any card in existense in his/her deck (i.e. rare cards stay rare)
Cons: Only plays Magic: The Gathering (maybe later it might play other WOTC games), not open source, have to pay to play even if you don't care about the card buying thing, not yet finished

Magic: The Gathering Interactive Encyclopedia

This software was mainly about the card encyclopedia, helping you build card decks, provide strategy information, etc. It included a virtual card table to let M:TG players play online though. Unfortunately I have been unable to find out much about this program other than that. Also, the software seems to be under promoted and not used very much for online play so it must not have been very popular.

Digital Deck

Pros: Has a mechanism to buy card decks and booster packs, licensed for the Star Trek CCG
Cons: Only plays Star Trek but is designed to be used for other games. This is a product intended for companies that make CCGs so they can make their products available digitally.

NetMage

Pros: Lots of nifty ideas, actually produced a simple working version, written in Java, open-source, cross-platform
Cons: This program hasn't been updated in a while but it's a little early to call it completely abandoned. Unfortunately it seems to suffer from the same myopic view as a lot of these other projects that M:TG is the only CCG to play and it seems to do nothing to prevent cheating.

In addition to the program that actually plays the game we will need at least two other utilities. One will allow players to input data, lay out templates, and print cards for any CCG. This will be especially helpful for anyone who wants to try and use the software to create a new card game.

A second tool will allow users to pick cards from dictionaries of available cards to create decks for play. This will not have the level of sophistication of some M:TG tools which can do statistical analysis of your deck but as long as a standard XML file format is used by all of our tools and we document it well, a third party could write one.

The Tools

To do our development we will use Java. It is a language near and dear to my heart and one with a lot of advantages for the software we are going to write. You can create a great GUI with Java Swing, it offers several different approaches for using the network to send moves back and forth and chat, and when we are done the program will run without recompilation on Linux, Windows, and Mac OS X.

Listed below is the software you will absolutely need to install in order to be able to compile the code in these articles or be able to develop similar games. Take the time now to go get each of the pieces and go ahead and install each.

Sun Java 2 Platform, Standard Edition (J2SE)

You will see a link to download the latest version of the J2SE SDK on this page (it was version 1.4.0 at the time of this writing). At a minimum you must have this or another Java 2 compatible SDK in order to build the code.

Ant

The best build tool out there for Java projects. Ant performs the same types of functions that developers used to use Unix make for, but Ant is written in Java (and thus is portable to the same machines your programs are portable to) and it uses an XML based build file rather than the often obscure syntax of make files.

Java Web Start

The easiest way to help users download, install, run, and update your Java based software. Uses a simple file to direct the user's machine to download an application, cache it locally, update it when there are changes, and run it under a specific version of the Java runtime environment.

JAXP

We will use XML to store a lot of our data in a cross platform (even cross program) fashion. So we will use the Sun library for dealing with XML to handle it. JAXP is their Java library for reading and writing XML files. Note: If you installed J2SE SDK 1.4.0 or later then you don't need this part because it is included.

Unlike the above items, the following is strictly optional.

If you are like me you will also want a good "Integrated Development Environment" (IDE). An IDE offers a place for you to edit your Java source code, compile, and debug. My personal favorite is NetBeans but you may want to substitute any of a number of other popular alternatives like IBM's VisualAge or JBuilder or use no IDE at all. Because we are using Ant to do all of our project building we don't have to worry about the particular IDE you may choose to use.

NetBeans or Forte

The open source IDE NetBeans and its commercial counterpart Forte are integrated development environments (IDEs) for compiling, running, debugging, etc. Java projects. Forte usually lags a little bit behind the development of NetBeans but it adds a few additional features and Sun offers support for it.

Learning Java vs. Knowing Java

This series is targeted more towards users who already know Java or another modern object oriented language like C++, Python, etc. If you don't fall into this category then I'm not going to discourage you from hopping right in because I believe that using a language is the only way to really learn it. But I am going to suggest a book for you to get called Thinking in Java 2nd Edition by Bruce Eckel. The book can be downloaded in several formats from his website at http://www.bruceeckel.com but you will probably buy a paper copy of the book later just to have it handy as you work.

Compiling A Sample Application

Once you have downloaded the SDK, Ant, etc. listed above and installed it you will be ready to try compiling and running a sample application just to test your installation. While I cannot speak for all Java applications out there, I can say that I attempt to make everything in each of my projects almost point and click easy to build.

At this point you should grab the source to a little test project here: Chapter1.zip

Then follow these directions to make sure you will be able to compile and run the code in the project:

  1. Unzip the file to a directory.
  2. Open up a command console for your operating system and change directory to the directory you just created. If you list the files in this location you should see both a ReadMe.html and a build.xml file.
  3. Type "ant chapter1" at the command prompt and hit enter. If Ant and the JDK are correctly installed then it should run and automatically perform the build steps in the build.xml file to compile, package, and run a simple Java application.

The program in question is just a simple shell program with no functionality in it except to show a splash screen when it comes up. That's it. But if you got it to work then congratulations because you are ready to continue on to the next steps in the development of this software.

The Methodology

Now that you have successfully compiled and run a sample program you are ready to follow along for the rest of this series. My current plan for writing the software looks something like this:

  1. Design
    1. A general class design to cover the needed functionality
    2. List problem areas and possible solutions
  2. Prototype
    1. Solve problems
    2. Build crude version - A completely playable version of the game with all major features implemented. The code can be a total hack. This is the one we are building to throw away after we are done. We are going to take what was learned here and use it to build the final version.
  3. Build final version
  4. Complete
    1. Installation
    2. Sample data
    3. Online help
    4. Documentation
    5. Lobby

So the current outline for the series is:

  1. Introduction
  2. Design
  3. Fairness
  4. Instant messaging, chat, and rendevous
  5. Rendering
  6. Communications
  7. Implementing the design
  8. Rewriting the code
  9. Putting it all together
  10. Finishing touches

Reference

Links

Apprentice

The most popular software to play Magic: The Gathering online. Patches exist to let you play some other games like Harry Potter.

CardTable

An open source program to play different CCGs online.

Magic: The Gathering Interactive Encyclopedia

Although it was mainly a card catalog, this software included a way to play M:TG onlne.

Magic Online

Official software from Wizards of the Coast to play M:TG online. In beta at the time this was written.

Digital Deck

Commercial software from Decipher, the makers of several CCGs including Star Trek and Star Wars. Currently you can only play Star Trek using their software.

GameDev.net

The number one site for game development.

NetMage

An already existing Java virtual tabletop project.

JohnMunsch.com

Home of the author's weblog and all his projects (including this one).