Title: GameCreator
Course: CPS 261: Advanced Java Concepts ~ DL & MM MASTER

Package | Class | Use | Tree | Deprecated | Index | Help |
PREV CLASS   NEXT CLASS | FRAMES    NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

gameNet_cloneable
Class GameCreator


java.lang.Object
  gameNet_cloneable.GameCreator


public abstract class GameCreator
extends java.lang.Object




The normal class that gets the show on the road looks like the following:



 public class MyMain extends GameCreator{

  public GameNet_CoreGame createGame()
  {
          return new MyGame();
  }



  public static void main(String[] args) throws IOException
  {
        MyMain myMain = new MyMain();
        GameNet_UserInterface myUserInterface = new MyUserInterface();

        myMain.enterGame( myUserInterface);
  }// end of main
}// end of class


Things to note:

- GameCreator is an abstract method and extending this class requires us to have the method createGame
- GameCreator contains the enterGame which is responsible for asking the questions:


Enter your name:
Server side of game?(y/n)
etc.


Constructor Summary
GameCreator()

Method Summary
abstract  GameNet_CoreGame | createGame() createGame must construct and return an instance of your game.
void | enterGame(GameNet_UserInterface yourUserInterface) enterGame is responsible for all of the hard work of getting the networked game up and running.

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

GameCreator


public GameCreator()

Method Detail

createGame


public abstract GameNet_CoreGame createGame()

createGame must construct and return an instance of your game.

Returns:
GameNetCoreGame - your game must extend the GameNetCoreGame class

enterGame


public void enterGame(GameNet_UserInterface yourUserInterface)

enterGame is responsible for all of the hard work of getting the networked game up and running.

Parameters:
yourUserInterface - - You need to pass in an instance of your user interface. This class must implement the GameNet_UserInterface interface.

Here is the sequence that happens in enterGame to start up the whole game:

1. Your MyMain constructs an instance of your user interface code and passes it into the enterGame Method.
2. The enterGame method then asks the questions you have all seen that are listed above.
3. After the questions have been asked the GameCreator knows enough to put the pieces together as follows:
4. A GameControl class is constructed in one of 2 flavors. If we are on the Server, then the GameControl class will create a Server task and do all of the associated Server jobs.
5. If our GameControl contains the Server task, then it will also call the method createGame to obtain an instance of your game.
6. If we are not a Server, then the GameControl merely records the IP address and the port number so that we connect to the real Server as a client using sockets.
7. At this point the enterGame constructs the GamePlayer class that is the glue(threads, sockets, etc.) that connects your user interface to it's mygame.
8. The GamePlayer will maintain the Player's name, his GameControl object and the user interface object passed into the enterGame method.
9. The last thing done by enterGame is to call the startUserInterface method in your user interface to pass in a reference to your GamePlayer object and to let you know that everything is now connected.

Package | Class | Use | Tree | Deprecated | Index | Help |
PREV CLASS   NEXT CLASS | FRAMES    NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD