코딩의 신 9

김동관·2025년 10월 2일

게임 시작 문구, 캐릭터 정보, 상태보기

internal class Program
{
 static int level = 1;
 static string name = "호날두";
 static string job = "축구선수";
 static int attack = 90;
     static void Main(string[] args)
 {
     StartIntro();
 }
     static void StartIntro()
 {
     while (true)
     {
         Console.Clear();
         string intro = @"
 캄프누에 오신것을 환영합니다.
 이곳에서 경기장으로 들어가기 몸을 풀 수 있습니다.
     
 1.상태보기
 2.인벤토리

 원하시는 행동을 입력해주세요.
 >> ";
             //ReadLine으로 반환 받으면 string이니 유의. 
         Console.Write(intro);
         string input = Console.ReadLine() ?? "";
         switch (input)
         {
             case "1":
                 status();
                 break;
//나중에는 case를 더 만들어 다른것도 추가 하면 됨.
//Console.Clear();는 앞에 달아서 항상 앞에 지문이 사라지도록 깔끔하게 함.
   static void status()
 {
     while (true)
     {
         Console.Clear();
         Console.WriteLine($"레벨: {축구력}");
         Console.WriteLine($"이름: {name}");

처음에는 static으로 변수를 여러개 만들어줌. 그 뒤 따로 StartIntro를 따로 만들어 관리.다른곳에서도 접근 가능하게 만듦. (while(true))를 만들어 반복문으로 만들기.
Console.ReadLine()과 string input으로 값을 받아와 만약 1번을 누르면 어떤 변수가 뜰지 case문을 만들어 추가해줌.
예를 들어 1번을 누르면 break로 탈출을 하며 다른 화면으로 넘어가게 전환을 함.

profile
아이디어 뱅크

0개의 댓글