[Kde-games-devel] Online Granatier, common real time online gaming libs?
Mathias Kraus
k.hias at gmx.de
Thu Jun 6 19:30:59 UTC 2013
Am Samstag, 1. Juni 2013, 01:31:28 schrieb Nathan Sala:
> > I always wanted Granatier to be an online game, but I didn't find time to
> > do it.
> > Last year, I think, I saw a blog post from the telepathy guys. They had a
> > proof of concept online version of battleship, but I don't know what
> > happened with that.
> > At that time it sounded reasonable to use telepathy to connect the player
> > with each other. With telepathy we wouldn't need to care about such things
> > like NAT and so on.
>
> Yes that would be good. Can it help with NAT?
I think so. I don't know much about telepathy, bat as the telepathy clients can connect through NAT, it should be possible. The only problem I see is if it would be fast enough.
> > It look like you have some experience with online gaming. It would be
> > great if you could help with a common library.
> >
>
> No. I have experience about networking performance and reliability, but not
> about game engines.
> As a first step I want to build a solid low level networking UDP/TCP layer
> which will handle clients/server synchronization.
> But then I need to find a good generic algorithm and therefore a protocol.
>
> The best idea I have until now would be like:
> - User inputs are sent to the server and redistributed to all the clients.
> - Every XX milliseconds, the server sends the full current state of the
> game to all the clients.
For LAN games it would be good enough to just send the user inputs to the server and the server sends the changes of the scene to the clients. The time should be below the refresh rate of the screen, so this should be the easiest solution.
For Internet the solution would be a little bit more complex. I think the best would be, if the game runs on every client and also on the server. If there are ambigous situations, the state on the server wins over the client states.
That means, the client sends the user input to the server, together with the player position on the scene when the user input happened and maybe also a timestamp (e.g. milliseconds since game start). The server distributes that to all clients. Now at least the postition and the moving direction are synchronized.
The server notifies the clients if a player takes a bonus and which bonus was taken. The client which get the bonus has to confirm that. That is necessary, because if the player gets a bonus on the server to increase the bomb power and the player puts a bomb before he receives the notification from the server, the bomb power on the client would be lower than on the server.
The biggest problem is bomb moving. If there are a few 10 milliseconds delay between the clients, this might look arkward in certain situations, e.g. if two players try to kick the same bomb in different directions. A possible solution would be to add an inertia to the bombs, lets say start moving 50ms after kicking. This should be enough time for the server to figure out which player was first.
Overall I think it should be doable but like Aurélien said, LAN should be the first step because it's much easier and then extending to the internet.
Regards,
Hias
More information about the kde-games-devel
mailing list