C# 方法练习-制作简易飞行棋游戏

这篇博客介绍了如何使用C#编程语言来创建一个简单的飞行棋游戏。玩家1通过按下键盘的'a'键进行操作,而玩家2则通过按下'L'键进行交互。文章将探讨游戏的基本逻辑和键盘事件处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
玩家1按a键,玩家2按L键

using System;

namespace _02_demo
{
    class Program
    {
        /*
         * 0代表地图格子□
         * 1代表幸运盘◎
         * 2代表地雷☆
         * 3代表暂停▲
         * 4代表时空隧道卐
         */
        public static int[] map = new int[100];
        //玩家位置
        public static int[] player = new int[2];
        //玩家姓名
        public static string[] name = new string[2];
        //回合数
        public static int bout;
        //玩家暂停数
        public static int[] pause_bout = new int[2];
        //游戏结束
        public static bool over = false;
        //胜利玩家
        public static string winner;

        public static readonly int[] luck = { 6, 23, 40, 55, 69, 83 }; //幸运转盘
        public static readonly int[] landmine = { 5, 13, 17, 33, 38, 50, 64, 80, 94 }; //地雷
        public static readonly int[] pause = { 9, 27, 60, 93 }; //暂停
        public static readonly int[] tunnel = { 20, 25, 45, 63, 72, 88, 90 }; //时空隧道

        static void Main(string[] args)
        {
            GameTitel(); //输出游戏标题头
            InputName(); //让玩家输入姓名
            InitialMap(); //初始化地图
            //玩家开始游戏
            for (bout = 0; ; bout++){
                Console.Clear(); //清屏
                DrawMap(); //画地图
                StartGame(bout);
                //判断是否可以结束游戏
                if (over==true)
                {
                    break;
                }
            }
            Console.WriteLine("恭喜{0}玩家取得最后胜利!!!", winner);
        }

        /// <summary>
        /// 输出游戏标题头
        /// </summary>
        public static void GameTitel()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*************************");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("*************************");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Wr
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值