本文介绍了创造捐赠游戏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用c#创建简单的dongeon游戏。玩家应选择两扇门,如果他选择第一扇门,他应该失去一分,如果他选择了第二扇门,他应该得到一分,如果他选择了第二扇门,当他达到0分时,他应该失去这一点应该结束,选择门的条件应该重复20次



我尝试过的事情:



i'm trying to create simple dongeon game in c#. the player should chose between 2 doors if he chose the first door he should lose one point and if he chose the second door he should get a point and if he chose the second door he should lose the point when he reach to 0 point the game should be over and the codition of chosing the doors should repeat 20 times

What I have tried:

<blockquote class="quote"><div class="op">Quote:</div>int  health, door,level;
health = 20;
level = 20;
string name;

Console.WriteLine("write your name ");
name = Convert.ToString(Console.ReadLine());
Console.WriteLine("hello " + name + " welcome to the ddungeon \n");

Console.WriteLine("you want to open the the right door (press 1) or the left one (press 2)");
door = Convert.ToInt32(Console.ReadLine());

while(level < 20 && health > 0)
{
    door = Convert.ToInt32(Console.ReadLine());
    if (door == 1)
    {
        Console.WriteLine("you have chance ");
        Console.WriteLine(health);
        health++;
        level++;
    }
    else if (door == 2)
    {

        health--;
        level--;
        Console.WriteLine(health);
    }
}

Console.Read();</blockquote>

推荐答案


这篇关于创造捐赠游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 18:01