I'm in class and our teacher is making us create a basic framework for what would be a snake game, I'm just going for the function that the frame should paint, but I have a certain problem, and that is that the right side, it is painted right next to the left, instead of being painted like a frame ... Let's see if anyone can help me, this is what I have:
static void pintaMarc()
{
//caracteres marc 186 ║, 187 ╗, 188 ╝, 200 ╚, 201 ╔, 205 ═
int alçada = Console.WindowHeight - 10, amplada = Console.WindowWidth - 30;
Console.Write('╔');
for (int i = 0; i < amplada; i++)
{
Console.Write('═');
}
Console.Write('╗');
for (int x = 0; x < alçada; x++)
{
Console.Write('\n');
for (int y = 0; y < amplada; y++)
{
if (y == 0)
{
Console.Write('║');
}
if (y == amplada - 1)
{
Console.Write('║');
}
}
}
Console.Write('\n');
Console.Write('╚');
for (int x = 0; x < amplada; x++)
{
Console.Write('═');
}
Console.WriteLine('╝');
}
Thank you very much in advance!
Attachment captures how it is executed:
Well, at the end I did it with the console.setcursorposition function:
Console.SetCursorPosition(1, 1);
Console.WriteLine("╔");
Console.SetCursorPosition(1, 30);
Console.WriteLine("╚");
Console.SetCursorPosition(100, 1);
Console.WriteLine("╗");
Console.SetCursorPosition(100, 30);
Console.WriteLine("╝");
for (int y = 2; y < 100; y++)
{
int x = 1;
Console.SetCursorPosition(y, x);
Console.WriteLine("═");
}
for (int x = 2; x < 30; x++)
{
int y = 1;
Console.SetCursorPosition(y, x);
Console.WriteLine("║");
y = 100;
Console.SetCursorPosition(y, x);
Console.WriteLine("║");
}
for (int y = 2; y < 100; y++)
{
int x = 30;
Console.SetCursorPosition(y, x);
Console.WriteLine("═");
}
So that in the second for, the vertical bars, are placed parallel, at the distance you assign.