C#基础入门实例

 #region 奥特曼打小怪兽
            // Random r = new Random();
            //定义奥特曼的数据
            //string atmName = "奥特曼";
            //int atmHP = 100;
            //int atmATK = r.Next(8, 13);
            //int atmRate = 30;


            定义怪兽的数据
            //string monsterName = "小怪兽";
            //int monsterHP = 100;
            //int monsterATK = r.Next(5, 9);
            //int monsterRate = 100;


            //每回合奥特曼先动手
            //判断有没有命中
            //如果命中了
            //怪兽血量减去奥特曼的攻击力
            //检测怪兽的血量有没有归零
            //如果归零
            //怪兽死亡,奥特曼胜利
            //如果没死
            //如果没有每命中


            //怪兽攻击奥特曼
            //判断有没有命中
            //如果命中了
            //奥特曼的血量减去怪兽的攻击力
            //检测奥特曼有没有被打死
            //如果奥特曼死亡,怪兽胜利
            //如果没有每命中
            //则开始新的回合


            //while (true)
            //{
            //    //奥特曼的回合
            //    Console.ReadKey(true);
            //    Console.WriteLine("{0}攻击了{1}", atmName, monsterName);
            //    int num = r.Next(1, 101);
            //    if (num <= atmRate)//代表奥特曼命中了
            //    {
            //        monsterHP -= atmATK;
            //        Console.WriteLine("{0}的攻击命中了,对{1}造成了{2}伤害,{1}还剩{3}点HP", atmName, monsterName, atmATK, monsterHP);
            //        if (monsterHP <= 0)//检测怪兽是否死亡
            //        {
            //            Console.WriteLine("{0}被残忍杀害,{1}沾满鲜血的双手获得胜利", monsterName, atmName);
            //            break;
            //        }

            //    }
            //    else
            //    {
            //        Console.WriteLine("{0}的攻击落空了", atmName);
            //    }


            //    //怪兽回合
            //    Console.ReadKey(true);
            //    Console.WriteLine("{0}攻击了{1}", monsterName, atmName);
            //    num = r.Next(1, 101);
            //    if (num <= monsterRate)//代表怪兽命中了
            //    {
            //        atmHP -= monsterATK;//奥特曼扣血
            //        Console.WriteLine("{0}的攻击命中了,对{1}造成了{2}伤害,{1}还剩{3}点HP", monsterName, atmName, monsterATK, atmHP);
            //        if (atmHP <= 0)//检测奥特曼是否死亡
            //        {
            //            Console.WriteLine("{0}终于被打败了,{1}的生存得以保证", atmName, monsterName);
            //            break;
            //        }

            //    }
            //    else
            //    {
            //        Console.WriteLine("{0}的攻击落空了", monsterName);
            //    }


            //}
            #endregion
#region 移动光标绘制不同的图形
            //Console.BackgroundColor = ConsoleColor.Blue;
            //Console.Clear();
            //Console.ForegroundColor = ConsoleColor.Red;
            //Console.WriteLine(" ");

            如果在控制台里设置光标的位置
            位置 = position
            在控制台里,行间距是2个宽度

            //int x = 10;
            //int y = 5;

            //Console.SetCursorPosition(x * 2, y);
            //Console.WriteLine("■");

            先监听玩家的按键
            //int x1 = 10;
            //int y1 = 5;
            //Console.SetCursorPosition(x1 * 2, y1);
            //Console.WriteLine("■");

            //while (true)
            //{
            //    Console.CursorVisible = false;
            //   char input = Console.ReadKey(true).KeyChar;

            //    switch (input)
            //    {
            //        case 'w':
            //            y -= 1;
            //            if (y <= 0)
            //            {
            //                y = 0;
            //            }
            //            break;
            //        case 's':
            //            y += 1;
            //            if (y >= 20)
            //            {
            //                y = 39;
            //            }
            //            break;
            //        case 'a':
            //            x -= 1;
            //            if (x <= 0)
            //            {
            //                x = 0;
            //            }
            //            break;
            //        case 'd':
            //            x += 1;
            //            if (x >= 39)
            //            {
            //                x = 39;
            //            }
            //            break;


            //        default:
            //            break;
            //    }
            //    //Console.Clear();

            //    Console.SetCursorPosition(x * 2, y);
            //    Console.WriteLine("■");
            //}
            #endregion
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LilyCoder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值