Sign in to follow this  
walle

Learning by doing...

Recommended Posts

walle    478
I would like to learn multiplayer game making. I thought about making a simple pong clone multiplayer. But I don't really know how to do this. If we do this the simplest possible you have to do: Send the paddle1, paddle2 and ball coordinates to the clients. That's it? I would like to be able to both host and join a game in an aplication, not like in all tutorials I've seen where you build a server whitch you have to run separatly. Would it be simplest to make a packet struct with all coordinates and just send it to both clients? Or would you have a packet struct for each object? I'm doing this in SDL_Net I think. //walle

Share this post


Link to post
Share on other sites
Sir Sapo    769
Well, I just got started with this myself, but my game is coming along nicely so I will try and answer your questions.

Quote:

If we do this the simplest possible you have to do:
Send the paddle1, paddle2 and ball coordinates to the clients. That's it?


Yes, thats all you have to do to get teh paddle coordinates to the clients, however, if you are doing client-server type system where the server does all the work, you will have to send a packet from the client to the server with all of the input data so the server can respond accordingly.

Quote:

I would like to be able to both host and join a game in an aplication, not like in all tutorials I've seen where you build a server whitch you have to run separatly.


If you have an option to host the game yourself, you could just make your game run the server in the background and run the client program on the same computer. Just connect to yourself (I.P. 127.0.0.1) and it will be the same as having 2 clients and no server(and a lot simpler IMHO). If you dont want to do that however, look into client-client architecture. I dont know of any really good Client-Client tutorials, so you may have to try a lot of crap before you get it right.

Quote:

Would it be simplest to make a packet struct with all coordinates and just send it to both clients? Or would you have a packet struct for each object?


Dont really know about that one. In my game I send the client's player's packet info first, then use a for loop to send everyone elses.

Anyways, good luck.

Share this post


Link to post
Share on other sites
Revelations    151
If you want to get fun with this, it should be possible to only send the ball's coordinates at game start, and from there let each client make the decision as to where it should go given the paddle information. To keep things on the level, I'd also throw in a quick synchronizing function to verify the ball is in the same place for both clients("server" instance can do this). This should remove some overhead, and would probably be fun to code, at least for me, since I'm a network code kinda guy.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this