View Single Post
# 14 07-02-2005 , 11:52 AM
Sparaig's Avatar
Subscriber
Join Date: Jan 2005
Posts: 5

Mel Shuts down maya

Originally posted by InvaZimm
I get what you are saying with the footprint, tho each buidling will have to have it's own since they are different sizes. I guess my only problem is being able to fathom how to do it. I've been staring at this project for days on end, and I think that's probably where I got the mental roadblock about this.

Actually, that kind of thing IS a form of 2D collision detection. Games programming books show how to do this, I believe, but the most efficient algorithms use bit manipulation operators which MEL apparently doesn't have.

The basic way to do it is to define your map to be a bunch of blocks 1 unit (feet/yard/inches/bricks/blocks/whatever) on a side. Now create a 2D array that is the size of your map in units. Each time you want to place a building, check the array to see if there is already a block/brick in that position --if there is, then you have to move over until you can't find one (or move down or both). Once you place a building, update the position array so that set of blocks is marked "taken". Continue til done. Hope this helps.