| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1113 人关注过本帖
标题:飞行棋,跟着写,还是不会,太菜了。。。。。
取消只看楼主 加入收藏
大口吃奶
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-2-20
收藏
 问题点数:0 回复次数:0 
飞行棋,跟着写,还是不会,太菜了。。。。。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 飞行棋
{
    class Program
    {
        //定义全局变量。
        static int[] Maps = new int[100];
      
        //声明静态数组存储玩家A和B;
        public  static int[] Playpos =  {0,0};
      
        //存储输入玩家姓名
        static  string[] PlayName = new string[2];
        static void Main(string[] args)
        {
            //画初始化
            GameShow();
           InputPlayName();
            IntiMaps();
           DrawMap();
            Console.ReadKey();
        }
        #region 游戏线头
        public static void GameShow()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("************************");
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("************************");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("*****我的飞行棋*********");
            Console.WriteLine("************************");
            Console.ForegroundColor =ConsoleColor.Green ;
            Console.WriteLine("************************");
            Console.ForegroundColor=ConsoleColor .DarkBlue ;
            Console.WriteLine("************************");
        
        
        }
        #endregion

        #region    //输入玩家姓名。
        public static void InputPlayName()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console .WriteLine ("请输入玩家A姓名。");
            PlayName [0]=Console .ReadLine ();
                while  (PlayName [0]=="")
                {
                    Console .WriteLine ("玩家姓名不能为空。");
                    Console.WriteLine("请重新输入玩家A姓名。");
                PlayName [0]=Console .ReadLine ();
                }
                Console.WriteLine("请输入玩家B姓名。");
                PlayName[1]=Console.ReadLine();

                while (PlayName [1]==""||PlayName [1]==PlayName [0])
                {
                    if (PlayName [1]=="")
                    {
                        Console .WriteLine ("玩家不能为空");
                        PlayName [1]=Console .ReadLine ();
                    
                    
                    }
                    else  if (PlayName [0]==PlayName [1])
                    {
                        Console.WriteLine("不能与A相同。");
                            PlayName [1]=Console .ReadLine ();
                    
                    }
               
                }
        
        
        }
#endregion



        #region 初始化地图
        public static void IntiMaps()
        {
            int[] luckyturn = { 6, 23, 40, 55, 69, 83 };//幸运轮盘◎
            for (int i = 0; i <= luckyturn.Length; i++)
            {
              
                Maps[luckyturn [i ]] = 1;
            
            
            }
            int[] landMine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 };//地雷☆
            for (int i = 0; i <= landMine.Length; i++)
            {
               
                Maps[landMine [i ] ]=2;
            
            }
            int[] pause = { 9, 27, 60, 93 };//暂停▲
            for (int i = 0; i <= pause.Length; i++)
            {
               
                Maps[pause [i ] ]= 3;


            }
            int[] timeTunnel = { 20, 25, 45, 63, 72, 88, 90 };//时空隧道卐
            for (int i = 0; i <= timeTunnel.Length; i++)
            {
               
                Maps[timeTunnel [i ]] = 4;


            
        }
        }
#endregion
         #region 初始A和B
        public  static string   GetMapString(int pos)
        {           string str=" ";
      
                //如果A和B的坐标相同并且在地图上画"<>"。
                if (Playpos[0] == pos &&Playpos[1]==pos  )
                {
                    str="<>";


                }
                else if (Playpos[0] == pos)
                {
               
                    str ="A";
               
               
                }
                else
                    if (Playpos[1] == pos)
                {
                    str ="B";
               
               
                }
                    else
                   {
                       switch (Maps[pos])
                       {
                           case 0:
                               Console.ForegroundColor = ConsoleColor.Yellow;
                               str ="□";
                               break;
                           case 1:
                               Console.ForegroundColor = ConsoleColor.Blue;
                               str ="◎";
                               break;
                           case 2:
                               Console.ForegroundColor = ConsoleColor.Green;
                               str ="☆";
                               break;
                           case 3:
                               Console.ForegroundColor = ConsoleColor.Gray;
                              str ="▲";
                               break;
                           case 4:
                               Console.ForegroundColor = ConsoleColor.DarkBlue;
                               str ="卐";
                               break;
                       
                       
                    
                       }
                    
                }
            return str ;
            }
#endregion

        #region   画地图
        public static void  DrawMap()
            {
                  for (int i = 0; i <= 29; i++)
            {
                Console.Write(GetMapString(i));
            }
            //画右边第一列
            Console.WriteLine();
            for (int i = 30; i <= 34; i++)
            {
                for (int j = 0; j < 29; j++)
                {
                    Console.Write("  ");
                }
                Console.WriteLine(GetMapString(i));
            }
            //画第二行
            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();
         
            
            }

   
#endregion   
        
        
    }

}
照着传智博客的思路写,居然也出错。
没有初始化地图。
GetMapString()没有看到返回值str.
祝各位大神春节快乐,合家欢乐。
搜索更多相关主题的帖子: 飞行棋 public 姓名 
2015-02-20 16:30
快速回复:飞行棋,跟着写,还是不会,太菜了。。。。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036386 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved