F How can we make a Circle move horizontally across the screen? [C graphics program] | CodeTheta

How can we make a Circle move horizontally across the screen? [C graphics program]

May 18, 2013

In this c programming is related to graphics programming when you will run this program in you own mechine do not forget to set the path. of you don't the program will not work.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#define GPATH "C:\\TC\\BGI"
void mp(int, int, int);
void cpp(int, int, int, int);
void main()
{
int x, yc, r;
int gd=DETECT, gm;
x=0;
initgraph(&gd, &gm, GPATH);
printf("\nEnter radius:\n");
scanf("%d", &r);
printf("\nEnter Y center:\n");
scanf("%d", &yc);
while(!kbhit() && x<getmaxx())
{
mp(r, x, yc);
x=x+1;
delay(50);
cleardevice();
}
getch();
}
void mp(int r, int xc, int yc)
{
int x, y, p;
x=0;
y=r;
p=1-r;
cpp(xc, yc, x, y);
while(x<=y)
{
x++;
if(p<0)
p+=2*(x-1);
else
{
p+=2*(x-y)+1;
y--;
}
cpp(xc, yc, x, y);
}
}
void cpp(int xc, int yc, int x, int y)
{
putpixel(xc+x, yc+y, WHITE);
putpixel(xc+y, yc+x, WHITE);
putpixel(xc-x, yc+y, WHITE);
putpixel(xc+y, yc-x, WHITE);
putpixel(xc+x, yc-y, WHITE);
putpixel(xc-y, yc+x, WHITE);
putpixel(xc-x, yc-y, WHITE);
putpixel(xc-y, yc-x, WHITE);
}
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us

Post a Comment

PRODUCTS

LISTS OF PRODUCTS

SERVICES

SKILLS
SOFTWARE DEVELOPMENT
WEBSITE DEVELOPMENT
WEB HOSTING
BULK SMS SERVICE
SEO SERVICE
ANDROID APPS
QR CODE / BARCODE
HARDWARE SERVICE
OUR WORK AREA