Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <graphics.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- void kolo(int x, int y, int r,unsigned char color)
- {
- int x1,y1,yk = 0;
- int sigma,delta,f;
- x1 = 0;
- y1 = r;
- delta = 2*(1-r);
- do
- {
- putpixel(x+x1,y+y1,color);
- putpixel(x-x1,y+y1,color);
- putpixel(x+x1,y-y1,color);
- putpixel(x-x1,y-y1,color);
- f = 0;
- if (y1 < yk)
- break;
- if (delta < 0)
- {
- sigma = 2*(delta+y1)-1;
- if (sigma <= 0)
- {
- x1++;
- delta += 2*x1+1;
- f = 1;
- }
- }
- else
- if (delta > 0)
- {
- sigma = 2*(delta-x1)-1;
- if (sigma > 0)
- {
- y1--;
- delta += 1-2*y1;
- f = 1;
- }
- }
- if (!f)
- {
- x1++;
- y1--;
- delta += 2*(x1-y1-1);
- }
- }
- while(1);
- }
- int main()
- {
- int r=50;
- int x=r+1;
- int y=r+1;
- initwindow(480,480);
- while(1)
- {
- if(kbhit())
- switch(getch())
- {
- case 75://Left
- if((x-r-1)>0){
- cleardevice();
- kolo(--x, --y, r,2);
- };
- break;
- case 77://Right
- if((x+r+1)<480){
- cleardevice();
- kolo(++x, ++y, r,2);
- };
- break;
- case 72://Up
- if((r+1)<50){
- cleardevice();
- kolo(x, y, ++r,2);
- };
- break;
- case 80://Down
- if((r-1)>5){
- cleardevice();
- kolo(x, y, --r,2);
- };
- break;
- case 27://ESC
- closegraph();
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement