I'm programming a 2.5D networked game in Java. The networking works like this right now:
Create new networked sprite object at the client. Send it to the server. Server distributes and saves it. (
TCP-ObjectStream
s are used)The Sprite's state is represented by a
String
that contains its id (Player's name+Index) and values. You can request the state with the methodgetState()
:return getID()+"|x"+getX()+"y"+getY()+"#"; //Example: "Grimey2|x402y123#"
These states are collected multiple times a second by adding them to a single big String
:
zState += spriteArray[x].getState();
//Example: "Grimey1|x752y133#Grimey2|x410y31#Grimey3|x202y13#"
All sprites' states are then saved in a HashMap
at the client, sent to the server (Java DatagramSocket
) and saved there too.
Is there a more performant way to handle sprite-updating than with String
s?