Jump to content
  • Advertisement
Sign in to follow this  
Figherstarter

Networking pong using C

This topic is 4699 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was curious if any can supply an example of pong or any other game being networked. I would like to have a server-client kind of thing going so that I could play against a friend. In order to do this, is multi-threading going to be needed? Right now I have an AI controlling the other paddle. I dont quite understand the concept of how the whole networking thing works with games. I am not sure how the input works for the client...it's really quite confusing. If anyone has any source code online that would really help. Thanks. Gil

Share this post


Link to post
Share on other sites
Advertisement
Well you will be hard pressed to find open source code for what you want but i can give you some pointers.

- If you are looking to develope in windows then use Winsock. I can't see the need for using a game-networking api because of how easy this easy this is.
- The data you would send would be in your own protocol, you could get away with sending 3 or 4 bytes from the server to client and back.
- Have one exe act as the server and that would sit there waiting for a client.

Hope that helps, if i think of anything further i will add to the above,

ace

Share this post


Link to post
Share on other sites
I've read up on the fundamentals of WinSock and seen it used in some Unix examples. The header files used in those examples were different but luckily, I realized that I had some examples already supplied for me. I recently purchased game programming tutorials from GameTutorials.com and noticed that there were examples of WinSock in C++. It was really easy to convert C++ version of WinSock to C. So all things look good, thanks for pointing me in the right direciton!


Gil

Share this post


Link to post
Share on other sites
I can show you the code i wrote for my network pong game, though its an unfinished, bugridden peice of software. It does work though albeit with some serious limitations. It has to be run via loopback to get high enough performance for the game to be even remotely playable. it uses c++ and winsock though im not real heavy on c++ conventions so it should be pretty readable to a C oriented person. It also uses minimal directx for graphics and collision detection(just D3DX*boundProbe()).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!