프로그래밍/콘솔프로젝트
공 벽 튕기기
SUGI_
2023. 7. 11. 11:20
namespace BrickGame
{
public class INFO
{
//좌표(멤버변수 m)
public int m_nX;
public int m_nY;
}
}
namespace BrickGame
{
public class Ball
{
//좌표
private INFO tInfo = new INFO();
bool cheak = false;
int num = 0;
int newX = 0;
int newY = 0;
public void Initialize() //초기화 해주는 함수 start
{
tInfo.m_nX = 0; //좌표 0,0
tInfo.m_nY = 0;
}
public void Progress() //움직임관련 등등 함수 update
{
if (tInfo.m_nX >= 79)
{
newX = -1;
}
else if(tInfo.m_nX <= 0)
{
newX = 1;
}
if (tInfo.m_nY >= 24)
{
newY = -1;
}
else if (tInfo.m_nY <= 0)
{
newY = 1;
}
tInfo.m_nX += 1 * newX;
tInfo.m_nY += 1 * newY;
}
public void Render() //그려주는 함수
{
Console.Clear();
gotoxy(tInfo.m_nX, tInfo.m_nY);
//색바꾸기
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("●");
Console.ResetColor();
}
public void Release() //정리할게 있으면 사용할 함수
{
}
public void gotoxy(int x, int y) //좌표함수
{
Console.SetCursorPosition(x, y);
}
}
}
namespace BrickGame
{
internal class GameManager
{
Ball pBall = null;
public void Initialize()
{
pBall = new Ball();//객체생성
pBall.Initialize();
}
public void Progress()
{
pBall.Progress();
}
public void Render()
{
pBall.Render();
}
public void Release()
{
pBall.Release();
}
}
}
namespace BrickGame
{
public class Program
{
static void Main(string[] args)
{
GameManager gm = new GameManager(); //객체 생성
int Current = Environment.TickCount; //현재시간
gm.Initialize();
while (true)
{
if (Current + 100 < Environment.TickCount)
{
Current = Environment.TickCount;
gm.Progress();
gm.Render();
}
gm.Release();
}
}
}
}
[C# 문법] C# 콘솔창 텍스트 색상(컬러) 입히는 방법
안녕하세요. 오늘은 C# 에서 콘솔창에서 내용을 출력할 때 출력 텍스트에 색상을 입혀서 각기 다른 색상으로 출력되는 방법에 대해서 알려 드리려고 합니다. 보통은 어떤 표식 혹은 로그를 기록
afsdzvcx123.tistory.com
728x90