Thread: Roomless world
View Single Post
Old 08-18-2014, 05:19 AM   #3
KaVir
Legend
 
KaVir's Avatar
 
Join Date: Apr 2002
Name: Richard
Home MUD: God Wars II
Posts: 2,052
KaVir will become famous soon enoughKaVir will become famous soon enough
Re: Roomless world

My approach is even simpler. Creatures, Objects, Dungeons, Portals, etc, are all types of Thing. Each Thing can contain other Things, and each Thing also stores its own X/Y position (which is a relative position). The original design included the use of abstract containers for grouping Things together based on proximity, but I never bothered implementing it - I tend to avoid premature optimisation, and while searching the entire container isn't exactly efficient, it's still an insignificant fraction of the processing effort.

One other difference is that your Things are rectangles, while mine are circles - you store two points, while I store one point and a radius. I do use rectangles for areas though (e.g., the "black forest" might be defined as all forest terrain between 50/50 and 500/500).
KaVir is offline   Reply With Quote