C 基礎知識 飛行棋小遊戲

2021-07-10 23:36:44 字數 4550 閱讀 2871

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

namespace 飛行棋

console.writeline("請輸入玩家b的姓名");

playername[1] = console.readline();

while (playername[1] == "" || playername[0] == playername[1])

else

console.readline();

}#endregion

//輸完姓名清屏

console.clear();

initailmap();

drawmap();

#region //玩遊戲

while ((playerpos[0] < 99) && (playerpos[1] < 99))

else

if (playerpos[0] >= 99)

贏了", playername[0]);

}if (flags[1] == false)

else

if (playerpos[1] >= 99)

贏了", playername[1]);}}

#endregion

console.writeline();

console.readkey();

}//遊戲頭

public

static

void

gameshow()

//初始化地圖,即初始化陣列

public

static

void

initailmap()

;for (int i = 0; i < luckyturn.length; i++)

int landmine = ;

for (int i = 0; i < landmine.length; i++)

int pause = ;

for (int i = 0; i < pause.length; i++)

int timetunnel = ;

for (int i = 0; i < timetunnel.length; i++)

}//畫地圖,畫出方塊和關卡

public

static

void

drawmap()

的士兵用a表示", playername[0]);

console.writeline("的士兵用b表示", playername[1]);

console.writeline("圖例:幸運輪盤○,地雷☆,暫停△,時空隧道卍");

#region 第一橫行

for (int i = 0; i < 30; i++)

#endregion

//畫完第一橫行換行

console.writeline();

#region 第一豎行

for (int i = 30; i < 35; i++)

console.write(drawstringmap(i));

console.writeline();

}#endregion

#region 第二橫行

for (int i = 64; i >= 35; i--)

#endregion

//畫完第二橫行換行

console.writeline();

#region 第二豎行

for (int i = 65; i <= 69; i++)

#endregion

#region 第三橫行

for (int i = 70; i <= 99; i++)

#endregion

//畫完第三橫行換行

console.writeline();

}//畫關卡 返回乙個關卡

public

static

string

drawstringmap(int i)

else

if (playerpos[0] == i)

else

if (playerpos[1] == i)

else

switch (maps[i])

return str;

}//玩遊戲

public

static

void

playgame(int playnumber)

按任意鍵開始擲骰子", playername[playnumber]);

console.readkey(true);

console.writeline("擲出了點", playername[playnumber], rnumber);

playerpos[playnumber] += rnumber;

console.readkey(true);

console.writeline("按任意鍵開始行動", playername[playnumber]);

console.readkey(true);

console.writeline("行動完了", playername[playnumber]);

console.readkey(true);

if (playerpos[playnumber] == playerpos[1 - playnumber])

踩到了玩家,玩家退六格", playername[playnumber], playername[1 - playnumber], playername[1 - playnumber]);

playerpos[1 - playnumber] -= 6;

}else

踩到了方塊,安全", playername[playnumber]);

console.readkey(true);

break;

case

1: console.writeline("踩到了幸運輪盤,選擇1交換位置,2轟炸對方", playername[playnumber]);

string input = console.readline();

while (true)

選擇跟交換位置", playername[playnumber], playername[1 - playnumber]);

console.readkey(true);

int temp = playerpos[playnumber];

playerpos[playnumber] = playerpos[1 - playnumber];

playerpos[1 - playnumber] = temp;

console.writeline("交換成功");

break;

}else

if (input == "2")

選擇轟炸", playername[playnumber], playername[1 - playnumber]);

console.readkey(true);

playerpos[1 - playnumber] -= 6;

console.writeline("退了六格", playername[1 - playnumber]);

console.readkey(true);

break;

}else

}break;

case

2: console.writeline("踩到了地雷,退六格", playername[playnumber]);

console.readkey(true);

playerpos[playnumber] -= 6;

break;

case

3: console.writeline("踩到了暫停,跳過一回合", playername[playnumber]);

flags[playnumber] = true;

console.readkey(true);

break;

case

4: console.writeline("踩到了時空隧道,前進十格", playername[playnumber]);

console.readkey(true);

playerpos[playnumber] += 10;

break;

default:

break;}}

changepos();

console.clear();

drawmap();

}//限定位置,防止出界

public

static

void

changepos()

if (playerpos[0] >= 99)

if (playerpos[1] < 0)

if (playerpos[1] >= 99)}}

}

C 實現飛行棋小遊戲

邏輯圖以下是擲色子的乙個 比較有代表性,裡面的邏輯和內容都已注釋,可通過注釋了解這一方法的運作模式。public static void rowtouzi int playerpos 擲色子 按任意鍵開始擲色子 playernames playerpos 不顯示用ucvnajjk戶按下的任意鍵 co...

C 飛行棋遊戲

1 using system 2using system.collections.generic 3using system.linq 4using system.text 5using system.threading.tasks 67 namespace 05.飛行棋遊戲834 35 conso...

C 編寫飛行棋遊戲

using system using system.collections.generic using system.linq using system.text using system.threading.tasks using system.drawing 繪圖 namespace plane...