drawVertLine ( col, bottom, bottomLine [col], FLOOR_COLOR ); bottomLine [col] = -bottom;
}
else
bottom = bottomLine [col];
topLine [col] = bottom + 1; bottomLine [col] = top -1;
// now draw visible part of wall drawVertLine ( col, top, bottom, WALL_COLOR );
}
}
void drawLowerWall (int coM, int col2, int bottomHeight, int topHeight,
int v1, int v2 )
{
Fixed b1 = int2Fixed ( 1001 + ( bottomHeight * VSCALE ) / v1 ); Fixed b2 = int2Fixed ( 1001 + ( bottomHeight * VSCALE ) / v2 ); Fixed t1 = int2Fixed ( 1001 + (topHeight * VSCALE ) / v1 ); Fixed t2 = int2Fixed ( 1001 + (topHeight * VSCALE ) / v2 ); Fixed db = ( b2 - b1 ) / ( col2 - coM ); Fixed dt = (t2-t1 )/(col2-col1 ); int top, bottom;
if ( coM < 0 ) // clip invisible part {
b1 -= coM * db; t1 -=col1*dt;
coM = 0;
}
if ( col2 > 320 ) col2 = 320;
for (int col - coM; col < col2; col++ ) {
top = fixed2lnt (t1 ); bottom = fixed2lnt ( b1 ); t1 +=dt;
b1 +=db;
if (topLine [col] > bottom Line [col]) continue;
if (top < topLine [col])
top = topLine [col]; // adjust top
if ( bottom < topLine [col]) bottom = topLine [col];
if ( bottom <= bottomLine [col]) // draw floor
drawVertLine ( col, bottom, bottomLine [col]++, FLOOR^COLOR );
else
bottom = bottomLine [col];
if (top < bottom ) // now draw visible part
{ // of wall
drawVertLine ( col, top, bottom, LOWER_WALL„COLOR );
if (top < bottomLine [col]) bottomLine [col] = top -1;
}
else
if ( bottom < bottomLine [col]) bottomLine [col] = bottom -1;
}
}
void drawUpperWall (int coh, int col2, int bottomHeight, int topHeight,
int v1, int v2 )
{
Fixed b1 = int2Fixed (1001 - ( bottomHeight * VSCALE ) / v1 ); Fixed b2 = int2Fixed ( 1001 - ( bottomHeight * VSCALE ) / v2 ); Fixed t1 = int2Fixed (1001 - (topHeight * VSCALE ) / v1 ); Fixed t2 = int2Fixed (1001 - (topHeight * VSCALE ) / v2 ); Fixed db = ( b2 - b1 ) / ( col2 - coh ); Fixed dt = (t2 -11 ) / ( col2 - coll ); int top, bottom;
if ( coll < 0 ) // clip invisible part {
b1 -= coh * db; t1 -= coll * dt; coll = 0;
⇐ Предыдущая| |Следующая ⇒