- 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;
-
- XPutPixel( pXImage, nXPos + iWidth, nYPos + iHeight,
- aXColors[ nIndex ].pixel );
- }
- }
-
- XPutImage( pDisplay, MainWindow, *pGC, pXImage,
- nXPos, nYPos, nXPos, nYPos, nBobDiameter, nBobDiameter );
- XSync (pDisplay, False);
+ unsigned long iColor;
+ short iColorVal;
+ int iPixelX, iPixelY;
+ unsigned int iWidth, iHeight;
+
+ MoveShadeBob( pShadeBob );
+
+ for( iHeight=0; iHeight<iBobDiameter; iHeight++ )
+ {
+ iPixelY = pShadeBob->nPosY + iHeight;
+ if( iPixelY >= iWinHeight ) iPixelY -= iWinHeight;
+
+ for( iWidth=0; iWidth<iBobDiameter; iWidth++ )
+ {
+ iPixelX = pShadeBob->nPosX + iWidth;
+ if( iPixelX >= iWinWidth ) iPixelX -= iWinWidth;
+
+ iColor = XGetPixel( pImage, iPixelX, iPixelY );
+
+ /* FIXME: Here is a loop I'd love to take out. */
+ for( iColorVal=0; iColorVal<iColorCount; iColorVal++ )
+ if( aiColorVals[ iColorVal ] == iColor )
+ break;
+
+ iColorVal += pShadeBob->anDeltaMap[ iWidth * iBobDiameter + iHeight ];
+ if( iColorVal >= iColorCount ) iColorVal = iColorCount - 1;
+ if( iColorVal < 0 ) iColorVal = 0;
+
+ XPutPixel( pImage, iPixelX, iPixelY, aiColorVals[ iColorVal ] );
+ }
+ }
+
+ /* FIXME: if it's next to the top or left sides of screen this will break. However, it's not noticable. */
+ XPutImage( pDisplay, MainWindow, *pGC, pImage,
+ pShadeBob->nPosX, pShadeBob->nPosY, pShadeBob->nPosX, pShadeBob->nPosY, iBobDiameter, iBobDiameter );
+ XSync( pDisplay, False );