[ad_1]
I am not sure whether or not this has been answered before, but this question is really specific. I am attempting to code a dungeon generator in c#, and I want the size of the array to be dynamic, and it to display in the console as a grid, per the size inputted. I got the array to be dynamic, and it can display every index in a grid form, but I can't figure out how to make the amount of indexes in a row dynamic. Here's what I have so far:
Random rand = new Random();
int num;
num = Convert.ToInt32(Console.ReadLine());
int x = num;
int y = num;
int i = x - 1;
int j = y - 1;
int[,] dungeon = new int[x,y];
for(int z = 0; z <= i; z++)
int a = 0;
for( a = 0; a <= j; a++)
dungeon[a,z] = rand.Next(0,2);
for (int h = 0; h <= i; h++)
{
if (h == 0)
Console.WriteLine("#-#-#-#-#");
Console.WriteLine("|" + dungeon[h,0] + "|" + dungeon[h,1] + "|" + dungeon[h,2] + "|" + dungeon[h,3] + "|");
Console.WriteLine("#-#-#-#-#");
Excuse the messiness. It isn't quite finished yet.
[ad_2]
لینک منبع