Slick2D + Kryonet guidance

I’m trying to create a multiplayer game using Slick2D and Kryonet and need a few tips to get started. I’ve already done a bit of networking in Kryonet to test it out, so I know how it all works, but it would be helpful to have some sense for the architecture of the whole thing. What would be the best way to set up a client and server game system?

Some more specific questions that I have:

  • Should I be running Slick from the client, server, or both?
  • Should I be sending the whole game state or just things like entity data, positions, etc?
  • How often should I be sending the information to the client?
  • How and how often would input be sent from the client to the server?
  • What code should I have on both the client and the server?

Note that I want to keep the server and client together, so that it is possible to host a server and play on it from the same program.

Any help is appreciated!

I like that your questions are really concise! :slight_smile: (Adding that to the “Good Examples” Wiki Page ;D )

  • Should I be running Slick from the client, server, or both?
    It’s a good idea to have Game Logic and Rendering seperated strong enough, so that you can run your Game without rendering anything. That’d allow your Server to run as a terminal / console program or in the background of a already running Slick game :wink:

  • Should I be sending the whole game state or just things like entity data, positions, etc?
    You might want to start with sending the whole game state. Later you might try out something like only sending the changes. You can experiment with either only sending what the User Clicks and Types (Mouse & Keyboard Input), with the server responding with the current game state (No client-side prediction, “Server like a terminal”, how John Carmack called it). You can always try out everything else later.

  • How often should I be sending the information to the client?
    It really depends. What I’d suggest is sending it about ~20 Times a second (I think that’s just as frequent as in Minecraft) and interpolate between the gamestates so that you can render at 60 Times a second :slight_smile:

  • How and how often would input be sent from the client to the server?
    I’d have the same update rates from client -> server like from server -> client.

  • What code should I have on both the client and the server?
    Ideally, the game logic code should be exactly the same :slight_smile: Note, that many programs don’t do that. The Minecraft server, for example, does only route the recieved game updates from one client to the other clients, while also checking that they don’t fly in the air for too long (Do you know the “You got kicked from the server because of flying” dialoge? :wink: ). It also checks the speed at which the client’s player travel, afaik.

Hope this helps you :slight_smile:

Thanks for the help, I appreciate it.

I’m running into a problem with serialization though. I’m using the jbox2D library for physics, and it isn’t working well with Kryo. There seems to be two classes that contain instances of each other, causing Kryo to get stuck in an infinite loop of serialization. Is there any way around this, or should I find a way to avoid sending jbox2D data?