Misc/오늘 알아낸 것
내일배움캠프 12일차 TIL - Console.SetCursorPosition으로 UI 찍어내기
Potatopotatopotato
2023. 8. 19. 21:53

저번에 뱀 게임에서 배웠던 메서드를 사용해서 오른쪽과 화면 하단에 UI 틀을 찍어봤다
안에 들어갈 내용도 똑같은 메서드를 사용해서 찍어내면 될거같다
해당 UI 틀 시작할 기준 값은 상수로 받아놨으니 거길 기준으로 차례대로 찍어내면 된다
글자들은 10 크기를 가진 char 배열로 만들고 10을 넘어가면 다음줄에 출력할 생각이다
코드는 좀 더럽지만 간단하게 작성했다
별찍기 느낌으로..
const char lt = '┌';
const char rt = '┐';
const char lb = '└';
const char rb = '┘';
const char tb = '─';
const char s = '│';
public static void RenderRightUI()
{
Console.SetCursorPosition(Define.UI_RIGHT_PIVOT, 0);
Console.Write(lt);
for (int i = 1; i < Define.UI_RIGHT_WIDTH - 1; i++)
{
Console.Write(tb);
}
Console.WriteLine(rt);
for (int i = 1; i < Define.UI_RIGHT_HEIGHT - 1; i++)
{
Console.SetCursorPosition(Define.UI_RIGHT_PIVOT, i);
Console.Write(s);
for (int j = 1; j < Define.UI_RIGHT_WIDTH - 1; j++)
{
Console.Write(' ');
}
Console.WriteLine(s);
}
Console.SetCursorPosition(Define.UI_RIGHT_PIVOT, Define.UI_RIGHT_HEIGHT - 1);
Console.Write(lb);
for (int i = 1; i < Define.UI_RIGHT_WIDTH - 1; i++)
{
Console.Write(tb);
}
Console.WriteLine(rb);
}