Advertisement
Guest User

PT spiral drawing

a guest
Nov 27th, 2010
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. //paste that in main.c
  2.  
  3. int spiralx, spiraly;
  4. float spiralv;
  5.  
  6. double degtorad(double angle)
  7. {
  8.     return angle * 3.14 / 180;
  9. }
  10.  
  11. void drawspiral(maxspiral,spart)
  12. {
  13.     int i = 0;
  14.     for(i = 0; i < maxspiral; i++)
  15.     {
  16.     if(spiralv!=360)
  17.     {
  18.         spiralv+=0.1;
  19.     }
  20.     else if(spiralv==360)
  21.     {
  22.         spiralv = 1;
  23.     }
  24.  
  25.     spiralx = mousex+spiralv*cos(degtorad(spiralv));
  26.     spiraly = mousey+spiralv*sin(degtorad(spiralv));
  27.     create_part(-1,spiralx,spiraly,spart);
  28.     }
  29. }
  30.  
  31.  
  32. // that too in main.c, but next to sdl_key checkings
  33.  
  34.  
  35.         if(sdl_key=='e')
  36.         {
  37.             drawspiral(360,sl);
  38.         }
  39.         if(sdl_key=='r')
  40.         {
  41.             spiralv = 0;
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement