(接上)
rectangle(x+1,y+15,x+10,y+22);
rectangle(x+10,y+15,x+20,y+22);
rectangle(x+20,y+15,x+29,y+22);
rectangle(x+1,y+22,x+6,y+29);
rectangle(x+6,y+22,x+15,y+29);
rectangle(x+15,y+22,x+24,y+29);
rectangle(x+24,y+22,x+29,y+29);
}
void stone(int x,int y) /* draw a stone which can't be broken by a bomb blast */
{
setfillstyle(6,YELLOW);
bar(x+1,y+1,x+29,y+29);
}
void character(int x,int y,int i) /* draw the player , i is the player NO. */
{
setcolor(WHITE);
circle(x+15,y+6,5);
if(i==1)
{ setfillstyle(1,YELLOW);}
else if(i==2)
{ setfillstyle(1,GREEN); }
else return;
floodfill(x+15,y+5,WHITE);
putpixel(x+13,y+5,RED);
putpixel(x+17,y+5,RED);
moveto(x+15,y+12);
lineto(x+15,y+19);
moveto(x+15,y+12);
lineto(x+8,y+20);
moveto(x+15,y+12);
lineto(x+22,y+20);
moveto(x+15,y+20);
lineto(x+8,y+30);
moveto(x+15,y+20);
lineto(x+22,y+30);
}
void put_bomb(int x,int y) /* draw a bomb */
{
setfillstyle(1,BLUE);
bar(x,y,x+30,y+30);
setcolor(DARKGRAY);
setfillstyle(1,DARKGRAY);
pieslice(x+15,y+15,0,360,14);
setcolor(RED);
setfillstyle(1,RED);
pieslice(x+15,y+15,0,360,4);
}
void moveplace(int x,int y)
{
setcolor(BLUE);
setfillstyle(1,BLUE);
bar(x,y,x+30,y+30);
}
void blast_p(int x,int y)
{
setcolor(13);
setfillstyle(1,13);
bar(x,y,x+30,y+30);
}
void draw(int i,int j,int n)
{
int x,y;
x=i*30+10;
y=j*30+10;
switch(n){
case 0 : moveplace(x,y);a[j]=0;break;
case 1 : stone(x,y);a[j]=1;break;
case 2 : wall(x,y);a[j]=2;break;
case 3 : sign_addbomb(x,y);a[j]=3;break;
case 4 : sign_addpower(x,y);a[j]=4;break;
case 5 : put_bomb(x,y);a[j]=5;break;
case 6 : character(x,y,1);a[j]=6;Station_x[0]=i;Station_y[0]=j;break;
case 7 : character(x,y,2);a[j]=7;Station_x[1]=i;Station_y[1]=j;break;
case 8 : blast_p(x,y);a[j]=8;break;
default : break;
}
}
void map1(void)
{
int b[13][15]={{6,0,2,2,2,2,2,0,0,2,2,2,2,0,0},{0,2,2,0,2,1,2,1,0,2,2,0,2,1,0},
{2,2,2,2,0,2,2,2,2,2,0,2,2,2,2},{2,1,2,2,2,2,2,1,2,1,2,1,2,1,2},
{2,2,2,2,0,2,2,2,2,2,2,2,2,2,2},{0,0,2,1,2,1,2,1,2,0,2,0,2,0,2},
{0,0,2,2,2,2,1,1,1,1,2,2,2,0,0},{2,2,2,0,2,1,1,1,1,1,2,1,2,2,2},
{2,2,2,2,0,2,2,2,0,2,2,2,0,2,2},{2,0,2,1,2,1,2,1,2,1,2,1,2,0,2},
{2,2,2,2,0,2,2,2,2,2,2,2,2,2,2},{0,2,2,2,2,1,0,0,2,2,2,1,2,0,0},
{0,0,2,2,2,2,0,0,0,2,2,2,2,0,7}};
int i,j;
setcolor(LIGHTBLUE);
setbkcolor(BLUE);
cleardevice();
rectangle(Map_xy);
for(j=0;j<13;j++)
for(i=0;i<15;i++){
a[j]=b[j];
draw(i,j,a[j]);
if(a[j]==6) {Relive1[0]=i;Relive1[1]=j;}
if(a[j]==7) {Relive2[0]=i;Relive2[1]=j;}
}
}
void map2(void)
{
int b[13][15]={{2,2,2,2,0,0,0,2,0,0,0,2,2,2,2},{2,1,2,0,2,2,2,0,2,2,2,0,2,1,2},
{2,2,0,2,0,2,0,2,0,2,0,2,0,2,2},{2,0,2,0,2,2,2,2,2,2,2,0,2,0,2},
{2,0,2,2,2,2,2,2,2,2,2,2,2,0,2},{2,0,2,0,2,2,2,2,2,2,2,0,2,0,2},
{2,0,2,2,2,2,1,1,1,2,2,2,2,0,2},{2,2,0,2,0,2,2,2,2,2,0,2,0,2,2},
{2,2,2,0,2,2,2,2,2,2,2,0,2,2,2},{2,2,2,2,0,2,0,2,0,2,0,2,2,2,2},
{2,2,0,2,2,0,2,2,2,0,2,2,0,2,2},{2,1,0,2,2,2,0,0,0,2,2,2,0,1,2},
{2,0,6,2,2,2,2,2,2,2,2,2,7,0,2}};
int i,j;
setcolor(LIGHTBLUE);
setbkcolor(BLUE);
cleardevice();
rectangle(Map_xy);
for(j=0;j<13;j++)
for(i=0;i<15;i++){
a[j]=b[j];
draw(i,j,a[j]);
if(a[j]==6) {Relive1[0]=i;Relive1[1]=j; }
if(a[j]==7) {Relive2[0]=i;Relive2[1]=j; }
}
}
void playinfo(void)
{
setcolor(LIGHTBLUE);
rectangle(P1info_xy);
rectangle(P2info_xy);
rectangle(Writerinfo_xy);
setcolor(WHITE);
settextstyle(1,0,3);
outtextxy(140,420,"Writer By : Gu Rui");
settextstyle(0,0,1);
outtextxy(40,460,"Wellcome to send mail to me:guruilong1983@sina.com");
}
void cha_up(int i,int j,int p)
{
int up_station;
int n;
if(p==1) n=6;
else if(p==2) n=7;
else return;
if(j<=0) return;
up_station=a[j-1];
switch(up_station){
case 0 : break;
case 1 :
case 2 : return;
case 3 : Bombnumber[p-1]+=2;break;
case 4 : powerx[p-1]+=3;powery[p-1]+=3;break;
case 5 : return;
case 6 :
case 7 : break;
case 8 : play_die(p);break;
default : return;
}
up_station=a[j];
if(up_station!=5)
draw(i,j,0);
draw(i,j-1,n);
}
void cha_down(int i,int j,int p)
{
int up_station;
int n;
if(p==1) n=6;
else if(p==2) n=7;
else return;
if(j>=12) return;
up_station=a[j+1];
switch(up_station){
case 0 : break;
case 1 :
case 2 : return;
case 3 : Bombnumber[p-1]+=2;break;
case 4 : powerx[p-1]+=3;powery[p-1]+=3;break;
case 5 : return;
case 6 :
case 7 : break;
case 8 : play_die(p);break;
default : return;
}
up_station=a[j];
if(up_station!=5)
draw(i,j,0);
draw(i,j+1,n);
}
void cha_left(int i,int j,int p)
{
int up_station;
int n;
if(p==1) n=6;
else if(p==2) n=7;
else return;
if(i<=0) return;
up_station=a[j][i-1];
switch(up_station){
case 0 : break;
case 1 :
case 2 : return;
case 3 : Bombnumber[p-1]+=2;break;
case 4 : powerx[p-1]+=3;powery[p-1]+=3;break;
case 5 : return;
case 6 :
case 7 : break;
case 8 : play_die(p);break;
default : return;
}
up_station=a[j];
if(up_station!=5)
draw(i,j,0);
draw(i-1,j,n);
}
void cha_right(int i,int j,int p)
{
int up_station;
int n;
if(p==1) n=6;
else if(p==2) n=7;
else return;
if(i>=14) return;
up_station=a[j][i+1];
switch(up_station){
case 0 : break;
case 1 :
case 2 : return;
case 3 : Bombnumber[p-1]+=2;break;
case 4 : powerx[p-1]+=3;powery[p-1]+=3;break;
case 5 : return;
case 6 :
case 7 : break;
case 8 : play_die(p);break;
default : return;
}
up_station=a[j];
if(up_station!=5)
draw(i,j,0);
draw(i+1,j,n);
}
void lose(int p)
{
int m,n;
int key;
char *bbb;
for(m=0;m<2;m++)
for(n=0;n<8;n++){
TimeCounter[m][n]=999;
}
KillTimer();
cleardevice();
setbkcolor(BLACK);
DrawStar();
setcolor(RED);
settextstyle(1,0,4);
sprintf(bbb,"Player%d Is Loss",p);
outtextxy(150,170,bbb);
settextstyle(1,0,2);
outtextxy(100,350,"Press ESC to quit,ENTER to restart game");
Gamestate=1;
}
void play_die(int i)
{
char *aaa;
life[i-1]--;
setcolor(LIGHTRED);
settextstyle(1,0,1);
setfillstyle(1,BLUE);
if(life[i-1]==0) { lose(i);return; }
if(i==1){
sprintf(aaa,"%d",life[0]);
bar(599,14,620,36);
outtextxy(600,15,aaa);
draw(Relive1[0],Relive1[1],6);
}
if(i==2){
sprintf(aaa,"%d",life[1]);
bar(599,250,620,270);
outtextxy(600,250,aaa);
draw(Relive2[0],Relive2[1],7);
}
}
void c_blast(int i,int j)
{ int m,n;
for(m=0;m<2;m++){
for(n=0;n<7;n++){
if(Blastx[m][n]==i&&Blasty[m][n]==j){
TimeCounter[m][n]=BlastTime1-1;
return;
}
}
}
}
void blast(int i,int j,int k,int p)
{
int station;
int m;
int ap;
draw(i,j,p);
for(m=1;m<=powerx[k];m++){
if(i+m>14) break;
else{
station=a[j][i+m]; /* right meet a item */
switch(station){
case 0 : if(p==8){draw(i+m,j,p);} break;
case 1 : m=powerx[k]+1;break;
case 2 : if(p==8){
draw(i+m,j,p);
}
if(p==0){
ap=random(4);
if(ap==1&&Map_bomb!=0){
draw(i+m,j,3);
Map_bomb--;
}
if(ap==2&&Map_power!=0){
draw(i+m,j,4);
Map_power--;
}
}
m=powerx[k]+1;break;
case 3 :
case 4 : m=powerx[k]+1;break;
case 5 : c_blast(i+m,j);break;
case 6 : draw(i+m,j,p);play_die(1);break;
case 7 : draw(i+m,j,p);play_die(2);break;
case 8 : draw(i+m,j,p);break;
default : break;
}
}
}
for(m=1;m<=powerx[k];m++){
if(i-m<0) break;
else{
station=a[j][i-m]; /* left meet a item */