黑马程序员__飞行棋
黑马程序员__飞行棋
------- Windows Phone 7手机开发、.Net培训、期待与您交流! -------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 飞行棋
{
class Program
{
/* 在下面的数组储存我们游戏的地图关卡
* 数组的下标为0的元素对应我们地图上的第一格 下标为n对应n+1格
* 在数组中1表示幸运轮盘◎
*2表示地雷 ☆
*3表示暂停▲
*4表示时空隧道卐
*0表示普通
*/
//定义一个地图的数组
static int[] map = new int[100];
static int[] playerPos = { 0, 0 };//存玩家A和B的下标
static void Main(string[] args)
{
//定义一个地图的数组
int[] map = new int[100];
//存玩家A和B
string[] names = new string[2];
Program.Show();
Console.WriteLine("请输入玩家A的姓名?");
names[0] = Console.ReadLine();
while (names[0] == "")
{
Console.WriteLine("您输入的内容为空,请重新输入");
names[0] = Console.ReadLine();
}
Console.WriteLine("请输入玩家B的姓名");
names[1] = Console.ReadLine();
//定义一个bool类型接收忽略大小写的比较值
while (names[1] == "" || names[1].Equals(names[0], StringComparison.OrdinalIgnoreCase)==true)
{
if (names[1] == "")
{
Console.WriteLine("玩家B输入的不能为空,请重新输入");
}
if (names[1].Equals(names[0], StringComparison.OrdinalIgnoreCase) == true)
{
Console.WriteLine("改姓名已经被玩家A占用,请重新输入");
}
names[1] = Console.ReadLine();
}
Console.Clear();
Program.Show();
Console.WriteLine(" 对战开始......");
Console.WriteLine("{0}用A来表示", names[0]);
Console.WriteLine("{0}用B来表示", names[1]);
Console.WriteLine("如果AB在同一个位置用<>来表示");
InitialMap();//初始化地图
DraMap();//
Console.ReadKey();
}
/// <summary>
///显示飞行棋
/// </summary>
static void Show()
{
Console.WriteLine("*************************************");
Console.WriteLine("*** ***");
Console.WriteLine("*** 飞 行 棋 ***");
Console.WriteLine("*** ***");
Console.WriteLine("*************************************");
}
/// <summary>
/// 对地图上的关卡进行初始化
/// </summary>
static void InitialMap()
{
int[] luckTurn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘1
int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷2
int[] pause = { 9, 27, 60, 33 };//暂停3
int[] timeturnl = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道4
for(int i=0;i<luckTurn.Length;i++)
{
int p = luckTurn[i];
map[p] = 1;
}
for (int i = 0; i < landMine.Length; i++)
{
map[landMine[i]] = 2;
}
for (int i = 0; i < pause.Length; i++)
{
map[pause[i]] = 3;
}
for (int i = 0; i < pause.Length; i++)
{
map[timeturnl[i]] = 4;
}
}
/// <summary>
/// 获得第pos坐标上应绘制的图案
/// </summary>
/// <param name="pos">要绘制的坐标</param>
/// <returns></returns>
static string GetMapString(int pos)
{
string result = "";
if (playerPos[0] == pos && playerPos[1] == pos)
{
Console.ForegroundColor = ConsoleColor.Yellow;
result= "<>";
}
else if (playerPos[0] == pos)
{
Console.ForegroundColor = ConsoleColor.Yellow;
result="A";
}
else if (playerPos[1] == pos)
{
Console.ForegroundColor = ConsoleColor.Yellow;
result="B";
}
else
{
switch (map[pos])
{
case 0:
Console.ForegroundColor = ConsoleColor.White;
result="□";
break;
case 1:
Console.ForegroundColor = ConsoleColor.Red;
result="◎";
break;
case 2:
Console.ForegroundColor = ConsoleColor.Green;
result="★";
break;
case 3:
Console.ForegroundColor = ConsoleColor.Blue;
result="▲";
break;
case 4:
Console.ForegroundColor = ConsoleColor.DarkBlue;
result="卐";
break;
}
}
return result;
}
/// <summary>
/// 画地图
/// </summary>
static void DraMap()
{
for (int i = 0; i <= 29; i++)
{
Console.Write(GetMapString(i));
}
//第一行绘制完毕
Console.WriteLine();
//绘制第一列
for (int i = 30; i <= 34; i++)
{
//29个双空格
for (int j = 0; j < 29; j++)
{
Console.Write(" ");
}
// Console.WriteLine(GetMapString(i));
string str = GetMapString(i);
Console.WriteLine(str);
}
for (int i = 64; i >= 35; i--)
{
Console.Write(GetMapString(i));
}
Console.WriteLine();
for (int i = 65; i <= 69; i++)
{
Console.WriteLine(GetMapString(i));
}
for (int i = 70; i <= 99; i++)
{
Console.Write(GetMapString(i));
}
Console.WriteLine();
}
}
}
黑马程序员__飞行棋相关推荐
- 黑马程序员 骑士飞行棋
------- Windows Phone 7手机开发..Net培训.期待与您交流! ------- 游戏说明: 有一个100格的棋盘(当然也可以自定义200甚至300格),玩家A和玩家B互掷骰子,根 ...
- 黑马程序员 骑士飞行棋源码
---------------------- Windows Phone 7手机开发..Net培训.期待与您交流! ---------------------- using System; using ...
- 黑马程序员-骑士飞行棋
---------------------- Windows Phone 7手机开发.Net培训.期待与您交流! ---------------------- using System; using ...
- 黑马程序员__关于自己的一些学习死角的再学习(基于老毕的java基础视频)
----------------------<ahref="http://edu.csdn.net"target="blank">ASP.Net+A ...
- 黑马程序员__银行业务调度系统
------- <a href="http://www.itheima.com" target="blank">android培训</a> ...
- 梦想黑马程序员__夜雨飘零的心绪
夜雨飘零的心绪 ---------- android培训 .java培训.期待与您交流! ---------- ------------------------------------------- ...
- 梦想在三十岁起航!__来自黑马程序员69期安卓班的学员
梦想在三十岁起航! 多久没动笔了?恐怕我也记不起来了,在生活不如意的时候也曾想写点什么,可是却又全然没有思路,曾经的文思泉涌,早已在长时间浑浑噩噩的工作生活中干涸了,而今宛如仲永一般,泯然众人 ...
- 黑马程序员—[.Net就业薪资] 黑马.Net 12期毕业33个工作日,就业率达98%,平均薪水:6972元
文章来源:黑马程序员,黑马论坛 黑马.Net 12期毕业33个工作日,就业率达98%,平均薪水:6972元 班级名称:黑马.Net 12期 毕业时间:2014年6月17日 总人数: ...
- jQuery学习笔记【黑马程序员】
文章目录 前言 JQury学习 1.引入JQury 2.jqury简介 3.jQuery入口函数 4.dom对象与jQuery对象 4.1.dom对象 4.2.jQuery对象 4.3.jQuery对 ...
最新文章
- tornado压力测试
- 图论之tarjan缩点
- 后端_Laravel
- python怎么写文件-python 头文件怎么写
- 如何生成WebPart的部署文件(wsp文件)
- C++中返回对象的情形及RVO
- JSP中的include指令
- 设计模式(C++实现)--一句话总结
- combineLatest 使用的一个陷阱和基于 debounceTime 的解决方案
- 重复download CRM已经存在的parent equipment
- 5位院士谈科研瓶颈:必须“逼着自己在精神上愿意吃苦”
- NSA(美国国安局)泄漏Exploit分析
- C语言 | 内存对齐01 - 什么是内存对齐
- Div图片垂直居中的方法
- Web调取摄像头拍照
- hive根据已有表创建新表_读取Hive中所有表的表结构,并在新Hive库中创建表,索引等...
- DNS劫持又称域名劫持
- L1-061 新胖子公式
- org.springframework.data.mapping.PropertyReferenceException: No property item found for type BItem!
- 用python或者vba把一个excel表格拆分成多个excel表格