#include #include #include #include class Air{ public: int size; void planeshow(int i,int k); void ereasep(int i, int k); void shoot(int i, int k); /*i decides the herizontal position */ /* k decides the vertical position */ }; void Air::planeshow(int i,int k) { int j; circle(i+5, 200+size+k, size); circle(i+3, 200+2*size+k, size); for (j=0; j<=4+3*size; j=j+size) circle(i+j, 200+k, size); circle(i+5, 200-size+k, size); circle(i+3, 200-2*size+k, size); } void Air::ereasep(int i, int k) { int j; setcolor(BLACK); circle(i+5, 200+size+k, size); circle(i+3, 200+2*size+k, size); for (j=0; j<=4+3*size; j=j+1) circle(i+j, 200+k, size); circle(i+5, 200-size+k, size); circle(i+3, 200-2*size+k, size); } void Air::shoot(int i, int k) {int j; sound(700); for(j=0; j<=10; j++) { setcolor(RED); line(i+j*30, 200+k,i+j*30+18, 200+k ); delay (30); setcolor(BLACK); line(i+j*30, 200+k,i+j*30+18, 200+k); } nosound(); } class Shoot { public: void point(int i, int k); void sh(int i, int k); }; void Shoot::point(int i, int k) { setcolor(YELLOW); circle(400+i, 400+k, 1); } void Shoot::sh(int i, int k) {int j; sound(900); for(j=0; j<=10; j++) { setcolor(RED); line(400-j*30+i, 400+k-30*j,400-j*30+i-10, 400+k-30*j-10); delay (30); setcolor(BLACK); line(400-j*30+i, 400+k-30*j,400-j*30+i-10, 400+k-30*j-10); } nosound(); } char read_key(); void main(void) { int driver = DETECT,mode; int sf=0, i,k,f=0,f3=0, xi=0, yi=0; char x; Air y1, y2, y3; Shoot bullet; initgraph(&driver,&mode,"a:\\bgi"); setcolor(WHITE); line(1,400,400,400); for ( i = 0; i < 80; i++ ) { setcolor(BLUE); y1.size=2; y1.planeshow(5*i, 5); x=read_key(); if (x =='u') f=f-8; if (x =='i') f=f+8; if (x=='o') f3=f3-8; if (x=='p') f3=f3+8; setcolor(YELLOW); y2.size=3; y2.planeshow(5*(i-8), f); setcolor(RED); y3.size=3;y3.planeshow(5*(i-16), f3); if(x=='k'){sf=1; y2.shoot(5*(i-8), f);} bullet.point(xi,yi); if(x=='l') bullet.sh(xi,yi); if (sf==0) delay (300); else sf=0; y1.ereasep(5*i, 5); y2.ereasep(5*(i-8), f); y3.ereasep(5*(i-16), f3); } closegraph(); } char read_key() { int y=1; char x; _AH=0x01; geninterrupt(0x16); y=_FLAGS&0x40; if(y == 0) { _AH=0x00; geninterrupt(0x16); x=_AL; return x; } return '?'; }