🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Testing the water

Started by
1 comment, last by BrianNaughton 23 years, 10 months ago
Hi, I have written a DirectX game which has multiple players. However, in my ignorance I programmed it so all four players could use the same keyboard to play, you know, like in the good old days. Of course, modern keyboards are unhelpful in this respect, beeping all the time. So you can play the game as a single player against the computer but not multiplayer. What I''d like to know is, how difficult would it be to adapt the game so it ran on a network, without totally restructuring the game. I imagine it would be a lot of work but I just thought I''d check. Bear in mind that I don''t know a single thing about networks. Thanks, Brian
Advertisement
I know how you feel, as I literally just had the same problem - except I caught it in the design and testing phase so I''ve proceeded to re-structure my game for networking accordingly.

You say you know nothing about networks, well this is probably a bad thing if your going to attempt a conversion
Yes, it will probably take an amount of re-structuring to get a network version up and running, as you are going to have to design what data needs to be sent each frame, what kind of network architecture you will use, how you are going to parse out data packets on other machines et cetera.

I recommend a gamedev.net article on Winsock, since it should give you some reasonable foundation on network programming and some actual code to muck around with, you can find it in the gamedev.net programming section and scroll down the previous articles until you find ''winsock 2 for games''.

It can probably be done, it will just require some reasonable thought and time.

Regards,

-Mezz
For my current project, i have an independant class for network activities. It contains all winsock variables as well as a text buffer for every client (char buffer[MAXCLIENT][MAXBUFFERSIZE]) that is used to store packets to be sent to allow multiple packets of data to be sent to one user in one reasonable size packet. Using this correctly will keep yuo from sending data to a single client every cycle, with a good timer you would only send data to a user every few cycles unless its very urgent information.

Server side i have functions for things such as init Network, check for connections, check for incoming messages, recieve incoming messages, and send messages out. Client side is similar, but a bit more simplistic as it only handles the connection to a server, rather than connection to however many clients are connected.

The only difficult parts about it are deciding where to call the functions and how often for best results, and having a method for carrying out commands by clients(such as, if the server recieves a message asking to move to the right, you need to have a way to actually call a function that tests if moving there is ok, and if so, do it) It''s not such a complex system when you''re only dealing with a few clients, its when you want a shitload of clients that you have to work out problems for lag reasons. Even then, adding in timers to do certain tasks every few cycles rather than performing everything every cycle can fix alot of lag problems.

Anyway, thats just my 2 cents from my experience, if I''m wrong please correct me, I''d love to know another way if it was easier or alot faster.

Spartan
Cabal Ent.

This topic is closed to new replies.

Advertisement