* vptr = wallColor;
for (; j < SCREENJHEIGHT; j++, vptr += 320 )
* vptr = FLOOR_COLOR;
}
Fixed checkVWalls ( Angle angle ) {
int xTile = fixed2lnt (locX ); // cell indices int yTile = fixed2lnt (locY ); Fixed xlntercept; // intercept point
Fixed ylntercept;
Fixed xStep; // intercept steps
Fixed yStep; int dxTile;
if (fixAbs ( coTang ( angle )) < 2 ) return MAX_FIXED;
if ( angle >= ANGLE_270 || angle <= ANGLE_90 ) {
xTile ++;
xStep = ONE; yStep = tang (angle); xlntercept = int2Fixed (xTile); dxTile = 1;
}
else
{
xTile --;
xStep = -ONE; yStep = -tang (angle); xlntercept = int2Fixed (xTile + 1); dxTile = -1;
}
// find interception point ylntercept = locY + ((xlntercept - locX) « 15) / (coTang (angle) » 1);
for (; ; ) {
yTile = fixed2lnt (ylntercept); if ( xTile < 0 || xTile > 52 || yTile < 0 || yTile > 9 ) return MAX_FIXED;
if ( worldMap [yTile][xTile] != " )
return ((xlntercept - locX) » 8) * (invCosine ( angle ) » 8);
Компьютерная графика. Полигональные модели
xlntercept += xStep; ylntercept += yStep; xTile += dxTile;
}
}
Fixed checkHWalfs (Angle angle ) {
int xTile = fixed2lnt (locX );
int yTile = fixed2lnt (locY );
Fixed xlntercept;
Fixed ylntercept;
Fixed xStep;
Fixed yStep;
int dyTile;
if (fixAbs (tang ( angle )) < 2 ) return MAX_FIXED;
if (angle <= ANGLE_180) {
yTile ++;
xStep = coTang (angle); yStep = ONE; ylntercept = int2Fixed (yTile); dyTile = 1;
}
else
{
yTile -;
yStep = -ONE; xStep = -coTang ( angle ); ylntercept = int2Fixed (yTile + 1); dyTile = -1;
}
xlntercept = locX + ((ylntercept - locY) « 15) / (tang (angle) » 1);
for (;;) {
xTile = fixed2lnt (xlntercept); if ( xTile < 0 || xTile > 52 || yTile < 0 || yTile > 9 ) return MAX_FIXED;
if ( worldMap [yTile][xTile] != '1)
return ((ylntercept - locY)» 8) * (invSine ( angle ) » 8);
xlntercept += xStep; ylntercept += yStep; yTile += dyTile;