New guy introducing and looking for information about 2D multiplayer/network architecture

Started by
-1 comments, last by Gazu 11 years, 10 months ago
Hi there fellow gamedevs and those who'd like to be, such as me.
The last 4 days or so I've been into playing around with 2D animation and, for the purpose of being able to develop games with multiplayer features, networking via sockets, and of course encountered many problems, of which some I have been able to resolve after some research.
But I might as well try to get some input here instead of trying to google everything for hours (which I will of course continue to do biggrin.png )

Since this is my first post here, some information about myself might be a good start, so just skip the next "section" if you are just interested in my current problems biggrin.png

I'm currently 23 years old and studying for a bachelor degree in informatics (also I'm from germany btw).
Some of it is interesting, some is not, but we don't really get into things which would be crucial for game developing (or rather, I can't see those aspects yet).
In my free time I like to play electric/acoustic guitar, do some sport (I guess most of you havn't heard of tricking) and playing games myself of course. Over the years, I often tried to find a way into developing games, but have never been persistent enough to get anywhere (last thing I did was a well working snake game in python...yea, the irony.), though my accomplishments over the past few days made me think I can do it now if I keep trying. Or at least learn a bunch of things which might me help one day.
That's actually the main purpose of it all, learning, getting "into it" y'know biggrin.png
So I don't actually have a finished concept for a game I'd like to develop, but rather I'm gathering things I might want to implement, and try learning how to do it so that I first know which technical features are possible for me to implement.
After that I'd want to think about which what kind of game could make good use of those features.
Though I already have some ideas which won't let me sleep at night, dammit.

So heres what I achieved and what I couldn't achieve so far the past few days.
I'm currently using Ruby and the rubygame gem, which works good so far.

First step was, just creating a screen and having an animated sprite, moveable by the player.
Wasn't too hard, works well, movement and animation is fluent and appropiate at any given time.I didn't use the Sprite class though, for me it was easier to work without it as first (will need it for collision though, I guess).

Next step already went into networking, My goal for that matter was to be able to connect 2 clients to the server, both being able to move and also see the movement of the other player. I'm still far from there, but made some progress:

1. got familiar with TCP/UDP Sockets and decided to use UDP sockets because they are faster and the game view should update constantly anyway, so a bit of missing data here and their would be affordable.

2. Communication between the server and multiple clients works, one client sends a string to the server and all clients receive it. also keeping track on how many/which clients are connected, so everything works as long as i dont exit a client by closing the output window. (instead use ESC or the QuitEvent of the gamescreen)

3. got information about serializing, so I could send whole objects via sockets. Also working.

4. got information about threads, so I could let every client have 1 thread handling the input from the server.
Doesn't work quite well, I don't know if its me or Ruby's threads, but the threads get to work a bit every few seconds, which would be equal to massive lag in a multiplayer situation. Possibly trying to use Java threads via JRuby (have read about it somewhere)

So now the problems I couldn't resolve so far:
1. I'm confused, like, what the hell? biggrin.png I don't even know where to start. Actually, that covers the first problem.

2. What should a network architecture for these kind of tasks look like? Like, should I create a class for the server, the client, then in a different file creat server/client objects?
How can I build the code so, that the server handles all the logic, while the client only gets the user inputs and updates the view? (to prevent cheating). Currently, the calculations for the new positions for x/y values and animation cycles are still done within the client's code, according to the current framerate and the general speed of movement of the player(which is determinde by some vairable). I'm kinda confused as to what impact on performance and updating it would have to get all the logic to the server, sending the new positions back, and what the best way is to achieve that code-wise.

3. Serializing, how to efficiently utilize it?
Obviously I need to send serialized objects to the server, which recognizes the objects and can work with the data, then sends the serialized object back so the client can update the screen according to the data. Sounds simple, but I'm struggling with how to actually implement all that stuff, I have the feeling I'm just over-thinking many things and miss the obvious solution.

4. The threads, I already mentioned that before. They are slow. Like, really. Whats the point of a thread which only gets some time to work every few seconds, here and there. I guess there are applications which can make use of that, but a 2D Multiplayer? I highly doubt it biggrin.png

One thing I'd also like to say, some of you will most likely remember having googled all these topics on how to start making games, all those guys in forums asking that question and being told they need to know the basics, make a small little simple game before doing anything bigger.
So just saying in advance, please don't give me that, I've been there biggrin.png
But I guess you're all smart enough to see that I'm already trying to dig up the basics and yea...wow, that was much, much more text than I expected, guess I got carried away a little.

Anyways, anything to help me out with any of the topics I have posted here is appreciated, be it references to tutorials/guides, sharing your own experiences or just some thoughts you made up on the spot.

This topic is closed to new replies.

Advertisement