Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Online rpg: best way to send map info  (Read 4783 times)
0 Members and 1 Guest are viewing this topic.
Offline chelinho
« Posted 2013-06-09 06:36:30 »


Im building a simple online rpg game. I currently have the following:
  • Online Players Hash
  • Npc List
  • Active Spell List

Using a UDP socket i send the serialize version of each of them, the client receives them and create a view for each one.
Everything is running very good until now.

The problem arises  when I want to make things a little better.
Due that my current map is small, I have a few NPC's, Players and spells. However when want to start adding more I cant keep sending all map info.
This brings the fact that I only will need to send the data NEARBY the player's position.

It only occurs to me this solution:
In each individual server thread, check the players position, and iterate over the list grabbing only nearby objects.
However this method will consume a lot and will be very slow.

Any other ideas?

Offline marcuiulian13

Senior Devvie

Medals: 6
Exp: 3 years

« Reply #1 - Posted 2013-06-09 17:09:57 »

You can divide the map into chunks and then use some sort of binary search to find what chunk you should send to the player.

Getting a project done is by far the most hard thing in game development.
Offline chelinho
« Reply #2 - Posted 2013-06-09 17:41:15 »

thought of that too. The problem is the borders of the "chuck".

What happens if a player is almost at the end of one chuck, he wont be seeing what is next to him?
How would you do so to manage when the player is near the limit of one chuck?

Also that will require updating on what chuck the player is in every player update (which is not a big deal).

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sproingie

JGO Kernel

Medals: 202

« Reply #3 - Posted 2013-06-09 18:09:07 »

Amusing as it is to see my real name (Chuck) used like this, I think the word you're looking for is "chunk".  Smiley  Tho if I don't lay off the beer and curries, I'll certainly be deserving of the latter name too  Cranky

The answer is, when a player enters a chunk, you load enough surrounding chunks to cover the entire view distance plus one extra chunk (so the horizon doesn't appear in choppy fashion).  In fact, you'll probably want even more chunks in memory than what's visible so you can still run the simulation in them, though you can fudge things a bit if you can prove no one can see what's happening. 

As for keeping the current chunk updated for each player, since you always have to know exactly where in the world every player is, knowing what chunk they're in should be a trivial matter of dividing their coordinates by the size of the chunk.

Once you've generated a chunk, don't think of it as "loading" or "saving" it -- they all exist, just that some might have to be moved from disk to memory or back.  Thinking of it that way, it's just more of an optimization problem than a show-stopping design problem.  Don't be afraid to just throw every chunk in RAM to start out while you're developing -- as long as you keep some notion of discrete chunks, it'll be simple to offload them to disk or stream them over the network later.

Oh, and don't use UDP unless you're fine with dropping packets.  If you find yourself retransmitting them, you're already well on your way to poorly reinventing TCP.

Offline chelinho
« Reply #4 - Posted 2013-06-09 18:36:06 »

haha thanks Chuck!  Cheesy
I will think further on that idea..

Pages: [1]
  ignore  |  Print  

EgonOlsen (77 views)
2018-06-10 19:43:48

EgonOlsen (57 views)
2018-06-10 19:43:44

EgonOlsen (77 views)
2018-06-10 19:43:20

DesertCoockie (259 views)
2018-05-13 18:23:11

nelsongames (157 views)
2018-04-24 18:15:36

nelsongames (156 views)
2018-04-24 18:14:32

ivj94 (897 views)
2018-03-24 14:47:39

ivj94 (161 views)
2018-03-24 14:46:31

ivj94 (810 views)
2018-03-24 14:43:53

Solater (174 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!