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/2
- #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);
- }
- /* clear screen */
- /*
- filledRect(0, 0, screenWidth() - 1, screenHeight() - 1, BLACK);
- filledCircle(screenWidth() / 2, screenHeight() / 2, 100, YELLOW);
- updateScreen();
- getkey();*/
- // filledRect(0, 0, screenWidth() - 1, screenHeight() - 1, BLACK);
- //filledCircle(screenWidth() / 2, screenHeight() / 2, 100, YELLOW);
- //updateScreen();
- //getkey();
- /*for ( i = 100; i < 500; i = i + 10)
- {
- filledCircle(screenWidth() / 2, screenHeight() / 2, i, YELLOW);
- updateScreen();
- SDL_Delay(10);
- if (isKeyDown(SDLK_ESCAPE) == 1)
- {
- break;
- }*/
- int radious = 10;
- int 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)
- {
- //----------------------creating frame----------
- //clear screen
- filledRect(0, 0, screenWidth() - 1, screenHeight() - 1, BLACK);
- radious = (radious + 1) % (int)(min(screenWidth(), screenHeight())/2);
- rotation = (rotation + (int)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(40);
- if (isKeyDown(SDLK_ESCAPE) == 1)
- {
- break;
- }
- // if(pollkey() != -1)
- // break;
- }
- updateScreen();
- //SDL_Delay(40);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement