I don't have all your context, but:
If the main case is "give me the objects at x,y" (and not the objects NEAR
x, y), you can easily implement a two dimensional array
var objects = [];
function putObject(x, y, obj) {
if (objects[x] == null)
objects[x] = [];
if (objects[x][y] == null)
objects[x][y] = [];
objects[x][y].push(obj);
}
function getObjects(x, y) {
if (objects[x] == null)
return [];
if (objects[x][y] == null)
return [];
return objects[x][y];
}
I would write this using TDD, and then explore different implementations,
measuring time.
Make it work, make it right, make it fast (attributed to Kent Beck)
Angel "Java" Lopez
@ajlopez
On Sun, May 18, 2014 at 11:25 PM, Joshua Lunsford <
[email protected]> wrote:
> Just remember that you have 16.66ms to do any calculations to produce a
> fluid 60 frames per second. If part of the illusion of creating a seamless
> game world that is querying the positions of objects, then transferring
> them to a client, you have make that query as quick as possible to keep
> that illusion going. We have experimented keeping game objects in redis and
> updating N number of server processes with pubsub... we could get 1-5ms
> response time all on the same box. Still good for gaming at that point, so
> db work isnt off of the plate
>
>
> On Sun, May 18, 2014 at 1:41 PM, Aria Stewart <[email protected]> wrote:
>
>>
>> On May 18, 2014, at 6:02 AM, Paul Vencill <[email protected]> wrote:
>>
>> > I've never done game dev, but I'm curious if there's anything to be
>> gained by offloading this kind of query to the database? Most dbs now
>> (including mongodb) have pretty robust index and search capabilities
>> specifically built for bounding box and shape style queries.
>>
>> I’d imagine that for a couple thousand nodes, doing it in-core would be a
>> lot lower latency. BEyond that, worth considering.
>>
>
>
>
> --
> Thanks,
> Joshua Taylor Lunsford
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/CABPQR%3DF1HAePkTH-L09tQiQcv67WL2OuRQSpqFKJ__7DtUi8dQ%40mail.gmail.com<https://groups.google.com/d/msgid/nodejs/CABPQR%3DF1HAePkTH-L09tQiQcv67WL2OuRQSpqFKJ__7DtUi8dQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/CAMs%2BDqJrWkj80C03Ys9OfwJUqLpOS3DRkzB3NJXTyzP2-CgKHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.