6.030 Final Project FAQ

The following are questions that seem to be coming up fairly frequently. There's only a couple here now, but as more groups start asking questions, we'll add more answers.

NOTE: if this FAQ doesn't clear up your question, please ask the course staff! If you find any bugs, tell us that too!


Q: Can Java display images (such as GIFs or JPEGs)?

A: Yes! Let's say you have an image called myimage.gif. You can load it using the following Java code:

    java.awt.Toolkit tk      = java.awt.Toolkit.getDefaultToolkit(); 
    java.awt.Image   myImage = tk.getImage("myimage.gif"); 
That's it! Then, you could display the image in your paint method like so:
    public void paint(java.awt.Graphics g) { 
        g.drawImage(this.myImage,  // The image you want to draw
                    this.x,        // The x position of the image
                    this.y,           // The y position of the image
                    this           // The ImageObserver.  (Just use "this"). 

Q: Can we use the cs101 classes? How?

A: Yes, you are allowed to use the cs101 classes for this project except for the wire classes you used in the Cat & Mouse problem set. Here's how:

  1. Start a new project using the cs101 stationery. That's it!

From Athena:

  1. Download cs101 jar.
  2. Make a directory to hold this file, and copy the file there. (Henceforth, the full path of this directory will be referred to as <cs101_dir>).
  3. Run the following commands:
        > cd <cs101_dir>
        > echo 'setenv CLASSPATH ${CLASSPATH}:<cs101_dir>/cs101.jar' >> ~/.environment
  4. Logout, then log back in again. Otherwise your changes won't take effect.

From Windows95/98:

  1. Download cs101.jar.
  2. Place this file into the directory of your choice. (Henceforth, the full path of this directory will be referred to as <cs101_dir>).
  3. Use notepad to open c:\autoexec.bat. Add the following line to the bottom of that file:
        set CLASSPATH=%CLASSPATH%;<cs101_dir>\cs101.jar

Q: Making the user of my game specify a hostname and a port (ala Cat & Mouse) is not very user-friendly. Is there any way I can hide these low-level details from the user?

A: Yes there is. Mike Wessler has written a very nice utility that does this for you. For a description and download, go here.