Man, this class is pretty!

T540 Spring Semester 2002


Lecture Notes Four: Java 3D API, RMI, Sockets, Project Proposals

Here's a second way of doing double buffering:

import java.awt.*;
import java.applet.*;

class fNFA extends Applet {

    private Image     offScreenImage;
    private Graphics  offScreenGraphics;
    private Dimension offScreenSize;
    
    public final void update(Graphics theG){

	Dimension d=size();

	if( (offScreenImage == null) || 
	    (d.width != offScreenSize.width) || 
	    (d.height != offScreenSize.height)) {

	    offScreenImage = createImage(d.width, d.height);
	    offScreenSize = d;
	    offScreenGraphics = offScreenImage.getGraphics(); 
	}

	offScreenGraphics.clearRect(0, 0, 
				    offScreenSize.width, 
				    offScreenSize.height); 
	
	paint(offScreenGraphics);

	theG.drawImage(offScreenImage,0,0,null);

    }
}

This gives you a no-flicker applet.

Now your code needs only start from it.

import java.applet.*;
import java.awt.*; 

public class SimulOne extends fNFA implements Runnable {

    // instance variables 

    public void init() { 

        // whatever initializaton we need to do 

    }

    Thread simulation; // let's just assume 

    public void start() { 

	if (simulation == null) {
	    simulation = new Thread(this); 
	}
	simulation.start(); 

    }

    public void paint(Graphics g) {

        // simply do your painting

    }

    public void stop() { // irrlevant, just to match the start above 

	if (simulation != null) {
	    simulation.stop(); 
	    simulation = null; 
	}

    }

    public void destroy() { } // not really needed... 

    public void run() {

	while (true) {
            // your simulation loop, time passes... 
	}

    }

}
Today in class I would like to start from the following files:

Two URL's that will be useful:

  1. http://developer.java.sun.com/developer/onlineTraining/java3d/
  2. http://web3dbooks.com/java3d/

Now let's do networking.

  1. Here's a chat application developed with RMI.
  2. Here's an older document about the same thing.
  3. Here's a set of steps we always need to take for RMI.

Then we look at our other chat. Here's the server side of it:

  1. ChatServer.java
  2. ChatServerThread.java
  3. sClientGroup.java
  4. sClientThread.java
We used it once. Today we will try to use it by telnet-ing into it.

Here's a session with the server:

burrowww.cs.indiana.edu% java ChatServer 39999
Server successfully initialized.  Waiting for connection...
Received New Connection.
Got: login||adrian from null
Got: say||How are you people? from adrian
Received New Connection.
Got: login||michael from null
Got: say||hola, who else is on-line? from michael
Got: say||I am here, Michael, how are you? from adrian
Got: logout from michael
Got: logout from adrian
^Cburrowww.cs.indiana.edu%
Here's one of the clients' session:

frilled.cs.indiana.edu%telnet burrowww.cs.indiana.edu 39999
Trying 129.79.245.98...
Connected to burrowww.cs.indiana.edu.
Escape character is '^]'.
login||adrian
login||adrian||adrian has entered the room.
list||adrian
say||How are you people?
say||adrian says: How are you people?
login||michael||michael has entered the room.
list||adrian&michael
say||michael says: hola, who else is on-line?
say||I am here, Michael, how are you?
say||adrian says: I am here, Michael, how are you?
logout||michael has left the room.
logout
Connection closed by foreign host.
frilled.cs.indiana.edu%
And here's the other one:

frilled.cs.indiana.edu%telnet burrowww.cs.indiana.edu 39999
Trying 129.79.245.98...
Connected to burrowww.cs.indiana.edu.
Escape character is '^]'.
login||michael
login||michael||michael has entered the room.
list||adrian&michael
say||hola, who else is on-line?
say||michael says: hola, who else is on-line?
say||adrian says: I am here, Michael, how are you?
logout
logout||michael has left the room.
Connection closed by foreign host.
frilled.cs.indiana.edu%
Please note that these sessions are intertwined:

  1. first the server was started
  2. then adrian connected
  3. then michael connected
  4. then there was a brief conversation
  5. then michael disconnected
  6. then adrian logged out too
  7. then we stopped the server
We want to take this and include it in the simplest video game we have.

Here's that, done with RMI, for your edification.

Here, now, are what has been received thus far in terms of project proposals:

  1. I thought about programming a sort of bomberman game, but in three dimensions instead of two. So it would be possible to throw things from above, use extre tools such as parachutes or sneak onto people. The disign could be done to make it look like a mountain of ice or something like that.

  2. I would like to build a multiple player game that takes place in a maze. The players can navigate from an overhead 2D view. The goal is to collect treasure that appears randomly around the maze. Perhaps the players can shoot each other and they would reappear somewhere else. Scaling the game up: Allow a first person view. This shouldn't be overly difficult, if the maze is all right angles. It could be rendered with vertical lines and angled straight lines on the floor and ceiling. - Limit overhead view to line of sight. - Have teleporters in the maze. - Multiple rooms - elevators - powerups - invisibility, speed, firepower - independant game characters - in 3d view, show path on floor to nearest treasure

  3. So far I have two ideas. The problem is, one is good for networking but not graphics, and the other is good for graphics but not networking. Idea 1: Networked version of the Very Clever Pipe Game This is a card game developed by CheapAss Games. Last Semester for C343 (I was an AI), Peter Drake developed a version of this game as a standalone java application. I'd like to make it a networked game, probably as applet/servlet. The problem is, I wouldn't get any experience with 3D java. Idea 2: A 3D version of asteroids. To keep things simple, perhaps the action of the game would take place in only 2 dimensions, but the graphics could be 3D. Maybe I would call it Spider Attack. The player could be stuck at the center of a spider web. He could turn 360 degrees and shoot spiders as they come towards him on the web. Any ideas for adding a networked component to this? I'll keep thinking to try to come up with a game that is both networked and 3D.

  4. I was thinking of changing the Alien Landing game to allow 2 players to participate in the same game, cooperate in fighting the aliens, or compete and try to shoot each other down using "grenades" that could hurt the aliens or co player.

  5. An interactive game that you can play with four people. Maybe something that allows you to hunt each other down and kill each other. But, not real violent. :)

  6. In fact, I have no idea in mind right now. However, I think Iceblox is nice. If you let me choose, I would like to improve it to a network version, and more...

  7. I am thinking of a 2 dimensional game that is similar to "capture the flag" with users being assigned two separate teams.

  8. I want to do a networked gambling game involving the game of Craps. Users can join, bet... and keep score of cash. Maybe the server can remember users and logins, to save info of winnings.

As you can see these ideas are all very nifty and I'd like to discuss them all in class today.

Two more links, also for discussion.

And Sue Menzel's Shakey!


Last updated: Jan 31, 2002 by Adrian German for A348/A548