debug:僵尸被子彈射中有時候不會死掉,。。(前面不用管,,因為字數上線,,我刪了一部分)
if(c==32){if(right==1){for(int Bullets=y+1;Bullets<=20;Bullets++){a[zombiesX][zombiesY]=0;if(zombiesY==Bullets&&zombiesX==x){zombiesX=1;zombiesY=1;a[zombiesX][zombiesY]=0;Integral++;}if(zombiesY==y&&zombiesX==x){system("cls");cout<<" GAME OVER "<<endl;cout<<"Integral:"<<Integral<<endl;cout<<" thank you to play";return 0;}if(zombiesX!=x&&zombiesX<x){zombiesX++;}else if(zombiesY!=y&&zombiesY<y){zombiesY++;}else if(zombiesX!=x&&zombiesX>x){zombiesX--;}else if(zombiesY!=y&&zombiesY>y){zombiesY--;}a[zombiesX][zombiesY]=4;int Zx=x,Zy=y,ZB=Bullets;system("cls");cout<<"Integral:"<<Integral<<endl;for(int i=0;i<20;i++){if(i!=x){for(int o=0;o<20;o++){if(o==Bullets&&i==x)cout<<8<<" ";else if(o!=Bullets)cout<<a[i][o]<<" ";}cout<<endl;}else{for(int o=0;o<20;o++){if(o==Bullets+1&&i==x)cout<<8<<" ";else if(o!=Bullets)cout<<a[i][o]<<" ";}cout<<endl;}}if(up==1)cout<<"上";if(down==1)cout<<"下";if(right==1)cout<<"子彈方向:右射速:"<<10000-Rateofire<<"m/秒";if(left==1)cout<<"子彈方向:左射速:"<<10000-Rateofire<<"m/秒";cout<<endl<<"按q退出by Luo Tsun Lam Jerry";Sleep(Rateofire);Rateofire+=100;}}if(left==1){for(int Bullets=y-1;Bullets>=0;Bullets--){a[zombiesX][zombiesY]=0;if(zombiesY==Bullets&&zombiesX==x){zombiesX=1;zombiesY=1;a[zombiesX][zombiesY]=0;Integral++;}if(zombiesY==y&&zombiesX==x){system("cls");cout<<" GAME OVER "<<endl;cout<<"Integral:"<<Integral<<endl;cout<<" thank you to play";return 0;}if(zombiesX!=x&&zombiesX<x){zombiesX++;}else if(zombiesY!=y&&zombiesY<y){zombiesY++;}else if(zombiesX!=x&&zombiesX>x){zombiesX--;}else if(zombiesY!=y&&zombiesY>y){zombiesY--;}a[zombiesX][zombiesY]=4;int Zx=x,Zy=y,ZB=Bullets;system("cls");cout<<"Integral:"<<Integral<<endl;for(int i=0;i<20;i++){if(i!=x){for(int o=0;o<20;o++){if(o==Bullets&&i==x)cout<<8<<" ";else if(o!=Bullets)cout<<a[i][o]<<" ";}cout<<endl;}else{for(int o=0;o<20;o++){if(o==Bullets-1&&i==x)cout<<8<<" ";else if(o!=Bullets)cout<<a[i][o]<<" ";}cout<<endl;}}if(up==1)cout<<"上";if(down==1)cout<<"下";if(right==1)cout<<"子彈方向:右射速:"<<10000-Rateofire<<"m/秒";if(left==1)cout<<"子彈方向:左射速:"<<10000-Rateofire<<"m/秒";cout<<endl<<"按q退出by Luo Tsun Lam Jerry";Sleep(Rateofire);Rateofire+=100;}}system("cls");cout<<"Integral:"<<Integral<<endl;for(int i=0;i<20;i++){for(int o=0;o<20;o++){cout<<a[i][o]<<" ";}cout<<endl;}if(up==1)cout<<"上";if(down==1)cout<<"下";else if(right==1)cout<<"子彈方向:右射速:"<<10000-Rateofire<<"m/秒";else if(left==1)cout<<"子彈方向:左射速:"<<10000-Rateofire<<"m/秒";cout<<endl<<"按q退出by Luo Tsun Lam Jerry";}Rateofire=0; }}
這是植物大決戰(zhàn)僵尸代碼,是子彈和僵尸觸碰死亡邏輯代碼,,最好不要亂刪游戲自帶文檔和代碼,,