国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#繪制飛行棋地圖小程序

2020-01-24 01:00:00
字體:
來源:轉載
供稿:網友

1、 初始化地圖,在繪制時可先將地圖進行初始化,用數組來存儲關卡的位置,然后利用循環給地圖中 關卡所在處賦予代表關卡的值。

關鍵代碼如下

/// <summary>/// 初始化游戲地圖/// </summary> static void InitialMap(){for (int i=0;i<Map.Length;i++){Map[i] =0;}//用于存儲關卡位置int[] luckyTurn = { 6, 23, 40, 55, 69, 83,98 };//幸運轉盤 1int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷 2int[] pause = { 9, 27, 60, 93 };//暫停 3int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90};//時空隧道 4for (int i=0;i<luckyTurn.Length;i++){int pos = luckyTurn[i];Map[pos] = 1;}for (int i=0;i<landMine.Length;i++){Map[landMine[i]] = 2;}for (int i=0;i<pause.Length;i++){int pos = pause[i];Map[pos] = 3;}for(int i=0;i<timeTunnel.Length;i++){int pos = timeTunnel[i];Map[pos] =4;}}

2、檢查坐標的值,在將地圖進行初始化之后,便可開始進行繪制地圖的操作了,地圖繪制可使用 在程序設計時所講的分布繪制,在繪制地圖時應檢驗該該坐標點的值,在根據該點的值繪制相應的圖案,在檢查時根據值 返回相應的圖案 ,在利用循環繪制出即可,檢查坐標的值代碼如下:

/// <summary>/// 獲得要繪制的坐標/// </summary>/// <param name="i"> 要繪制的坐標</param>/// <returns></returns>static string GetMapString(int i){string Result="";//用于返回 給一個坐標相應的圖案if (playerPos[0] == i && playerPos[1] == i)//判斷是否是對戰雙方所在此處{Console.ForegroundColor = ConsoleColor.Yellow;//設置圖案的前景色為黃色Result = "<>";//得到兩人均在圖案}else if (playerPos[0] == i){Console.ForegroundColor = ConsoleColor.Yellow;Result = "A";//得到A均在圖案}else if (playerPos[1] == i){Console.ForegroundColor = ConsoleColor.Yellow;Result = "B";//得到B均在圖案}else{switch (Map[i]){case 0:Console.ForegroundColor = ConsoleColor.White;Result = "□";//得到普通均在圖案break;case 1:Console.ForegroundColor = ConsoleColor.Red;Result = "○";//得轉盤圖案break;case 2:Console.ForegroundColor = ConsoleColor.Blue;Result = "☆";break;case 3:Console.ForegroundColor = ConsoleColor.Green;Result = "▲";break;case 4:Console.ForegroundColor = ConsoleColor.DarkBlue;Result = "

主站蜘蛛池模板:
浏阳市|
安徽省|
长垣县|
临澧县|
莎车县|
乌拉特前旗|
奈曼旗|
西丰县|
松潘县|
黄石市|
秀山|
洪江市|
定兴县|
华蓥市|
白沙|
武强县|
雷州市|
英山县|
梧州市|
德令哈市|
锦州市|
驻马店市|
来凤县|
依安县|
秦皇岛市|
秦安县|
稻城县|
长汀县|
太保市|
越西县|
平乡县|
扬中市|
米脂县|
钟山县|
临沧市|
赫章县|
内黄县|
奉贤区|
舒兰市|
高尔夫|
阳江市|