Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. void render(SDL_Renderer *r)
  2. {
  3.     if(!r)
  4.         return;
  5.     // static int step = 1, A = 50, sign = 1;
  6.     int A = 50, B = 35;
  7.     static int sign = 1;
  8.     // int step = 1;
  9.     static int cx = SCREEN_W / 2 - 50,
  10.                cy = SCREEN_H / 2;
  11.  
  12.     static double phi = 0.0f;
  13.     // static double offset = M_PI/2;
  14.    
  15.     static SDL_Rect dot = {
  16.         SCREEN_W/2 - 5, SCREEN_H/2 - 5, 10, 10
  17.     };
  18.     dot.x = cx + sign*A*cos(phi*M_PI/180);
  19.     dot.y = cy - sign*B*sin(phi*M_PI/180);
  20.    
  21.  
  22.     phi += sign*1;
  23.  
  24.     if((int)phi % 360 == 0)
  25.     {
  26.         cx += sign*2*A;
  27.         sign = -sign;
  28.     }
  29.     SDL_SetRenderDrawColor(r,0,0,0,255);
  30.  
  31.     SDL_RenderFillRect(r, &dot);
  32.     SDL_RenderPresent(r);
  33.    
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement