Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Help with NetPong

This topic is 5863 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

Hi, I''m currently making a simple version of Pong that can be played online. What I need help with are some design matters.. first the program determines at initialization if it is a host or a client. Any idea on how to code the rest depending on if it is a host or not? I thought of something like "if(isHost) do_host_stuff(); else do_client_stuff();" but it will get pretty messy after a while. So do you have any tip on how to do it smoother? And the other thing is how should I send information between client and host. The host performs movement, collision detection and such, and the client just draws and collects input. I thought of having the client send CLIENT_UP messages to the host (when the UP key is being pressed), which then takes appropriate action. But how should I inform the client that the movement was ok? Should I send back the new position? I also thought of having a message handler (sort of) which looks for an incoming message, sends it to the handler which might look like this: void NetMessageHandler(MESSAGE msg) { if(msg == CLIENT_UP) client.moveup(); // if it sends a position it could be like this if(msg == CLIENT_POSITION) client.position(received_info); } About the client position part I thought of having each message starting with an integer that describes the message. And if it is for example CLIENT_POSITION then the package should include 3 floats describing the position. Do you understand what I mean? Like having a flag in the start of the package that tells what to receive. Is this a good idea? How did you do it? Thanks alot, this is really bugging me!

Share this post

Link to post
Share on other sites

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