Learning by doing...
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
Well, I just got started with this myself, but my game is coming along nicely so I will try and answer your questions.
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.
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.
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.
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.
My Current Project Angels 22 (4E5)
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement