欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

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

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C#教程|點(diǎn)擊: 次

1、 初始化地圖,在繪制時(shí)可先將地圖進(jìn)行初始化,用數(shù)組來存儲(chǔ)關(guān)卡的位置,然后利用循環(huán)給地圖中 關(guān)卡所在處賦予代表關(guān)卡的值。

關(guān)鍵代碼如下

/// <summary>
/// 初始化游戲地圖
/// </summary> 
static void InitialMap()
{
for (int i=0;i<Map.Length;i++)
{
Map[i] =0;
}
//用于存儲(chǔ)關(guān)卡位置
int[] luckyTurn = { 6, 23, 40, 55, 69, 83,98 };//幸運(yùn)轉(zhuǎn)盤 1
int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷 2
int[] pause = { 9, 27, 60, 93 };//暫停 3
int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90};//時(shí)空隧道 4
for (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、檢查坐標(biāo)的值,在將地圖進(jìn)行初始化之后,便可開始進(jìn)行繪制地圖的操作了,地圖繪制可使用 在程序設(shè)計(jì)時(shí)所講的分布繪制,在繪制地圖時(shí)應(yīng)檢驗(yàn)該該坐標(biāo)點(diǎn)的值,在根據(jù)該點(diǎn)的值繪制相應(yīng)的圖案,在檢查時(shí)根據(jù)值 返回相應(yīng)的圖案 ,在利用循環(huán)繪制出即可,檢查坐標(biāo)的值代碼如下:

/// <summary>
/// 獲得要繪制的坐標(biāo)
/// </summary>
/// <param name="i"> 要繪制的坐標(biāo)</param>
/// <returns></returns>
static string GetMapString(int i)
{
string Result="";//用于返回 給一個(gè)坐標(biāo)相應(yīng)的圖案
if (playerPos[0] == i && playerPos[1] == i)//判斷是否是對(duì)戰(zhàn)雙方所在此處
{
Console.ForegroundColor = ConsoleColor.Yellow;//設(shè)置圖案的前景色為黃色
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 = "○";//得轉(zhuǎn)盤圖案
break;
case 2:
Console.ForegroundColor = ConsoleColor.Blue;
Result = "☆";
break;
case 3:
Console.ForegroundColor = ConsoleColor.Green;
Result = "▲";
break;
case 4:
Console.ForegroundColor = ConsoleColor.DarkBlue;
Result = "卍";
break;
}
}
return Result; //返回圖案 
}

3、繪制地圖,在得到 返回的圖案后,便可進(jìn)行地圖的繪制,這里給出繪制第一行的代碼

/// <summary>
/// 繪制游戲地圖
/// </summary>
static void DrownMap()
{
Console.WriteLine("圖例:幸運(yùn)轉(zhuǎn)盤 ○ 地雷 ☆ 暫停 ▲ 時(shí)空隧道 卍");
//畫第一行 下標(biāo)0-29 的地圖
for(int i=0;i<30;i++)//循環(huán)坐標(biāo)得到 第一行每個(gè)點(diǎn)的圖案
{
Console.Write(GetMapString(i)); //調(diào)用函數(shù)得到每個(gè)坐標(biāo)的圖案
}
Console.Write("\n");
Console.ResetColor();//重置前景色 
}

以上所述是小編給大家介紹的C#繪制飛行棋地圖小程序,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)我們網(wǎng)站的支持!

上一篇:WPF仿三星手機(jī)充電界面實(shí)現(xiàn)代碼

欄    目:C#教程

下一篇:C#實(shí)現(xiàn)導(dǎo)出List數(shù)據(jù)到xml文件的方法【附demo源碼下載】

本文標(biāo)題:C#繪制飛行棋地圖小程序

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6281.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有