| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1111 人关注过本帖
标题:飞行棋,跟着写,还是不会,太菜了。。。。。
只看楼主 加入收藏
大口吃奶
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-2-20
收藏
 问题点数:0 回复次数:2 
飞行棋,跟着写,还是不会,太菜了。。。。。
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
外挂是什么瓜
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2015-4-1
收藏
得分:0 

r=a(1-sinθ)
2015-04-01 18:26
wangnannan
Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18
等 级:贵宾
威 望:87
帖 子:2546
专家分:9359
注 册:2007-11-3
收藏
得分:0 
同学 按我的感觉你进去了一个误区 做这种项目 不要在乎结果 重要在过程 比如在这学习过程中你对算法操作的理解 还有数组的操作是否更熟练了 逻辑的判断是否有误 代码是否有待优化 等等 等等 这都是值得学习的 而不是最后模仿着人家的 做出一个程序 我想等你把这过程中的问题都解决了 最终的结果不是难题

出来混,谁不都要拼命的嘛。 。拼不赢?那就看谁倒霉了。 。有机会也要看谁下手快,快的就能赢,慢。 。狗屎你都抢不到。 。还说什么拼命?
2015-04-03 08:49
快速回复:飞行棋,跟着写,还是不会,太菜了。。。。。
数据加载中...
 
   



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

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