Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2007

Tip: Looking for answers? Try searching our database.

Organizing a World

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Oliphant - 28 Jun 2007 21:27 GMT
I'm creating an application which is game-like, in that it has entities
which move in a World composed of adjacent grids.

At first, the 'natural' way to build the World object as a class is to
create a Grid class, and then create an array of Grid objects to represent
the World.

That is,

ref class Grid
{
   // definition
} ;

ref class World
{
private:

int W ;
int H ;
array<Grid^>   grid_array ;
} ;

And then create W x H Grid objects for the array after allocating enough
pointers for them. This method definitely works. In Theory. But it can be
very impractical in many cases.

My case turned out to be one of the impractical one. This is becuase my
world is suppose to be very big, ala 10k x 10K grids, or even bigger. If I
used the above method, I would need to create 100 million grid objects! Yes,
this is likely within memory bounds, but like I said I might want to have
even higher dimensions for the World.

So, my solution was instead to create row and column link lists, one for
each row and column in the world. I then put the link 'chain' pointers in
each entity that must move in this World. Now the World only 'exists' as a
construct in the inhbitants (the entities!).

With this method I only need (H + W) totaly link lists, and then memory
requirements are only limited by the number of entities in the World! It is
also much faster in terms of collisions and processing, since the program
need only deal with grids that have an entity in them (which it would have
to in both methods). So I find this to be cool organization method I would
share.

As a side note, I then discover that scientists recently have shown the REAL
UNIVERSE might be similar in structure! See the following article:

http://physicsweb.org/articles/news/11/4/14

So, this post isn't a question, it's more me just sharing! :)
Aek - 29 Jun 2007 03:16 GMT
On Jun 29, 4:27 am, "Peter Oliphant" <poliph...@RoundTripInc.com>
wrote:
> I'm creating an application which is game-like, in that it has entities
> which move in a World composed of adjacent grids.
[quoted text clipped - 10 lines]
> to in both methods). So I find this to be cool organization method I would
> share.

Have you looked into a octtree structure for your world? These are
often used in games for static world objects.
They are very fast for culling and collision checks.

Josh

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.