Skip to content

Commit 3c0f430

Browse files
Add files via upload
1 parent 9497610 commit 3c0f430

File tree

5 files changed

+402
-0
lines changed

5 files changed

+402
-0
lines changed

Graphics/COUNTD.C

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**********************************************
2+
Statement - Static Countdown
3+
Programmer - Vineet Choudhary
4+
Written For - http://developerinsider.in
5+
**********************************************/
6+
#include <graphics.h>
7+
#include <dos.h>
8+
#include <conio.h>
9+
10+
int main()
11+
{
12+
int gd = DETECT, gm, i;
13+
char a[5];
14+
15+
initgraph( &gd, &gm, "C:\\TURBOC3\\BGI");
16+
17+
settextjustify( CENTER_TEXT, CENTER_TEXT );
18+
settextstyle(DEFAULT_FONT,HORIZ_DIR,50);
19+
setcolor(RED);
20+
for (i = 30; i >=0; i--)
21+
{
22+
sprintf(a,"%d",i);
23+
outtextxy(getmaxx()/2, getmaxy()/2, a);
24+
delay(1000);
25+
26+
if ( i == 0 )
27+
break;
28+
cleardevice();
29+
}
30+
cleardevice();
31+
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
32+
outtextxy(300,300,"Project by http://www.turboc.codeplex.com");
33+
delay(5000);
34+
closegraph();
35+
return 0;
36+
}

Graphics/MCAR.C

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**********************************************
2+
Statement - Move a Car
3+
Programmer - Vineet Choudhary
4+
Written For - http://developerinsider.in
5+
**********************************************/
6+
#include <graphics.h>
7+
#include <dos.h>
8+
#include <conio.h>
9+
10+
main()
11+
{
12+
int i, j = 0, gd = DETECT, gm;
13+
14+
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
15+
16+
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
17+
outtextxy(25,240,"Press any key to view the moving car");
18+
19+
getch();
20+
setviewport(0,0,639,440,1);
21+
22+
for( i = 0 ; i <= 420 ; i = i + 10, j++ )
23+
{
24+
rectangle(50+i,275,150+i,400);
25+
rectangle(150+i,350,200+i,400);
26+
circle(75+i,410,10);
27+
circle(175+i,410,10);
28+
setcolor(j);
29+
delay(100);
30+
31+
if( i == 420 )
32+
break;
33+
34+
clearviewport();
35+
}
36+
getch();
37+
cleardevice();
38+
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
39+
outtextxy(100,200,"Project by http://www.turboc.codeplex.com");
40+
delay(5000);
41+
closegraph();
42+
return 0;
43+
}

Graphics/PMBG.C

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
/**********************************************
2+
Statement - Press Me Button Game
3+
Programmer - Vineet Choudhary
4+
Written For - http://developerinsider.in
5+
**********************************************/
6+
7+
#include <stdio.h>
8+
#include <conio.h>
9+
#include <dos.h>
10+
#include <graphics.h>
11+
#include <stdlib.h>
12+
13+
union REGS i, o;
14+
int left = 265, top = 250;
15+
16+
void initialize_graphics_mode()
17+
{
18+
int gd = DETECT, gm, error;
19+
20+
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
21+
22+
error = graphresult();
23+
24+
if (error != grOk)
25+
{
26+
perror("Error ");
27+
printf("Press any key to exit...\n");
28+
getch();
29+
exit(EXIT_FAILURE);
30+
}
31+
}
32+
33+
void showmouseptr()
34+
{
35+
i.x.ax = 1;
36+
int86(0x33,&i,&o);
37+
}
38+
39+
void hidemouseptr()
40+
{
41+
i.x.ax = 2;
42+
int86(0x33,&i,&o);
43+
}
44+
45+
void getmousepos(int *x,int *y)
46+
{
47+
i.x.ax = 3;
48+
int86(0x33,&i,&o);
49+
50+
*x = o.x.cx;
51+
*y = o.x.dx;
52+
}
53+
54+
void draw_bar()
55+
{
56+
hidemouseptr();
57+
setfillstyle(SOLID_FILL,CYAN);
58+
bar(190,180,450,350);
59+
showmouseptr();
60+
}
61+
62+
void draw_button(int x, int y)
63+
{
64+
hidemouseptr();
65+
setfillstyle(SOLID_FILL,MAGENTA);
66+
bar(x,y,x+100,y+30);
67+
moveto(x+5,y);
68+
setcolor(YELLOW);
69+
outtext("Press me");
70+
showmouseptr();
71+
}
72+
73+
void draw()
74+
{
75+
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
76+
outtextxy(100,451,"Project by http://www.turboc.codeplex.com");
77+
setcolor(BLUE);
78+
rectangle(0,0,639,450);
79+
setcolor(RED);
80+
outtextxy(160,25,"Try to press the \"Press me\" button");
81+
outtextxy(210,50,"Press escape key to exit");
82+
setfillstyle(XHATCH_FILL,GREEN);
83+
setcolor(BLUE);
84+
bar(1,1,75,449);
85+
bar(565,1,638,449);
86+
showmouseptr();
87+
draw_bar();
88+
draw_button(left,top);
89+
}
90+
91+
void initialize()
92+
{
93+
initialize_graphics_mode();
94+
95+
if( !initmouse() )
96+
{
97+
closegraph();
98+
printf("Unable to initialize the mouse");
99+
printf("Press any key to exit...\n");
100+
getch();
101+
exit(EXIT_SUCCESS);
102+
}
103+
104+
draw();
105+
}
106+
107+
int initmouse()
108+
{
109+
i.x.ax = 0;
110+
int86(0x33,&i,&o);
111+
return ( o.x.ax );
112+
}
113+
114+
void get_input()
115+
{
116+
int x, y;
117+
118+
while(1)
119+
{
120+
getmousepos(&x,&y);
121+
122+
/* mouse pointer in left of button */
123+
124+
if( x >= (left-3) && y >= (top-3) && y <= (top+30+3) && x < left )
125+
{
126+
draw_bar();
127+
left = left + 4;
128+
129+
if (left > 350)
130+
left = 190;
131+
132+
draw_button(left,top);
133+
}
134+
135+
/* mouse pointer in right of button */
136+
137+
else if (x<=(left+100+3)&&y>=(top-3)&&y<=(top+30+3)&&x>(left+100))
138+
{
139+
draw_bar();
140+
left = left - 4;
141+
142+
if (left < 190)
143+
left = 350;
144+
145+
draw_button(left,top);
146+
}
147+
148+
/* mouse pointer above button */
149+
150+
else if(x>(left-3) && y>=(top-3) && y<(top) && x<= (left+100+3))
151+
{
152+
draw_bar();
153+
top = top + 4;
154+
155+
if (top > 320)
156+
top = 180;
157+
158+
draw_button(left,top);
159+
}
160+
161+
/* mouse pointer below button */
162+
163+
else if (x>(left-3)&&y>(top+30)&&y<=(top+30+3)&&x<=(left+100+3))
164+
{
165+
draw_bar();
166+
top = top - 4;
167+
168+
if (top < 180)
169+
top = 320;
170+
171+
draw_button(left,top);
172+
}
173+
174+
if (kbhit())
175+
{
176+
if (getkey() == 1)
177+
exit(EXIT_SUCCESS);
178+
}
179+
}
180+
}
181+
182+
int getkey()
183+
{
184+
i.h.ah = 0;
185+
int86(22,&i,&o);
186+
187+
return( o.h.ah );
188+
}
189+
190+
main()
191+
{
192+
initialize();
193+
194+
get_input();
195+
return 0;
196+
}

Graphics/SFA.C

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**********************************************
2+
Statement - Smiling Face Animation
3+
Programmer - Vineet Choudhary
4+
Written For - http://developerinsider.in
5+
**********************************************/
6+
7+
#include<graphics.h>
8+
#include<conio.h>
9+
#include<stdlib.h>
10+
11+
main()
12+
{
13+
int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75;
14+
void *p;
15+
16+
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
17+
18+
setcolor(YELLOW);
19+
circle(50,100,25);
20+
setfillstyle(SOLID_FILL,YELLOW);
21+
floodfill(50,100,YELLOW);
22+
23+
setcolor(BLACK);
24+
setfillstyle(SOLID_FILL,BLACK);
25+
fillellipse(44,85,2,6);
26+
fillellipse(56,85,2,6);
27+
28+
ellipse(50,100,205,335,20,9);
29+
ellipse(50,100,205,335,20,10);
30+
ellipse(50,100,205,335,20,11);
31+
32+
area = imagesize(left, top, left + 50, top + 50);
33+
p = malloc(area);
34+
35+
setcolor(WHITE);
36+
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
37+
outtextxy(20,451,"Smiling Face Project by http://www.turboc.codeplex.com");
38+
39+
setcolor(BLUE);
40+
rectangle(0,0,639,449);
41+
42+
while(!kbhit())
43+
{
44+
temp1 = 1 + random ( 588 );
45+
temp2 = 1 + random ( 380 );
46+
47+
getimage(left, top, left + 50, top + 50, p);
48+
putimage(left, top, p, XOR_PUT);
49+
putimage(temp1 , temp2, p, XOR_PUT);
50+
delay(500);
51+
left = temp1;
52+
top = temp2;
53+
}
54+
55+
getch();
56+
closegraph();
57+
return 0;
58+
}

0 commit comments

Comments
 (0)