Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Command and Conquer

807569Aug 18 2006 — edited Aug 19 2006
I am creating a game that is based in space. One computer runs a server which contains information about different objects such as spaceships and bullets. Whenver a ship or bullet moves on the server, it sends a message to all of the clients telling them the new x,y position of the object.

I was wondering how the proffessionals that make games like Generals, Red Alert, and Tiberian Sun are able to update all the clients so effeciently. My implementation is really laggy.

Does anyone have any ideas?

Here is some of the code:
 new javax.swing.Timer(TICKRATE, new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        if(time>=100)
          time = 0;
        time++;
        tickShips(time);
        tickProjectiles(time);
        updateClients();
      }
    }).start(); 
public void updateClients(){
    for(int i = 0; i<ships.size(); i++){
     Ship current = ships.get(i);
     Sender.sendToAll(current);
    }
  }
public static void sendToAll(Ship s){
    sendToAll("moveship"+" "+s.ID+" "+((int)s.x)+" "+((int)s.y));
  }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 16 2006
Added on Aug 18 2006
6 comments
201 views