资源描述:
《C程序敲键盘射气球.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include"graphics.h"#include"stdlib.h"#defineESC0x11bstructball{intcolor;intxx;intyy;}balls[5];/*¶¨ÒåÆøÇò*/structgun{intflag;intcolor;intxx;intyy;intff;}guns[5];/*¶¨Òå×Óµ¯*/chardes[10]={104,0,101,0,108,0,108,0,111,0};/*³õʼÆøÇòÉϵÄ×Öĸ*/intflag[5]={1,1,1,1,1};longgun_a=0,gun_b=0;/*ͳ¼Æ×Óµ¯ÊýÄ¿
2、*/intdepth[5]={5,5,5,5,5};/*±ê¼Ç*/void*buffer_ball[5],*buffer_gun[5];/*¶¨ÒåͼÐδ洢ָÕë*/unsignedsize;charc[32]={0x08,0x00,0x0C,0x00,0x1B,0xFE,0x10,0x08,0x30,0x08,0x27,0xC8,0x64,0x48,0xA4,0x48,/*ºÎ__×ÖÄ£*/0x24,0x48,0x27,0xC8,0x24,0x48,0x20,0x08,0x20,0x08,0x20,0x28,0x20,0x10,0x00,0x00};chary[32
3、]={0x00,0x00,0x7C,0x3C,0x45,0xE0,0x44,0x20,0x44,0x20,0x7C,0x20,0x13,0xFE,0x10,0x20,/*Ô¾__×ÖÄ£*/0x5C,0x50,0x50,0x50,0x50,0x88,0x50,0x88,0x5D,0x04,0xE1,0x06,0x02,0x04,0x04,0x00};voidInit()/*³õʼº¯Êý*/{intgdriver=DETECT,gmode,ii;registerbgidriver(EGAVGA_driver);initgraph(&gdriver,&gmode,"");rando
4、mize();for(ii=0;ii<5;ii++){balls[ii].color=random(6)+1;balls[ii].xx=84+90*ii;balls[ii].yy=48;guns[ii].ff=0;}}voidDraw_name(char*c,intx,inty)/*ºº×ÖÊä³ö*/{charmask[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};inti,j,k;for(k=0;k<16;k++){for(i=0;i<2;i++)for(j=0;j<8;j++){if((c[k*2+i]&mask[j])!=0)pu
5、tpixel(x,y,YELLOW);x++;}y++;x=590;}}voidDraw_m()/*»½çÃæ*/{intii,jj;setfillstyle(SOLID_FILL,11);for(ii=0;ii<32;ii++){bar(25+15*ii,396,38+15*ii,409);bar(25+15*ii,20,38+15*ii,33);}for(ii=0;ii<24;ii++){bar(25,35+15*ii,38,48+15*ii);bar(490,35+15*ii,503,48+15*ii);}for(jj=0;jj<5;jj++){setfillstyle(SO
6、LID_FILL,jj+5);for(ii=0;ii<15;ii++)bar(40+30*ii,320+15*jj,68+30*ii,333+15*jj);}settextstyle(0,0,1);Draw_name(c,590,300);Draw_name(y,590,330);setcolor(RED);outtextxy(530,400,"2005_12_15");setcolor(14);outtextxy(20,440,"Press'ENTER'tostartthegame,thenyoucanpress'ESC'toquitit");settextstyle(0,0,4
7、);setcolor(12);outtextxy(530,50,"K");outtextxy(530,90,"E");outtextxy(530,130,"Y");setcolor(GREEN);outtextxy(540,170,"B");outtextxy(540,210,"O");outtextxy(540,250,"A");outtextxy(540,290,"R");outtextxy(540,330,"D");}Draw_ball()/*»ÆøÇò*/{i