Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been working on programming an online RPG in Java for a while now. It's a huge project and way too hard for me, but I'm having fun learning.

server and client: Java
database: MySQL

I have mainly been working on the GUI but now have started to draw a map based on the tileset returned from my server. I am now ready to grab my users coordinates from the db, but I am wondering if I should have them sitting in a temp variable on my server or just access/change the coordinates in the database.

Long story short: hit db always for lookups and changes or have a LinkedList or something on the server?

share|improve this question
"tileset returned from my server": You are certainly saying that you deliver the tile set once and then it's stored locally, yes? – Hackworth May 23 '12 at 20:52
@Jim: not quite, I still need to come up with a strategy for that. I dont want users to be able to alter their map files or anything so I wanted to stay away from storing anything besides images on client pc. right now I am sending my map with a giant pipe/comma delimited string ("17|17|13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13...) with commandOut.writeUTF(); I am just assuming this approach will not work because not sure what the upper limit for writeUTF is. Any ideas on what a good approach would be here?? Any help would be greatly appreciated. Thanks. – KisnardOnline May 25 '12 at 0:13
up vote 4 down vote accepted

Assuming that you're going for persistence between runs, using the server to maintain the save state of your users for the RPG and as the authoritative source to restore from...

Storing the positions in the DB is fine for a turn based design and guarantees your players won't lose any steps if they crash. This makes players happy.

For a realtime game you'll want to cache and work on positions in memory, any structure like a list or array is fine for your scale, and occasionally store that to the DB. Here you have to balance how often you save to DB between making players happy by not losing too many steps if you crash, and slowing your server down with too many DB writes.

That's it, no need to get more complex until you approach MMO server loads.

share|improve this answer
great thanks so much!!! sucks I wont be able to just use the db because its realtime moving game. my goal is mmorpg :) – KisnardOnline May 25 '12 at 0:10
Side question... any clue a good way to handle characters near the player? Should all client moves be sent to each client? Playing at the max resolution the tile set is 45x29. Any help on this would be greatly appreciated. Thanks so much :D – KisnardOnline May 25 '12 at 0:16
@JayAvon maintaining "who is near" and "how much do I send, how often" is a whole pile of subjects on their own. You're already thinking of part of the answer, to only send characters in the same tile set area as the player, and that's a fine way to go even as you scale up. Later when you have a real need a good question to ask will present itself, until then I wouldn't worry too much. G'luck and don't forget to have fun along the way. – Patrick Hughes May 25 '12 at 0:42
Awesome thanks so much... dont know how much I appreciate the help. Any books you recommend on things like this? Also if you have a second can you take a stab at my other question above on sending map to client? – KisnardOnline May 25 '12 at 1:21
Maps/data on PC titles are typically stored local on the PC, usually during an install of update. When the main executable runs it quickly verifies that local game data is valid by generating a checksum of some kind and asking the server to say good or bad. You can see this happen at almost any multiplayer game startup as a pause while the client sorts out the checksums. On non-PC (aka web based) titles the local copy is cachhed instead of installed and the cache mechanism downloads new copies of altered/old data automatically. – Patrick Hughes May 25 '12 at 1:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.