Click here to Skip to main content
15,795,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 ");
    else if (door == 2)

Updated 1-Nov-17 14:46pm

1 solution

I would use a State Design Pattern[^] to manage each room: Door access, content and puzzles...
Share this answer
Bakhshi-faisal 2-Nov-17 5:57am    
this is too complicated i don't know about OOP i just want to create it with simple codition of while or maybe for condition without pattren and i should open the door by chosing the first one or the second

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900