Multiplayer Pong

Started by
12 comments, last by LEPT0N 17 years, 9 months ago
Hey everyone, I'm trying to make a 2D multiplayer game that can be played over LAN. After looking around it seems like openTNL would be great to use, however I haven't found any good tutorials / example code to show how to use openTNL. I basically just want to be able to have a networked gameworld across LAN, and the user would never have to input IP addresses, games would be broadcasted to any other client in shouting distance. So first off, is OpenTNL the kind of thing I'd want for this? I've heard it's very nice and powerful, but how's the learning curve? And also, are there any nice tutorials for this sort of thing? I've searched around GameDev and openTNL's site and haven't found anything that's helped me much. Thanks for any Help!
Advertisement
If I may, I suggest that you start learning to program multiplayer games with something other than pong. Pong is a real-time game, and as such is very difficult to make work. You should probably start out with something turn-based, until you have a solid understanding of networking, as synchronisation of real-time environments is a very tricky subject.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by swiftcoder
If I may, I suggest that you start learning to program multiplayer games with something other than pong. Pong is a real-time game, and as such is very difficult to make work. You should probably start out with something turn-based, until you have a solid understanding of networking, as synchronisation of real-time environments is a very tricky subject.


I understand that things would be easier in a turn based game, but would multiplayer pong really be that bad over LAN? Simply send out your paddle's position and velocity every frame (or every couple frames) and every frame, read in any messages you got over the network to update your opponent's paddle? I know it's most likely more difficult than I'm making it sound, but it's what I want to do. I understand what you're saying, it's just not for me :P

Anyone else?

Quote:Original post by LEPT0N
I understand that things would be easier in a turn based game, but would multiplayer pong really be that bad over LAN? Simply send out your paddle's position and velocity every frame (or every couple frames) and every frame, read in any messages you got over the network to update your opponent's paddle? I know it's most likely more difficult than I'm making it sound, but it's what I want to do. I understand what you're saying, it's just not for me :P


it depends if your want peer-to-peer, or server based pong, if it is peer-to-peer: don't forget that the messages take time to arrive (not as much on a LAN, but it is still an issue). So when your message arrives, it applies to some time in the past, but affects the world at the current time, so the two players will get further and further out of sync, until eventually the ball goes right through one players paddle, because the other players computer thinks it is somewhere else.

Server based pong is easier (and I recommend this as the way to go for your first attempt), as the server always has the authoritative game state, and the clients are just dumb-terminals, sending input to the server and receiving positional data back.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Well yes, that's all in the implementation details. server/client would probably be the way to go. However that still leaves the fact that I still need to find some tutorial on openTNL or something similar to get me started :P
hhe, sorry that I can't help with your learning, but, I might add a little word for you to consider when you actually write the game, ad it is that you should keep in mind that sending the paddles stats isn't that important, I mean, of course you have to send them for the game to seem uncheated to the players, but, the most important thing would be to send the balls postition and speed (direction) after the paddle hits it, and the client will just calculete each frame from there, instead of sending the data each frame (of course that you have to make sure that the message arrives, and also, you should be careful about unsinchronization issues). About the paddles.. just send their position/action/speed(direction) (depending on how you decide to implement it) whenever it changes but without worrying about making that data reliable.
I assume that you have realized that I'm talking about UDP here, I'm not sure of what TNL uses..

So! I hope this helps you when the time comes (and I hope to be righ about this, however, anyone intrested in proving that I'm wrong is welcome to argue with me).

PS: hmhm, are you sure TNL doesn't include some help/tutorials/demo files?
Allright, now I just spent the few seconds to google for documentation for OpenTNL (which you should do before posting, next time).

This would seem to be the most relevant result (and also the first): OpenTNL Documentation
There is quite a bit of information, and plenty of instructions for beginners.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by swiftcoder
Allright, now I just spent the few seconds to google for documentation for OpenTNL (which you should do before posting, next time).


You know what assuming does... :P

I already saw that site, but the documentation and tutorials were too generalized and I thought weren't good for beginners like me. I came on here after searching Google to see if anyone here knew of other OpenTNL tutorials.
If u cant find any tutorials i would consider a book theyre always the best for beginning things, look in your local library or buy one.
Quote:Original post by LEPT0N
I already saw that site, but the documentation and tutorials were too generalized and I thought weren't good for beginners like me. I came on here after searching Google to see if anyone here knew of other OpenTNL tutorials.
Welcome to lesson #1 of becoming a good programmer: Picking up APIs with crappy documentation. [smile]

This topic is closed to new replies.

Advertisement