• entries
743
1924
• views
584355

Urg

267 views

Quite good night last night. Getting far to old for this though. Once you pass the magic 30, you just can't drink like you used to.

Hey - I've just discovered that me here on this site gets the first two Google hits for "EasilyConfused". Groovy.

Little to report on the game this morning. I've just implemented the bits to restore the device and so on if you Alt-Tab out and back in again. Not really feeling well enough at the moment to approach anything more complex than that.

Got my edge tracing algorythm working last night, as I mentioned. The main thing with it is that you need to step along each edge by a fixed amount (the dimension of a map block in this case) but you need to ensure that you sample all four corners, regardless of the size of the CRect.

Solution is to just move clockwise around the rect, for each edge starting at the corner. This does mean that if an edge is exactly BlockDimension+1 wide or high, a corner gets sampled twice. Not a major issue here since sampling from the map grid is pretty fast, but would need to be special cased out if it was important.

On the off-chance that anyone cares, here is the edge sampling code:

bool CMap::Collisions(CRect R,std::vector &V){	size_t No=V.size();    for(int X=R.X;X        {		CMapCell C=MapCells[At(X,R.Y)];		V.push_back(CCollisionStruct(ComputeRectAt(X,R.Y),C.Layer));        }    for(int Y=R.Y;Y        {		CMapCell C=MapCells[At(R.X+R.W-1,Y)];		V.push_back(CCollisionStruct(ComputeRectAt(R.X+R.W-1,Y),C.Layer));        }    if(R.H>1)        {        for(int X=R.X+R.W-1;X>=R.X;X-=BD)            {			CMapCell C=MapCells[At(X,R.Y+R.H-1)];			V.push_back(CCollisionStruct(ComputeRectAt(X,R.Y+R.H-1),C.Layer));            }        }    if(R.W>1)        {        for(int Y=R.Y+R.H-1;Y>=R.Y;Y-=BD)            {			CMapCell C=MapCells[At(R.X,Y)];			V.push_back(CCollisionStruct(ComputeRectAt(R.X,Y),C.Layer));            }        }	return No!=V.size();}

Man, this forum really buggers about with tab characters.

There are no comments to display.

Create an account

Register a new account