KryoNet help

Started by
5 comments, last by hplus0603 11 years, 11 months ago
I just started working on a game in Java using Slick2d and I want to make the game multiplayer. I don't need to make anything massive, I just want to make a basic RPG to see how it works and I thought it would be cool if I could make it so that I could give a copy to my friend so he can see what I'm doing(he just started programming). I think it would be a pretty good learning experience as well for myself. I'm thinking of using KryoNet for it because I don't want to do it from scratch. Does anyone know how I should start with this? Any tutorials? Also, what will I need to change in my game as it is? Right now I haven't done a lot, just got a sprite moving around a tileBased map with basic collision with tiles and the outside of the map. Another thing, would I make a separate project for the client and one for the server? Also where would I add the client/server in my slick2d statebasedgame?

Sorry for the cluster of questions, I just kind of spewed ideas onto my keyboard.

Thanks in advance.
Advertisement
By "Project" I assume you mean in an IDE such as Eclipse.
There are two basic ways to do it.
One is to build everything as one application, which you start up in "server" or "client" mode, and when in "server" mode, it doesn't render, and when in "client" mode, it doesn't listen for new connections (for example.)
The other is to use THREE projects. One library project for "Common," which contains all the code that needs to be known by both client and server -- data structures, game rules, etc. Then one application project for "server" that uses the "common" library and adds only the server-application-specific bits, and another application for "client" that also uses the "common" library and adds only the client-application-specific bits.
enum Bool { True, False, FileNotFound };
I'm really confused, I've never done anything with networking before and I'm confused on how this all works. Which way would you suggest?
Easiest to get started, and easiest for players if you allow player-hosted servers, is to build a single executable, which can be started in "server" or "client" mode.
enum Bool { True, False, FileNotFound };
Okay, I understand that much, but how do I learn how to do this?
Like, would I make the menu have 2 options, host and join? Then from there it sends you into a gamestate for either one, depending on which one you pick?
There are two ways you can learn this:

1) Read other people's code that already does the same thing.
For example, the source for Quake (and Quake II, and Quake III, and now Doom III) is open source. It may not be easy to get into, but it's probably really rewarding once you do. Nothing worthwhile was ever easy :-)

2) Try it yourself, and measure/observe whether it works. When it doesn't, quantify the failure, and go back to doing it differently, compensating for that failure. Repeat.

In reality, you'll probably need to do both.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement