コード例 #1
0
 /* (non-Javadoc)
  * @see chu.engine.Game#loop()
  */
 @Override
 public void loop() {
   while (!Display.isCloseRequested()) {
     final long time = System.nanoTime();
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
     glClearDepth(1.0f);
     getInput();
     final ArrayList<Message> messages = new ArrayList<>();
     if (client != null) {
       synchronized (client.messagesLock) {
         messages.addAll(client.messages);
         for (Message m : messages) client.messages.remove(m);
       }
     }
     SoundStore.get().poll(0);
     glPushMatrix();
     // Global resolution scale
     //			Renderer.scale(scaleX, scaleY);
     currentStage.beginStep(messages);
     currentStage.onStep();
     currentStage.processAddStack();
     currentStage.processRemoveStack();
     currentStage.render();
     //				FEResources.getBitmapFont("stat_numbers").render(
     //						(int)(1.0f/getDeltaSeconds())+"", 440f, 0f, 0f);
     currentStage.endStep();
     glPopMatrix();
     Display.update();
     timeDelta = System.nanoTime() - time;
   }
   AL.destroy();
   Display.destroy();
   if (client != null && client.isOpen()) client.quit();
 }
コード例 #2
0
 /**
  * Send. Used by the game to tell the unit on either client to attempt an action.
  *
  * @param u the unit Identifier
  * @param moveX the x-wards movement
  * @param moveY the y-wards movement
  * @param cmds the commands for the unit
  */
 public static void send(UnitIdentifier u, Command... cmds) {
   for (Object o : cmds) {
     System.out.print(o + " ");
   }
   System.out.println();
   client.sendMessage(new CommandMessage(u, null, cmds));
 }
コード例 #3
0
 /**
  * Connect.
  *
  * @param nickname player nickname
  * @param ip the host ip
  */
 public static void connect(String nickname, String ip) {
   getLocalPlayer().setName(nickname);
   client = new Client(ip, 21255);
   if (client.isOpen()) {
     lobby = new ClientLobbyStage(client.getSession());
     setCurrentStage(lobby);
     client.start();
   } else {
     currentStage.addEntity(
         new Notification(
             180,
             120,
             "default_med",
             "ERROR: Could not connect to the server!",
             5f,
             new Color(255, 100, 100),
             0f));
   }
 }
コード例 #4
0
 /**
  * Gets the session.
  *
  * @return the session
  */
 public static Session getSession() {
   if (client == null) return testSession;
   return client.getSession();
 }