Multiplayer game with libgdx

Hello i am trying to make a multiplayer game with libgdx + kryonet.
and i get kinda confused…

Some questions -

  1. The server should be in a libgdx project, or in a plain java project?
  2. If i should make the server in libgdx project, how can i load the gdx without creating a screen, i mean the server doesn’t need a screen right?

Thanks a lot :slight_smile:

The server doesn’t have to be a LibGDX project, in fact there is almost no point in making it one. Create it separately.

Thanks that’s what i thought, here i have another problem, i have a tiled map, which is the game map, so in order to check collision i will need to load it right? how can i do that?

You should make a single player local game first :slight_smile:

I did, i made a single player libgdx game, now i want to implement the multiplayer feature.
So as i asked, i have a tiled map which is the game map, and in order to check collision, i will need to load it into the server, right? how can i do that? because with plain java project you don’t have any tiled map loaders or something.

No you won’t need to. Check collisions client side for now, focus on actually learning networking before you move to advanced networking, trust me.

ok thanks, i will work on some other things, like the client’s input and such… and will make the collision detection client side for now…
But i will be really glad if you will tell me how should i do the collision detection server side, with tiled map please :slight_smile:

From the “Support For TMX Maps” on the GitHub page under Java:

Seems like a good place to start. :wink:

Depends what route you wanna go down, many involve a world of hurt ;).

Most professional games will have a server that loads the entire map (never renders it obviously), and calculated collisions exactly as you probably are in your single player version. The people ‘playing on the server’ will also calculate collisions themselves, then just send what they have done (e.g. im moving forward and ended up here or something). This is when the server checks its collisions results with the clients, and send the client a correct version if it went wrong. This is essentially how you stop someone editing their client to cheat and go through walls or always claim they’ve shot someone, or w/e.

If you’re making a small game, or even better if its co-op (no pvp) then this is unnecesary, I don’t recommend it anyway as its extremely difficult when compensating for the lag time it takes to send and receive messages.

So really it all depends what your game does… It may be best just to use the server to tell all the players what each one has done, and forget doing server side collision for now. Once you have that running smooth you can look at what problems exist, and start working on a solution.

But tl’dr your question about how to do it on server side, you keep track of the players state, receive his actions, and check his movement or w/e exactly the same as in singleplayer, so yes you need to load the collision data, be it a tiled array or bunch of squares or w/e

Edit: I just read your other thread about its being a 2d fighting game. That isnt easy, you’ll need to do a fair bit of reading up on the subject. GL

Yeah… i actually did already the single player and it works pretty awesome and smooth. so i decided why not adding the multiplayer? i know its hard, but what can you do? when there will be a pill that will make everything a lot easier i’ll be glad to use it, but till then… :wink:

Id you’re really serious about making a proper multiplayer server type situation, I’d recommend

http://gamelix.com/resources/Unity3D%20Forum/Interpolation%20Explained.pdf

and

https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

But I warn you just the thought of implementing it made me yawn and watch TV. You could probably botch some little system together that balances programming time/ease and results accordingly to what you want. I only do multiplayer stuff that doesn’t require decent lag compensation.