Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void render(SDL_Renderer *r)
- {
- if(!r)
- return;
- // static int step = 1, A = 50, sign = 1;
- int A = 50, B = 35;
- static int sign = 1;
- // int step = 1;
- static int cx = SCREEN_W / 2 - 50,
- cy = SCREEN_H / 2;
- static double phi = 0.0f;
- // static double offset = M_PI/2;
- static SDL_Rect dot = {
- SCREEN_W/2 - 5, SCREEN_H/2 - 5, 10, 10
- };
- dot.x = cx + sign*A*cos(phi*M_PI/180);
- dot.y = cy - sign*B*sin(phi*M_PI/180);
- phi += sign*1;
- if((int)phi % 360 == 0)
- {
- cx += sign*2*A;
- sign = -sign;
- }
- SDL_SetRenderDrawColor(r,0,0,0,255);
- SDL_RenderFillRect(r, &dot);
- SDL_RenderPresent(r);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement