09.20 for문을 이용한 던전게임2 (글자색 추가)
카테고리 없음 2019. 9. 20. 11:50기존의 던전게임에서 문자에 색상을 추가함
예제:
코드:
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _09._20
{
class Program
{
static void Main(string[] args)
{
Console.Write("케릭터의 이름을 입력해주세요: ");
string characterName = Console.ReadLine();
Console.Write("직업을 설정해주세요: ");
string className = Console.ReadLine();
Console.Write("체력을 설정해주세요: ");
string strmaxHp = Console.ReadLine();
int maxHp = Convert.ToInt32(strmaxHp);
Console.Write("공격력을 설정해주세요: ");
string strdmg = Console.ReadLine();
int heroDamage = Convert.ToInt32(strdmg);
float monsterDamage = 3.5f;
float hp = maxHp;//현재 체력
Console.WriteLine("----------------------");
Console.WriteLine($"이름: {characterName}");
Console.WriteLine($"직업: {className}");
Console.WriteLine($"체력: {hp}/{maxHp}");
Console.WriteLine($"공격력: {heroDamage}");
Console.WriteLine("----------------------");
Console.WriteLine("던전으로 들어갔습니다.");
for (int i =1; i<5; i++)
{
Console.Write($"몬스터에게 공격(-{monsterDamage})을 받았습니다.");
Console.ResetColor();
Console.WriteLine($"({hp = hp - monsterDamage}/{maxHp})");
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|