🎉 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!

Making a server-client Pong game using sockets

Started by
2 comments, last by hplus0603 3 years, 5 months ago

Hey guys, I've been learning how to make 2D games recently and am looking for more challanges. I want to be able to create a server-client connection using sockets in C++. I chose a simple Pong clone (done using SDL library) to start with, but I'm kinda lost now. I looked all over the internet for some tutorials, but none of them seem to answer the questions I have. What functionalities are gonna by handled by the server, and what functionalities are gonna be handled by client? By the functionalities I mean: movement, collision detection, user input, rendering…Can I just make it so that one player is gonna be the server and the other will connect to him as a client ?

Advertisement

I think you'll benefit most from this exercise by writing a little dedicated server for it. However, please handle input and rendering on the client side. It would be interesting to see how a lockstep implementation would behave before you dive into predictions and the likes.

What do you use for sockets communication? I bet it's difficult to find a mature stand-alone library dedicated for just that.
I've been using SFML since I can also take advantage of some of its other features.

The easiest way to get started is probably to make one player be the host for the other player.

That “hosting” player will likely have a significant “ping” advantage, as in the local gameplay will be smoother than the remote gameplay, but this will let you work with the first kind of challenges, such as serializing state, dealing with disconnections, and so on.

Once that's built, you can start thinking about dedicated servers, lag compensation, and other network model updates.

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement