Advertisement

Network support for Bomberman

Started by July 22, 2002 09:08 AM
3 comments, last by fury94 22 years, 6 months ago
Hello, I''ve been coding a Bomberman clone for about two years now (http://www.bomberman.fr.fm). Many people have requested network support for this game and I recently decided to try. Someone told me the code design should have been planned for this, but oh well at least I will learn what I should have done By the way, how do you think it should be thought when you plan to add network support in the future? I don''t have real experience in networking since I just read some articles about the constraints and how to (hopefully) fix the problems. I just tried some simple stuff with WinSock. Here is the solution I may try, considering I''m using TCP and a client/server structure. Please don''t blame me if it sounds stupid Each client saves the state of the game. It lets the player use the input and play normally. The other players moves are predicted (I guess a very simple prediction could be acceptable). The local input is stored until 50 ms elapsed. Then this local input (which gives the history of the input during the last 50 ms) is sent to the server. While the server is receiving this, the player can still play normally and the other players moves are predicted. The server waits for the local input of each client. Once it has received each client''s local input, it applies all these inputs concurrently to update the state of the game. Then it sends the changes of the game state to each client. Once the client receives theses changes, it restores the game state he has saved. Then it applies the changes, and then applies again all the local input he is currently storing. Etc. In theory, do you think it''s OK? And what about in practice? I''d really like to have your opinion about the solution above, or hear about your solution, or hear about your advice on how to think about a solution, or any other advice actually. Thanks! fury
That''s strange, how come I didn''t get any answer? I thought I will have a lot of answers (I find this subject quite interesting).

Or is my post too long to read?
Advertisement
It''s fairly simple. Instead of getting input from a keyboard, you''re sort of reading it from a socket. Have the clients send their updated data to the server every x seconds (or milliseconds), then broadcast that data out the the other clients. The clients then process the data from the socket, and use it to update the world. This can be done like you said, when something changes, store what changes and send that. I''m probably not making much sense , maybe it''s because it''s so simple it''s hard to explain. Anyways, good luck.
I''ve read something about synchronous and asynchronous communication. My solution seems to be synchronous and it''s not very good since the slowest client makes everybody slow. Asynchronous is harder to program though. What do you think? Maybe it''s not that bad on a LAN...
You could use non-blocking sockets (they are almost like syncronous sockets). The slowest client shouldn''t slow down the entire game and there isn''t that much more effort to implement it. See this tutorial for an idea of how to do it. Basically all it invloves is calling select to see if there is any waiting data.

--24 Beers in a Case.24 Hours in a Day.Coincedence? I think not!www.gramb0.co.uk

This topic is closed to new replies.

Advertisement