void main()
{
	int Key;

	ScreenInit();
	Init();

	while (1)
	{
		if (_kbhit())
		{
			Key = _getch();

			if (Key == 'q' || Key=='Q')
				break;

			if (Key == SPACE)
			{
				//게임 시작 / 일시정지 
				switch (GameStatus)
				{
				case START:
					GameStatus = INIT;
					break;

				case RUNNING:
					GameStatus = STOP;
					break;

				case GO:
					GameStatus = RUNNING;
					break;

				case STOP:
					GameStatus = RUNNING;
					break;
				}
			}

			if (GameStatus != GO && GameStatus != STOP)
				KeyControl(Key);

		}

		Update();
		Render();

	}

	Release();
	ScreenRelease();
}
Exemplo n.º 2
0
Print::~Print()
{
	ScreenRelease();
}
int main (void){

	int Key, Remain;
	clock_t CurTime, OldTime;

	ScreenInit();
	Init(); // 초기화
	
	while( 1 ) //무한반복 
	{
		if(_kbhit())
		{
			Key = _getch();
			if(Key == 'q')
				break;
			switch(Key)
			{
				case LEFT :
					if(Player.MoveX > 0){
					Player.MoveX--; 
					Remain =  Length - (Player.CenterX); // 남은길이 = 전체 길이 - (중심좌표 + 1)
					if(Player.MoveX + Remain > 79 || Player.MoveX - Player.CenterX - 1 < 0)
						Player.MoveX--;
					Player.X = Player.MoveX - Player.CenterX;
					}
					break;
				case RIGHT :
					if(Player.MoveX + 1< 79){
					Player.MoveX++;
					Remain = Length - (Player.CenterX);
					if(Player.MoveX + Remain >79 || Player.MoveX - Player.CenterX < 0)
						Player.MoveX++;
					Player.X = Player.MoveX - Player.CenterX;
					}
					break;
				case SPACE :
					if(Ball.ReadyB)
					{
						Ball.bMoveX = Player.MoveX;
						Ball.bMoveY = Player.MoveY - 1;
						Ball.OldTime = clock();
						Ball.ReadyB = 0;
					}
					break;	
			}
		}
		
		Update();//데이터 갱신 
		Render(); //화면 출력 
		
		OldTime = clock();

		while (1)
		{
			CurTime = clock();
			if (CurTime - OldTime > 20)
			{
				OldTime = CurTime;
				break;
			}
		}//대기시간
	 } 
	 
	 Release();
	 ScreenRelease();
	 return 0;
}