C#/수업내용

2020.04.07. 수업내용 - while 문 4 (애니메이션 2)

dev_sr 2020. 4. 7. 22:44

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
            //5. while - 애니메이션 실행 2
 
            Console.Write("애니메이션 이름:   ");
            string aniName=Console.ReadLine();
 
            Console.Write("\n {0} 애니메이션의 total frame은 몇입니까?  ", aniName);
            var totalFrame = Int32.Parse(Console.ReadLine());
 
            Console.Write("\n {0} 애니메이션의 타격 frame은 몇입니까?  ", aniName);
            var attackFrame = Int32.Parse(Console.ReadLine());
 
            Console.Write("\n {0} 애니메이션의 타격 프레임 때 쓸 이펙트 효과는?  ", aniName);
            string effect = Console.ReadLine();
 
            Console.Write("\n 애니메이션을 실행하시려면 Play를 입력하세요.  ");
            string playOrder = Console.ReadLine();
 
 
            //total frame 입력 받은 만큼 반복시키기
            //증가하는 현재 프레임(count) 만들기
 
            int currentFrame = 0;
 
            while (true)
            {
                //현재 프레임 증가시키기
                currentFrame++;
 
                //현재 프레임이 토탈 프레임보다 커지면 종료하기
                if(currentFrame>totalFrame)
                {
                    Console.WriteLine("\n {0} 애니메이션 플레이를 완료했습니다.", aniName);
                    break;
                }
 
                //타격 프레임이랑 같아지면 효과음 실행
                if(currentFrame==attackFrame)
                {
                    Console.WriteLine("\n"+effect);
                }
 
                //아니면 현재 프레임 출력
                else
                {
                    Console.WriteLine("\n {0} {1} frame", aniName, currentFrame);
                }
                
            }
 
 

 

결과값