/*
* THIS IS A PROGRAM THAT DRAWS A FLYING AEROPLANE. THE KEYS CONTROL THE MOTION OF THE PLANE.
*/
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
void main(){
int gd=DETECT,gm,x,maxx,y,maxy,key,h_dir,v_dir;
char *aeroplane;
printf("Use arrow keys to move the aeroplane.\n\n");
printf("\n1.Press \"any key\" to continue.");
printf("\n2.Press \"Esc\" at the end to exit.");
getch();
clrscr();
initgraph(&gd,&gm,"C:\\tc\\BGI");
maxx=getmaxx();
maxy=getmaxy();
// ============ draw the aeroplane ==================
moveto(56,165);
lineto(57,163);
lineto(58,161);
lineto(59,160);
lineto(60,159);
lineto(61,159);
lineto(62,158);
lineto(63,158);
lineto(64,157);
lineto(65,157);
lineto(66,156);
lineto(67,156);
lineto(68,155);
lineto(69,155);
lineto(70,154);
lineto(71,154);
lineto(72,154);
lineto(73,154);
lineto(74,153);
lineto(75,153);
lineto(76,153);
lineto(77,152);
lineto(78,152);
lineto(79,152);
lineto(80,151);
lineto(80,151);
lineto(81,150);
lineto(82,149);
lineto(83,148);
lineto(84,147);
lineto(85,146);
lineto(86,145);
lineto(87,144);
lineto(88,143);
lineto(91,142);
lineto(93,141);
lineto(98,139);
lineto(103,137);
lineto(110,135);
lineto(114,134);
lineto(120,133);
lineto(125,132);
lineto(130,131);
lineto(151,130);
lineto(264,130);
lineto(264,130);
lineto(351,132);
lineto(415,132);
lineto(426,132);
lineto(429,131);
lineto(431,130);
lineto(434,129);
lineto(437,128);
lineto(440,127);
lineto(443,126);
lineto(445,125);
lineto(448,124);
lineto(451,123);
lineto(453,122);
lineto(458,119);
lineto(507,54);
lineto(520,53);
lineto(522,54);
lineto(507,137);
lineto(516,136);
lineto(566,129);
lineto(575,129);
lineto(515,142);
lineto(515,149);
lineto(512,152);
lineto(507,154);
lineto(458,170);
lineto(413,182);
lineto(401,183);
lineto(371,184);
lineto(331,184);
lineto(321,190);
lineto(319,193);
lineto(316,194);
lineto(310,193);
lineto(302,196);
lineto(295,197);
lineto(287,198);
lineto(270,198);
lineto(267,197);
lineto(266,195);
lineto(264,193);
lineto(263,190);
lineto(263,187);
lineto(259,187);
lineto(256,191);
lineto(251,192);
lineto(244,193);
lineto(234,194);
lineto(229,195);
lineto(212,195);
lineto(206,194);
lineto(206,191);
lineto(204,186);
lineto(121,185);
lineto(111,184);
lineto(103,183);
lineto(96,182);
lineto(89,181);
lineto(84,180);
lineto(80,179);
lineto(77,178);
lineto(73,177);
lineto(70,176);
lineto(68,175);
lineto(66,174);
lineto(63,172);
lineto(61,171);
lineto(60,170);
lineto(59,169);
lineto(58,167);
lineto(56,165);
//nozzle
moveto(64,157);
lineto(64,173);
floodfill(60,165,WHITE);
//windscreen
moveto(91,142);
lineto(99,145);
lineto(99,149);
lineto(96,151);
lineto(81,150);
floodfill(89,147,BLACK);
//lower body
moveto(121,185);
lineto(204,185);
lineto(262,184);
//wing
moveto(319,179);
lineto(471,149);
lineto(291,171);
lineto(319,179);
floodfill(319,175,WHITE);
//window border upper
moveto(99,145);
lineto(120,145);
lineto(120,142);
lineto(132,142);
lineto(132,145);
lineto(454,147);
lineto(454,144);
lineto(462,144);
lineto(462,148);
lineto(515,148);
//window border lower
moveto(64,173);
lineto(120,159);
lineto(120,168);
lineto(132,168);
lineto(132,159);
lineto(285,159);
lineto(285,163);
lineto(305,163);
lineto(305,159);
lineto(488,159);
//propeller
moveto(262,184);
lineto(263,179);
lineto(264,177);
lineto(265,174);
lineto(267,173);
lineto(270,171);
lineto(274,170);
lineto(283,170);
lineto(291,171);
lineto(295,172);
lineto(299,173);
lineto(307,175);
lineto(315,177);
lineto(319,179);
lineto(321,182);
lineto(331,184);
int i;
for(i=127 ; i<475; i+=10)
fillellipse(i,152,2,2);
floodfill(250,140,WHITE);
// ======================================================
aeroplane=malloc(imagesize(10,10,200,200));
getimage(10,10,200,200,aeroplane);
cleardevice();
y=15;
x=40;
while(1)
{
putimage(x,y,aeroplane,COPY_PUT);
h_dir=0;
v_dir=0;
key=getkey();
if(key==1)
exit(0);
if(key==72)
v_dir=-1;
else if(key==80)
v_dir=1;
else if(key==75)
h_dir=-1;
else if(key==77)
h_dir=1;
x=x+h_dir*10;
y=y+v_dir*10;
delay(10);
cleardevice();
if(x>=maxx)
x=0;
else if(x<=0)
x=maxx;
if(y>=maxy)
y=0;
else if(y<=0)
y=maxy;
}
}
getkey(){
union REGS i,o;
while(!kbhit())
i.h.ah=0;
int86(22,&i,&o);
//printf("%d",o.h.ah);
return(o.h.ah);
}
No comments:
Post a Comment
Do you think this information useful or was not up to the mark? Comment if you have any advices or suggestions about the post.