(GridWorld as in Collegeboard's AP exam case study thing)
So, I've been working on this game during my free time for a few years now, and it's coming along pretty nicely. I have a nice lil' stick character that runs around in a grid and picks up items and fights monsters and stuff. Now, I think I'm ready to take it to the next level (for as much of a choice as I have anyway, since I kind of need to make a project for my networks class, hah...), and I'm a bit stumped on how to progress.
I've made a few programs in the past using ServerSocket, where I have one Server running and several Clients can connect to it and receive messages, but they have all been simple text programs that don't exchange more than a few Strings. Sockets are what I was thinking of using for this, but I'm not sure how to set it up...
Now, when GridWorld is run, it automagically pops up what looks like a JFrame, which contains the grid and all actors in it. In the main source file that contains all the code for the, uhh, "engine", if you will, there are basically 2 giant methods: step(), which controls what happens per every unit of time, and keyPressed(), which controls what happens when the user pushes a key. Now, I was thinking that step() for sure needs to be on the server side, and keyPressed() should be on the client side, along with the window (of course—otherwise how will the user be able to see what they're playing?) The idea is to have the main game that governs all the NPCs' actions and game calculations to be running only once, on the server, and for multiple clients to be able to connect to it and each have their own character in the game (basically like a mmorpg).
But like, how exactly would I split it up? (Or if that's even the right way to go?) I'm not even sure on how to pass data back and forth between the server and client(s)—for my simple text programs that I've mentioned, I've always used PrintWriter and BufferedReader. I found that PrintWriter does have a print() method that accepts any Object, but then how would the BufferedReader receive it? It doesn't have any method that will read an Object.
So basically, I want to know all the specifics of exactly what the server should do, what the client should do, which libraries I should use, and where to put certain functionality.
All right, I've settled on using Sockets and doing the Serialization stuff myself with ObjectOutputStreams and stuff. I've figured out where to put everything, and it's basically working fine, though I still have the inevitable glitches in the game itself that I'll need to hammer out. Thanks, Tim :)