コード例 #1
0
 public void localChatText(String text) {
   String[] commands = text.split(" ");
   if (commands[0].equals("client")) {
     if (commands.length == 2) {
       client.init(commands[1], "localhost", 9001, "localhost", 9000);
       chatFrame.appendRow("default", "");
     } else if (commands.length == 6) {
       client.init(
           commands[1],
           commands[2],
           NumberTools.toInt(commands[3], 9005),
           commands[4],
           NumberTools.toInt(commands[5], 9000));
     } else {
       chatFrame.appendRow(
           "default",
           "To start the client enter: client <username> <localip> <localport> <serverip> <serverport>");
       return;
     }
     chatFrame.appendRow("default", ".");
     chatFrame.appendRow("default", "Try to connect...can take a while...");
   } else if (commands[0].equals("server")) {
     if (commands.length == 1) {
       server.init("localhost", 9000);
     } else if (commands.length == 3) {
       server.init(commands[1], NumberTools.toInt(commands[2], 9000));
     } else {
       chatFrame.appendRow(
           "default", "To start the client enter: client <localip> <serverip> <serverport>");
       return;
     }
     chatFrame.appendRow("default", ".");
     chatFrame.appendRow("default", "Server created...");
   } else {
     if (client.getChatService() != null)
       client
           .getChatService()
           .sendMessage(client.getCommonWorld().getUserManager().getAppUser(), text);
   }
 }
コード例 #2
0
  /*
   * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
   */
  public void init(GameContainer container, StateBasedGame s) throws SlickException {

    bulletDirector =
        new BulletDirector() {
          public SequenceDirectorIterator createIterator() {
            return new BulletSeq();
          }
        };

    bulletDirector.createBullets(1);

    //		for (int i = 0; i < 2000 ; i += 11)
    //		{
    //			int f**k = 10 + new Random ().nextInt (10);
    //			blaTimer += f**k;
    //			if (blaTimer >= 200)
    //			{
    //				blaTimer = f**k;
    //				superBlub = xpos;
    //			}
    //			blub = (( 50f/ 1000f) * (float)blaTimer) ;
    //			xpos = blub + superBlub;
    //			System.out.println ("Correct: " + (60 + xpos) + ":::" + blaTimer + " weg; " + blub);
    //			bulletDirector.update (f**k);
    //		}
    //		System.exit (0);

    container.setAlwaysRender(true);
    container.setShowFPS(true);
    container.setVSync(true);
    // Zeitscheibe auf 20ms
    //		container.setMinimumLogicUpdateInterval (60);
    container.setSmoothDeltas(true);
    //		map = new TiledMap ("maps/BeerMap.tmx");
    map = new TiledMap("maps/iso-test2.tmx");

    world = new GameWorld();
    boolean clientOnly = false;
    world.init(container, clientOnly);
    world.setMap(map);
    server = world.getServer();
    client = world.getClient();
    if (StringTools.isNotTrimEmpty(serverIp)) {
      server.init(serverIp, NumberTools.toInt(serverPort, 9000));
    }

    chatFrame = ChatFrame.getInstance(this);
    getRootPane().add(chatFrame);

    chatFrame.setSize(600, 400);
    chatFrame.setPosition(10, 250);
  }