home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / ball.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-19  |  2.0 KB  |  59 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright (c) 1992 - 1996  Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11. //
  12. // CBall
  13. //
  14. // Plots a ball into a supplied image buufer.
  15.  
  16. // The buffer is DIB byte array.
  17.  
  18.  
  19. class CBall {
  20. public:
  21.  
  22.     CBall(int iImageWidth = 320, int iImageHeight = 240, int iBallSize = 10);
  23.  
  24.     // Plots the square ball in the image buffer, at the current location.
  25.     // Use BallPixel[] as pixel value for the ball.
  26.     // Plots zero in all 'background' image locations.
  27.     // iPixelSize - the number of bytes in a pixel (size of BallPixel[])
  28.     void PlotBall(BYTE pFrame[], BYTE BallPixel[], int iPixelSize);
  29.  
  30.     // Moves the ball 1 pixel in each of the x and y directions
  31.     void MoveBall(CRefTime rt);
  32.  
  33. private:
  34.  
  35.     int m_iImageHeight, m_iImageWidth;        // the image dimentions
  36.     int m_iAvailableHeight, m_iAvailableWidth;    // the dimentions we can plot in, allowing for the width of the ball
  37.     int m_iBallSize;                // the diameter of the ball
  38.  
  39.     // For a bit of randomness
  40.     int m_iRandX, m_iRandY;
  41.  
  42.  
  43.     int m_x;    // the x position, in pixels, of the ball in the frame. 0 < x < m_iAvailableWidth
  44.     int m_y;    // the y position, in pixels, of the ball in the frame. 0 < y < m_iAvailableHeight
  45.  
  46.     enum xdir { LEFT = -1, RIGHT = 1 };
  47.     enum ydir { UP = 1, DOWN = -1 };
  48.  
  49.     xdir m_xDir;    // the direction the ball is currently heading in
  50.     ydir m_yDir;    //
  51.  
  52.     // Return the 1-dimensional position of the ball at time t millisecs
  53.     int  BallPosition(int iPixelTime, int iLength, int time, int iOffset);
  54.  
  55.     /// tests a given pixel to see if it should be plotted
  56.     BOOL WithinCircle(int x, int y);
  57.  
  58. };
  59.