F How can we move an arrow vertically upwards in the screen using C ? | CodeTheta

How can we move an arrow vertically upwards in the screen using C ?

May 18, 2013

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#define GPATH "C:\\TC\\BGI"
void linedda(int, int, int, int);
void arrow(int, int, int, int);
void main()
{
int x1, y1, x2, y2, d=10;
int gd=DETECT, gm;
clrscr();
initgraph(&gd, &gm, GPATH);
x1=getmaxx()/2;
y2=getmaxy();
x2=x1;
y1=y2-50;
while(!kbhit())
{
arrow(x1,y1,x2,y2);
y1-=10;
y2-=10;
delay(100);
cleardevice();
}
getch();
}
void arrow(int x1, int y1, int x2, int y2)
{
linedda(x1, y1, x2, y2);
linedda(x1, y1, x1-10, y1+10);
linedda(x1, y1, x1+10, y1+10);
}
void linedda(int x1, int y1, int x2, int y2)
{
int i, x, y, dx, dy, xincr, yincr, steps;
dx=x2-x1;
dy=y2-y1;
if(abs(dx) > abs(dy))
steps=abs(dx);
else
steps=abs(dy);
xincr=dx/steps;
yincr=dy/steps;
x=x1;
y=y1;
putpixel(x, y, WHITE);
for(i=0; i<steps; i++)
{
x=x+xincr;
y=y+yincr;
putpixel(x, y, WHITE);
}
}
 
Don't forget to set the path 

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