Advertisement
Guest User

QTS no. 6 - Primitive shape drawing function

a guest
Jul 9th, 2010
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. /*
  2. -----------------------------------------
  3. * Game hacking QTS ( Quickie Tip Series )
  4. * no. 6 - Primitive shape drawing function
  5. -----------------------------------------
  6. * Author: SEGnosis  - GHAnon.net
  7. * Thanks to:
  8. * bitterbanana      - No known site
  9. * Drunken Cheetah   - No known site
  10. * fatboy88      - No known site
  11. * Geek4Ever         - No known site
  12. * learn_more        - www.uc-forum.com
  13. * Novocaine         - http://ilsken.net/blog/?page_id=64
  14. * Philly0494        - No known site
  15. * Roverturbo        - www.uc-forum.com
  16. * SilentKarma       - www.halocoders.com - offline
  17. * Strife        - www.uc-forum.com
  18. * Wieter20      - No known site
  19. */
  20.  
  21. #define PI 3.14159265
  22.  
  23. enum ShapeSides
  24. {
  25.     LINE        = 2,
  26.     TRIANGLE    = 3,
  27.     SQUARE      = 4,
  28.     PENTAGON    = 5,
  29.     HEXAGON     = 6,
  30.     HEPTAGON    = 7,
  31.     OCTAGON     = 8,
  32.     NONAGON     = 9,
  33.     DECAGON     = 11
  34. };
  35.  
  36. //----------------------------------//
  37. void DrawShape( long x, long y, float fDegrees, DWORD dwSides, DWORD dwSize, DWORD dwLineWidth, D3DCOLOR Color )
  38. {
  39.     POINT* pt = new POINT[ dwSides + 1 ]; // allocate points
  40.    
  41.     fDegrees = ( fDegrees * PI ) / 180.0f; // Convert degrees to radians
  42.    
  43.     float k = 0.000000f;
  44.    
  45.     for( int i = 0; i < dwSides; i++, k += ( TWO_PI/dwSides ) )
  46.     {
  47.         float fDeg = k + fDegrees; // add degrees
  48.        
  49.         while( fDeg > TWO_PI )
  50.             fDeg -= TWO_PI; // limit
  51.            
  52.         pt[ i ].x = ( cos( fDeg ) * dwSize ) + x; // set points
  53.         pt[ i ].y = ( sin( fDeg ) * dwSize ) + y;
  54.     }
  55.    
  56.     pt[ dwSides ].x = pt[ 0 ].x; // set last point to first
  57.     pt[ dwSides ].y = pt[ 0 ].y;
  58.    
  59.     for( int i = 0; i < dwSides; i++ )
  60.         CDraw.Line( pt[ i ].x, pt[ i ].y, pt[ i + 1 ].x, pt[ i + 1 ].y, dwLineWidth, Color ); // draw through all points
  61.    
  62.     delete[] pt; // release points allocated
  63. }
  64. //----------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement