level 1
长空孤鹰se
楼主
主文件 game.cpp#include
// main fuction.void main(){me *myself;int gdriver=DETECT,gmode,d,i,size,x,y,number,next,kill=0,jkl=0,asd=0,nandu=0;object **ob;ob =new object*[100];printf("please tell me your level:");scanf("%d",&nandu);int baop = nandu*5;for(int g=0;g<=99;++g)ob[g]=NULL;next = 0;double j;void **baoimage,*azabao,*alifebao,*baoblack;baoimage = new void*[2];long int key;initgraph(&gdriver,&gmode,"d:\\tc30\\bgi");int baosize = imagesize(10,10,35,35);azabao = malloc(baosize);alifebao = malloc(baosize);baoblack = malloc(baosize);getimage(10,10,35,35,baoblack);setcolor(5);rectangle(10,10,35,35);setcolor(10);settextstyle(1,0,4);outtextxy(10,0,"B");getimage(10,10,35,35,azabao);setcolor(0);outtextxy(10,0,"B");setcolor(4);outtextxy(10,0,"L");getimage(10,10,35,35,alifebao);baoimage[0] = azabao;baoimage[1] = alifebao;cleardevice();setcolor(4);void *buff,*buffe,*black,*temp;black = malloc(imagesize(100,400,120,430));getimage(300,600,320,630,black);bar(20,20,40,40);setlinestyle(0,0,3);line(30,20,30,10);size=imagesize(20,10,40,40);buff = malloc(size);buffe = malloc(size);getimage(20,10,40,40,buff);myself = new me(buff,black,3,3,ob);cleardevice();bar(25,20,35,40);line(30,40,30,50);line(20,20,40,20);getimage(20,20,40,50,buffe);cleardevice();settextstyle(3,0,8);setcolor(10);cleardevice();outtextxy(100,100,"STAR WAR");setcolor(4);settextstyle(0,0,2);outtextxy(100,200,"press any key");getch();cleardevice();putimage(myself->x,myself->y,buff,XOR_PUT);ob[0]=myself;clock_t st,fir,dead;fir = clock();ob[2]=new enemy(buffe,100,0,kill/2+random(20),30,20,13,kill/20+random(4),black);int numb=0,lifeb = 3,zab;char *num;while(1){settextstyle(0,0,1);setcolor(0);sprintf(num,"you killed %5d enemy",numb);outtextxy(10,10,num);sprintf(num,"life:%3d,bomb:%3d",lifeb,zab);outtextxy(10,20,num);setcolor(13);sprintf(num,"you killed %5d enemy",kill);outtextxy(10,10,num);sprintf(num,"life:%3d,bomb:%3d",myself->life,myself->zanum);outtextxy(10,20,num);numb = kill;zab = myself->zanum;lifeb = myself->life;st = clock();key = 0;if(bioskey(1)!=0)key=bioskey(0);if(myself->isdestroyed!=1){switch(key){case 4471:myself->mup();break;case 8051:myself->mdown();break;case 7777:myself->mleft();break;case 8292:myself->mright();break;case 8807://fireif((clock()-fir)<4)break;myself->fire();fir = clock();break;case 9064:myself->diuza();break;case 4209:cleardevice();settextstyle(1,0,4);setcolor(15);outtextxy(200,300,"really exit?(y/n)");if(getch()=='y')goto end;cleardevice();}}for(i = 0;i<=99;++i){if(ob[i]!=NULL){ob[i]->move(ob,&kill);if(ob[i]->isdestroyed == 1){ // if(ob[i]->hight==30&&random(baop)==0){ // for(jkl = 1;jkl<=99&&ob[jkl]!=NULL;++jkl); // bao asd = 1+random(2); // ob[jkl]= new bao(random(640),0,25,25,3,(bproperty)asd,baoblack,baoimage[asd-1],myself,ob); // }object *k=ob[i]; //ob[i]->destroy(&ob[i]);if(i!=0)delete k;if(i==0&&ob[i]->hight>0&&ob[i]->isdestroyed==1){myself->buffer=black;};};};};if(myself->isdestroyed!=1)myself->redraw();if(ob[0]==NULL)break;if(random(130)<=kill*nandu/20){for(i=1;ob[i]!=NULL;++i);ob[i]=new enemy(buffe,random(640),0,kill*nandu/40+random(10),30,20,1+random(14),kill/50+random(4),black);}while((clock()-st)<1);}settextstyle(4,0,7);setcolor(15);outtextxy(140,100,"GAME OVER");getch();end: cleardevice();char *end;int r = int(kill/50);switch(r){case 0:end = "more carefully next time!";break;case 1:end = "good!";break;case 2:end = "very good!";break;default:end = "perfect!!";}settextstyle(1,0,5);sprintf(num,"you killed %d enemy",kill);outtextxy(10,100,num);setcolor(15);settextstyle(0,0,1);outtextxy(10,300,end);outtext("press 'q' to exit.");while(getch()!='q');}
2005年10月20日 10点10分
1
// main fuction.void main(){me *myself;int gdriver=DETECT,gmode,d,i,size,x,y,number,next,kill=0,jkl=0,asd=0,nandu=0;object **ob;ob =new object*[100];printf("please tell me your level:");scanf("%d",&nandu);int baop = nandu*5;for(int g=0;g<=99;++g)ob[g]=NULL;next = 0;double j;void **baoimage,*azabao,*alifebao,*baoblack;baoimage = new void*[2];long int key;initgraph(&gdriver,&gmode,"d:\\tc30\\bgi");int baosize = imagesize(10,10,35,35);azabao = malloc(baosize);alifebao = malloc(baosize);baoblack = malloc(baosize);getimage(10,10,35,35,baoblack);setcolor(5);rectangle(10,10,35,35);setcolor(10);settextstyle(1,0,4);outtextxy(10,0,"B");getimage(10,10,35,35,azabao);setcolor(0);outtextxy(10,0,"B");setcolor(4);outtextxy(10,0,"L");getimage(10,10,35,35,alifebao);baoimage[0] = azabao;baoimage[1] = alifebao;cleardevice();setcolor(4);void *buff,*buffe,*black,*temp;black = malloc(imagesize(100,400,120,430));getimage(300,600,320,630,black);bar(20,20,40,40);setlinestyle(0,0,3);line(30,20,30,10);size=imagesize(20,10,40,40);buff = malloc(size);buffe = malloc(size);getimage(20,10,40,40,buff);myself = new me(buff,black,3,3,ob);cleardevice();bar(25,20,35,40);line(30,40,30,50);line(20,20,40,20);getimage(20,20,40,50,buffe);cleardevice();settextstyle(3,0,8);setcolor(10);cleardevice();outtextxy(100,100,"STAR WAR");setcolor(4);settextstyle(0,0,2);outtextxy(100,200,"press any key");getch();cleardevice();putimage(myself->x,myself->y,buff,XOR_PUT);ob[0]=myself;clock_t st,fir,dead;fir = clock();ob[2]=new enemy(buffe,100,0,kill/2+random(20),30,20,13,kill/20+random(4),black);int numb=0,lifeb = 3,zab;char *num;while(1){settextstyle(0,0,1);setcolor(0);sprintf(num,"you killed %5d enemy",numb);outtextxy(10,10,num);sprintf(num,"life:%3d,bomb:%3d",lifeb,zab);outtextxy(10,20,num);setcolor(13);sprintf(num,"you killed %5d enemy",kill);outtextxy(10,10,num);sprintf(num,"life:%3d,bomb:%3d",myself->life,myself->zanum);outtextxy(10,20,num);numb = kill;zab = myself->zanum;lifeb = myself->life;st = clock();key = 0;if(bioskey(1)!=0)key=bioskey(0);if(myself->isdestroyed!=1){switch(key){case 4471:myself->mup();break;case 8051:myself->mdown();break;case 7777:myself->mleft();break;case 8292:myself->mright();break;case 8807://fireif((clock()-fir)<4)break;myself->fire();fir = clock();break;case 9064:myself->diuza();break;case 4209:cleardevice();settextstyle(1,0,4);setcolor(15);outtextxy(200,300,"really exit?(y/n)");if(getch()=='y')goto end;cleardevice();}}for(i = 0;i<=99;++i){if(ob[i]!=NULL){ob[i]->move(ob,&kill);if(ob[i]->isdestroyed == 1){ // if(ob[i]->hight==30&&random(baop)==0){ // for(jkl = 1;jkl<=99&&ob[jkl]!=NULL;++jkl); // bao asd = 1+random(2); // ob[jkl]= new bao(random(640),0,25,25,3,(bproperty)asd,baoblack,baoimage[asd-1],myself,ob); // }object *k=ob[i]; //ob[i]->destroy(&ob[i]);if(i!=0)delete k;if(i==0&&ob[i]->hight>0&&ob[i]->isdestroyed==1){myself->buffer=black;};};};};if(myself->isdestroyed!=1)myself->redraw();if(ob[0]==NULL)break;if(random(130)<=kill*nandu/20){for(i=1;ob[i]!=NULL;++i);ob[i]=new enemy(buffe,random(640),0,kill*nandu/40+random(10),30,20,1+random(14),kill/50+random(4),black);}while((clock()-st)<1);}settextstyle(4,0,7);setcolor(15);outtextxy(140,100,"GAME OVER");getch();end: cleardevice();char *end;int r = int(kill/50);switch(r){case 0:end = "more carefully next time!";break;case 1:end = "good!";break;case 2:end = "very good!";break;default:end = "perfect!!";}settextstyle(1,0,5);sprintf(num,"you killed %d enemy",kill);outtextxy(10,100,num);setcolor(15);settextstyle(0,0,1);outtextxy(10,300,end);outtext("press 'q' to exit.");while(getch()!='q');}