[gameprogrammer] Re: storing lists of units
- From: Tom Wilson <t.wilson@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Tue, 28 Sep 2004 18:31:49 +0100
Roger D. Vargas wrote:
> I need to store the list of NPCs in my game, and Im looking the best way
> to do so. I need to be able to quickly find only the ones closer to
> certain location to pass them to my lua script. Whats the best structure
> and algorithm to do this?
>
>
Try using space sub-division. So if it's a 2D game, divide the screen
up into say 8 rectangluar areas, each area has an associated list that
stores the NPC's that are entirely in the area or overlapping into the
area. When you move an NPC you can update which lists it appears in.
All you need to do to is find which area(s) your location is in, and
then the lists will tell you which items are close.
- Tom
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] storing lists of units
- From: Roger D. Vargas
Other related posts:
- » [gameprogrammer] storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- » [gameprogrammer] Re: storing lists of units
- [gameprogrammer] storing lists of units
- From: Roger D. Vargas