Ucigame - Getting Started

Home | Getting Started | Reference | Introduction to Java | Gallery

Ucigame is designed for people who want to design and program 2D computer games. This page will give you some useful information to get started.

Programming is in Java

Computer programming with Ucigame uses a very popular language called Java. Java is a versatile language which can be used to make all types of computer applications. Java has several features designed primarily for large systems created by teams of many people. In Ucigame we generally ignore those features.

Many good books on Java have been written, and you may want to own one. However, those books generally tell you much more about the language then your will need for writing many Ucigame programs, so feel free to skip whatever doesn't seem relevant or comprehensible.

How to get started

You need the have version 1.5.0 or later of Java, which can be freely downloaded from Sun Microsystems, the company which created Java. It's also called the J2SE Development Kit (JDK) 5.0 or 6.0. Start at Sun's download page.

You will also need a copy of ucigame.jar, which contains all the code necessary for Ucigame programming. Download it by clicking on the link. (If you are using Internet Explorer, ucigame.jar may get renamed to ucigame.zip. In this case, rename it back to ucigame.jar.) Now you need to put ucigame.jar in a place where it can be found when you want to compile and run Java programs that use it. There are two main options:

  1. This option may be best if you are running on your own computer. When Java was installed, its "Java Runtime Environment" or JRE was put on your computer. In Windows, it might be in a folder called C:\Program Files\Java\jre1.6.0. (Note that it will have the version number, such as 1.6.0, as part of the name.) Inside that folder is a subfolder called lib, and inside of lib is a subfolder called ext. Look inside that, and you'll see several .jar files. Any .jar file in this folder is accessible to any Java program running the corresponding version of Java. (It's possible to have more than one version of Java on a computer, which can lead to much confusion.) Copy ucigame.jar into this lib\ext folder, and you're ready.
  2. This option may be best if you are running on a shared computer. Move ucigame.jar into the folder where you will be writing your game programs. Now you need to tell Java to look in ucigame.jar (it knows to look in the lib\ext folder without you telling it to, but nowhere else). At the command prompt, type in
    SET CLASSPATH=%CLASSPATH%;ucigame.jar;

    This command adds to the "classpath," that is, the list of places Java looks for class files.

  3. [probably need other options for non-Windows and for specific programming environments]

If you get an error message like "package ucigame does not exists" when trying to compile, or an exception like "java.lang.NoClassDefFoundError: ucigame/Ucigame" when trying to run, that's a sure sign that there's a mismatch between your CLASSPATH and the location of ucigame.jar.

Once you have ucigame.jar and the classpath squared away, the steps for creating a Ucigame game application are:

  1. Create a file called YourGame.java with the source code for your game in it. (This is a big step, of course. Lot's of sample programs on this site can serve as models.)
  2. At the command prompt, enter javac YourGame.java. This compiles your program, which means that the .java file is transformed into one (or more) .class files. The .class files are used to actually run the game.
  3. You may get compiler errors; if so, fix them and repeat the previous step.
  4. Make sure that YourGame.class is now in your folder.
  5. Run your game with java YourGame YourGame. The name of the game has to be repeated on the command line. This is something unique to Ucigame, and isn't true of Java programs in general.
  6. You can stop the game by pressing the Escape key.

Running Ucigame games as applets

Java programs can run as applications or as applets. [More to come.]

What next?

Click on Gallery at the top of this page to see Ucigame programs (including source) running as applets.