-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMOVINGBA.C
More file actions
62 lines (50 loc) · 811 Bytes
/
MOVINGBA.C
File metadata and controls
62 lines (50 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// A program in C to print a ball and move it according to instructions given by arrow keys.
#include<graphics.h>
#include<process.h>
#include<dos.h>
#include<stdio.h>
#include<conio.h>
main()
{
int gd=DETECT,gm,i=250,j=250,ch,x=0,y=-1;
initgraph(&gd,&gm,"c:\\tc\\bgi");
while(1)
{
circle(i,j,10);
setcolor(RED);
if(kbhit())
{
ch=getch();
if(ch==72) // Move up
{
x=0;
y=-1;
}
if(ch==75) // Move left
{
x=-1;
y=0;
}
if(ch==77) // Move Right
{
x=1;
y=0;
}
if(ch==80) // Move down
{
x=0;
y=1;
}
if(ch==27) // Esc, Exit from the screen
{
exit(0);
}
i=i+x;
j=j+y;
// printf("%d,%d",i,j);
delay(5);
cleardevice();
} }
getch();
closegraph();
}