Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 2576 times)
0 Members and 1 Guest are viewing this topic.
Offline chelinho
« Posted 2013-06-09 06:36:30 »

Hello,

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?




chelinho139
-MobileCo Studios
Offline marcuiulian13

Senior Member


Medals: 5
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).

chelinho139
-MobileCo Studios
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..

chelinho139
-MobileCo Studios
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (39 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!