- long nColor;
- short nIndex;
- unsigned int nXPos, nYPos;
- unsigned int iWidth, iHeight;
-
- pShadeBob->nVelocityX += ( ( RANDOM() % 200 ) - 100 ) / 1000.0F;
- pShadeBob->nVelocityY += ( ( RANDOM() % 200 ) - 100 ) / 1000.0F;
-
- if( pShadeBob->nVelocityX > 4 ) pShadeBob->nVelocityX = 4;
- else if( pShadeBob->nVelocityX < 3 ) pShadeBob->nVelocityX = 3;
- if( pShadeBob->nVelocityY > 4 ) pShadeBob->nVelocityY = 4;
- else if( pShadeBob->nVelocityY < 3 ) pShadeBob->nVelocityY = 3;
-
- pShadeBob->nAngleX += pShadeBob->nVelocityX;
- pShadeBob->nAngleY += pShadeBob->nVelocityY;
-
- if( pShadeBob->nAngleX >= nDegreeCount ) pShadeBob->nAngleX -= nDegreeCount;
- if( pShadeBob->nAngleY >= nDegreeCount ) pShadeBob->nAngleY -= nDegreeCount;
-
- pShadeBob->nExtentX += ( ( ( RANDOM() % 5 ) - 2 ) / 2.0F ) * nExtentDelta;
- if( pShadeBob->nExtentX > nMaxExtentX ) pShadeBob->nExtentX = nMaxExtentX;
- if( pShadeBob->nExtentX < nMinExtentX ) pShadeBob->nExtentX = nMinExtentX;
- pShadeBob->nExtentY += ( ( ( RANDOM() % 5 ) - 2 ) / 2.0F ) * nExtentDelta;
- if( pShadeBob->nExtentY > nMaxExtentY ) pShadeBob->nExtentY = nMaxExtentY;
- if( pShadeBob->nExtentY < nMinExtentY ) pShadeBob->nExtentY = nMinExtentY;
-
- /* Trig is your friend :) */
- nXPos = (unsigned int)(( anSinTable[ (int)pShadeBob->nAngleX ] * pShadeBob->nExtentX )
- + nHalfWidth);
- nYPos = (unsigned int)(( anSinTable[ (int)pShadeBob->nAngleY ] * pShadeBob->nExtentY )
- + nHalfHeight);
-
- for( iHeight=0; iHeight<nBobDiameter; iHeight++ )
- {
- for( iWidth=0; iWidth<nBobDiameter; iWidth++ )
- {
- nColor = XGetPixel( pXImage, nXPos + iWidth, nYPos + iHeight );
-
- /* FIXME: Here is a loop I'd love to take out. */
- for( nIndex=0; nIndex < ncolors; nIndex++ )
- if( aXColors[ nIndex ].pixel == nColor )
- break;
-
- nIndex += pShadeBob->anDeltaMap[ iWidth * nBobDiameter + iHeight ];
- if( nIndex >= ncolors ) nIndex = ncolors-1;
- if( nIndex < 0 ) nIndex = 0;
+ pShadeBob->nAngle += pShadeBob->nAngleInc;
+ pShadeBob->nAngleDelta -= pShadeBob->nAngleInc;
+
+ if( pShadeBob->nAngle >= st->iDegreeCount ) pShadeBob->nAngle -= st->iDegreeCount;
+ else if( pShadeBob->nAngle < 0 ) pShadeBob->nAngle += st->iDegreeCount;
+
+ if( ( pShadeBob->nAngleInc>0.0F && pShadeBob->nAngleDelta<pShadeBob->nAngleInc ) ||
+ ( pShadeBob->nAngleInc<=0.0F && pShadeBob->nAngleDelta>pShadeBob->nAngleInc ) )
+ {
+ pShadeBob->nAngleDelta = ( RANDOM() % st->iDegreeCount ) - ( st->iDegreeCount / 2.0F );
+ pShadeBob->nAngleInc = pShadeBob->nAngleDelta / 50.0F;
+ if( pShadeBob->nAngleInc == 0.0F )
+ pShadeBob->nAngleInc = ( pShadeBob->nAngleDelta > 0.0F ) ? 0.0001F : -0.0001F;
+ }
+
+ pShadeBob->nPosX = ( st->anSinTable[ (int)pShadeBob->nAngle ] * st->iVelocity ) + pShadeBob->nPosX;
+ pShadeBob->nPosY = ( st->anCosTable[ (int)pShadeBob->nAngle ] * st->iVelocity ) + pShadeBob->nPosY;
+
+ /* This wraps it around the screen. */
+ if( pShadeBob->nPosX >= st->iWinWidth ) pShadeBob->nPosX -= st->iWinWidth;
+ else if( pShadeBob->nPosX < 0 ) pShadeBob->nPosX += st->iWinWidth;
+
+ if( pShadeBob->nPosY >= st->iWinHeight ) pShadeBob->nPosY -= st->iWinHeight;
+ else if( pShadeBob->nPosY < 0 ) pShadeBob->nPosY += st->iWinHeight;
+}