1
\$\begingroup\$

I'm currently planning to develop a real-time multiplayer online game, using the Google Maps API on Android. I thought about having survival-like game play, where you collect resources to build yourself up :)


The players should be able to build structures (houses, shelters, walls, etc.). There should also be random spawned objects, like trees or caverns. There will be many players in a multiplayer game, so there will be many of these objects. I thought about storing all of these objects in a server-based database. Every entity will get an ID and coordinates for their position.

Every player should be able to access and see those buildings, but I can't draw them all at once; I can't even calculate the distance for every structure or object - that just would make the game really slow. At some point, it would crash.


I need a way to manage, draw and calculate all of the structures and objects (which will be stored in my database), when the player is near their saved position. I googled a bit and asked some nice guys in the game development chat; they told me about some methods, like spatial mapping and quad trees. Those would be easy to implement, and the Google Maps API already supports quad trees with coordinates and latitude/longitude markers.

Is this the best way to achieve what I want, or is there a better way to manage, draw and calculate thousands of objects?

\$\endgroup\$
5
  • \$\begingroup\$ Yay Thanks for the downvote . Dont even know why. There aren't any several questions and this one is very detailed. \$\endgroup\$
    – genaray
    Feb 15, 2017 at 5:49
  • 5
    \$\begingroup\$ "at some point it would crash" - I don't see why that is a given. Regardless, you seem to be in way over your head. I strongly suggest starting with something much simpler. Get some smaller projects under your belt and you will have gained the experience you need to come to grips with the decisinos you are wrestling with here. \$\endgroup\$
    – xaxxon
    Feb 15, 2017 at 6:54
  • 1
    \$\begingroup\$ Quadtree is the usual way for managing this kind of thing. \$\endgroup\$
    – pjc50
    Feb 15, 2017 at 9:30
  • \$\begingroup\$ @pjc50 But wouldt it get slow at some point ? Image a quad tree with 10 or 50 thousand objects in it. \$\endgroup\$
    – genaray
    Feb 16, 2017 at 10:06
  • 1
    \$\begingroup\$ So? The whole point of a quadtree is that you only see the objects relevant to your current view. You probably want to allow level-of-detail mapping so the thing doesn't blow up when you look at the whole world. Look at e.g. Ingress and how many "portals" they have. They manage >5m of them blog.enl-ed.uk/2016/01/31/… \$\endgroup\$
    – pjc50
    Feb 16, 2017 at 12:02

1 Answer 1

0
\$\begingroup\$

As far as I can think this through ... You have to store the Data for a area like 2 by 2 KM. Load for every Player individualiy an Square area like 5 by 5 Areas. In this way you get a Field of 10 by 10 KM.

Sure it's not perfect but the solution I would get for ...

\$\endgroup\$
2
  • \$\begingroup\$ So you basicly mean a grid based storage system ? ^^ \$\endgroup\$
    – genaray
    Feb 15, 2017 at 15:24
  • \$\begingroup\$ Yes. Sorry I'm a native German Guy so sorry for confusing words and sentenses ;-) \$\endgroup\$ Feb 16, 2017 at 15:59

Not the answer you're looking for? Browse other questions tagged .