Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "primlib.h"
- #include <stdlib.h>
- #define PI 3.141592653589
- #define angle_of_rotation M_PI/80
- #define verticles 5
- int min (int a, int b)
- {
- if(a < b)
- return a;
- return b;
- }
- int main(int argc, char* argv[])
- {
- int i ;
- if(initGraph())
- {
- exit(3);
- }
- int radious = 10;
- int temp = 20;
- double rotation = 0 ;
- double polygonAngle = (2*M_PI)/ verticles;
- double origin_x = screenWidth() / 2;
- double origin_y = screenHeight() / 2;
- double start_x;
- double start_y;
- double stop_x;
- double stop_y;
- while(1)
- {
- filledRect(0, 0, screenWidth() - 1, screenHeight() - 1, BLACK);
- int maxRadious = (int)(min(screenWidth(), screenHeight())/2);
- temp = (temp + 1) % (2 * maxRadious);
- if (temp < maxRadious)
- {
- radious = temp;
- }
- else
- {
- radious = maxRadious - temp % maxRadious;
- }
- if (rotation + angle_of_rotation >= 2* PI)
- {
- rotation = 0;
- }
- rotation = (rotation + angle_of_rotation) ;
- for (i = 0; i < verticles; i++)
- {
- start_x = origin_x + radious * cos(polygonAngle* i + rotation);
- start_y = origin_y + radious * sin(polygonAngle* i + rotation);
- stop_x = origin_x + radious * cos(polygonAngle* (i + 1) + rotation);
- stop_y = origin_y + radious * sin(polygonAngle* (i + 1) + rotation);
- line(start_x, start_y, stop_x , stop_y, BLUE);
- }
- updateScreen();
- SDL_Delay(10);
- if (isKeyDown(SDLK_ESCAPE) == 1)
- {
- break;
- }
- }
- updateScreen();
- SDL_Delay(40);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement