Hi folks…
i have finished my fisrct basic Network code and would like you to have a look on it.
First question:
I’m using Oject Streams for the communication between clients and server.
Is the use of this streams much less performant as DataStreams?
Question two:
i have written a small space simulator where spaceships can fight each other.
I realise the synchronization between server World and client world as follow:
The server world has a mainloop.
in the loop the server do the following:
- sync the time
- update all sprites
- check collison
- sends worldstatus
The world status is a WorldData Object which contains the position, velocity, color and some more attributes (e.g. name, enrgie are optional) continously to all clients.
The World state is timestampted
The clients recieve the data and store them.
in the mainloop, the clients do the following:
- calculate the lag (timestamp of World - current time)
- update the world status with the lag
(it s a simple interpolation based on the velocity of each sprite) - check player controlls and send them to server
(each controll is a simple object) - paint the world
What could i optimize?
Is this strategie acceptable?
Question 3:
I have problems to connect the modells of my sprites which are flieng around in the werver world with my SpriteViews, which should be managed on the client.
i can’t assign the model on the server to the view on the client.
To solve this i implemented a little Renderer, which decide based on a casting, weather to paint a ship or ah shot (e.g.)
But i don t have a view fpr each sprite on the client…
I hope you can understand my problem.
if i could implement a connection betwwen a server model and a client view, i would be able to reduce the data, which is neccesarry to draw the Sprite.
(e.g. playername, color)
I hope someone can help me here.
Thanks in advanced