|
I'm confused by the following code provided in the developer documentation:
Why would an organism with a cellRadius of 1 occupy a rectangle that is 3 cells wide minus 1 pixel? Is it assumed that an organism occupies 1 cell plus a number of cells in radius around that center cell? Would it be correct to say that an organism's position would have to move between 1 and 8 pixels before it would occupy a different set of cells? Finally, is blocking caused by trying to occupy the same set of cells as described by this formula... or can there be overlap and blocking be determined by a rectangle precisely bounding the actual position of the organism?
??? width = (((cellRadius*2+1)*8)-1) ???
Function GetBoundsOfState(orgState As OrganismState) As Rectangle Dim origin As Point = orgState.Position Dim cellRadius as Integer = orgState.CellRadius
Dim p1 As New Point( _ (CInt(origin.X/8))*8, _ (CInt(origin.Y/8))*8 _ )
Dim bounds As New Rectangle( _ p1.X - (cellRadius*8), _ p1.Y - (cellRadius*8), _ (((cellRadius*2+1)*8)-1), _ (((cellRadius*2+1)*8)-1) _ )
Return bounds End Function
|