C语言实现骑士飞行棋

本文实例为大家分享了C语言实现骑士飞行棋的具体代码,供大家参考,具体内容如下

/* Author Mr.Long
 * Date  2015年12月2日17:33:17 
 */
#include
#include
#include
#include
#include
#define random(x) (rand()%x)
 
using namespace std;
 
string player[2]={"玩家A","玩家B"};
int map[100];
int playerPos[2]={0,0};
int gamePlayer = 0;
bool isGameOver = false;
int winer = -1;
int pausePlayer = -1; 
//0□正常 1☆幸运轮盘  2◎地雷  3△暂停  4卍时空隧道
 string getLogo(int pos){ 
 
 string res = "□";
 if((playerPos[0] == pos) && (playerPos[1] == pos)){
 res = "<>";  
 }else if(playerPos[0]==pos){
  res = "A";
 }else if(playerPos[1]==pos){
  res = "B";
 }else{
  switch(map[pos]){
  case 1:
   res = "☆"; // 幸运轮盘
   break;
  case 2:
   res = "◎"; // 地雷 
   break;
  case 3:
   res = "△"; // 暂停 
   break;
  case 4:
   res = "卍"; // 时空隧道 
   break;
  } 
 }
 return res;
 }
 void drowMap(){ //绘制地图 
 
 for(int i = 0;i<=29;++i){
  cout<=35;i--){
 cout<玩家同处一个位置】"<>tmpStr;
 while(tmpStr==""){
 cout<<"玩家名字不能为空请重新输入___" <>tmpStr;
 }
 player[0] = "A" + tmpStr;
 
 cout<<"请输入玩家B的名字___" <>tmpStr;
 while(tmpStr==""){
 cout<<"玩家名字不能为空请重新输入___" <>tmpStr;
 }
 while(tmpStr == player[0]){
 cout<<"玩家名字不能重复,请重新输入___" <>tmpStr;
 }
 player[1] = "B" + tmpStr;
 system("cls");
 cout<<"***玩家加入成功..."<>a;
  if(a=='g'){
  system("cls");
  number = random(6)+1;
  cout<<"***玩家["<=99){
  gameOver();
  }else{
  switch(map[pos]){
  case 0:
   if(pausePlayer = -1){
   gamePlayer = !gamePlayer;
   }else if(pausePlayer = 0){
   pausePlayer++;
   }else if(pausePlayer = 1){
   pausePlayer = -1;
   }
   break;
  case 1:
   int cnumber;
   cout<<"***哇哦!玩家["<>cnumber;
   if(cnumber == 1){
    int t = 0;
    t = playerPos[gamePlayer];
    playerPos[gamePlayer] = playerPos[!gamePlayer];
    playerPos[!gamePlayer] = t;
   }else if(cnumber == 2){
    playerPos[!gamePlayer] -=6 ;
   }else{
    cout<<"输入非规定数字!机会丢失。"<=99){
   gameOver();
   }
   gamePlayer = !gamePlayer;
   break;
  }
  } 
 }else if(a == 'a'){
  winer = 0;
  gameOver();
 }else if(a == 'b'){
  winer = 1;
  gameOver();
 }
 for(int i=0;i<=1;i++){
  if(playerPos[i]<0)
  playerPos[i] = 0; 
 }
 if(!isGameOver){
  drowMap();
 } 
 }
 }
 
 int main(){
 srand((unsigned)time(NULL));
 
 initUI();
 cout<<"***开始初始化玩家设置..."< 
 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

你可能感兴趣的:(C语言实现骑士飞行棋)