예제 #1
0
void Player::Update()
{
	elapsedTime++;

	switch (state)
	{
	case ePlayerState_Start: Update_Start();	break;
	case ePlayerState_Game: Update_Game();		break;
	case ePlayerState_Dead: Update_Dead();		break;
	default:	printfDx("Player.cpp:ERROR\n");	break;
	}

	// staticメンバ変数に値をコピー(アホ)
	CopyStaticMem();

	isHit = false;

	// TEST------------------------------------------------------------------------------------
	if (DebugMode::isTest == false)	return;

	/*
	if (Keyboard_Get(KEY_INPUT_P) == 1)	{
		Shift(true);		// シフトアップ
	}
	if (Keyboard_Get(KEY_INPUT_O) == 1) {
		Shift(false);
	}
	*/
}
예제 #2
0
void main()
{
    Start_TP();
    Initialize_Game();

    while (1)
    {
        Check_TP();
        Update_Game();
    }
}
예제 #3
0
파일: Game.cpp 프로젝트: KirSlayk/Game
void Game::Run_Game()
{
	srand(time(NULL));
	sf::Clock clock;
	sf::Time timeSinceLastUpdate = sf::Time::Zero;
	int timeForEneMies = 0;
	int numOfEnemy = 1;
	
	
	while (mWindow.isOpen())
	{
		if ( timeForEneMies  && timeForEneMies % 100 < 30 || eneMies.size() == 1 || !eneMies.size() )
		{
			numOfEnemy++;
			numOfEnemy = timeForEneMies% 4;
			if (!eneMies.size())
				numOfEnemy = 3;	
			if (eneMies.size() < 5 ){
				int size = eneMies.size();
				for ( int i = size; i < size + numOfEnemy - 1; i++ )
					eneMies.push_back(new Enemy());
				}
		}

		ProcessEvents_Game();
		timeSinceLastUpdate += clock.restart();
		while (timeSinceLastUpdate > TimePerFrame)
		{
			timeSinceLastUpdate -= TimePerFrame;
			ProcessEvents_Game();
			Update_Game();
		}
		
		bulLet.shrink_to_fit();
		
		Shoting_Game();
		
		if ( eneMies.size() )
			for ( int i = 0; i < (int) eneMies.size(); i++)
			if ( abs( plaYer.ReturnSprite()->getPosition().x - eneMies[i]->ReturnSprite()->getPosition().x < 10 ) ){
				Collision_Game();
				break;
			}
		
		BorderCheck_Game();	
		timeForEneMies += clock.getElapsedTime().asMilliseconds()/5;
		Render_Game();
		
	}
}
예제 #4
0
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
	timeBeginPeriod(1);

	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

 	// TODO: 여기에 코드를 입력합니다.
	MSG msg;
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);

	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc = WndProc;
	wcex.cbClsExtra = 0;
	wcex.cbWndExtra = 0;
	wcex.hInstance = hInstance;
	wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TCPFIGHTER));
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
	wcex.lpszMenuName = MAKEINTRESOURCE(IDC_TCPFIGHTER);
	wcex.lpszClassName = L"TCPFighter";
	wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
	RegisterClassEx(&wcex);

	hInst = hInstance; // 인스턴스 핸들을 전역 변수에 저장합니다.

	g_hWnd = CreateWindow(L"TCPFighter", L"TCPFighter", WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL);

	if (!g_hWnd)
	{
		return FALSE;
	}

	ShowWindow(g_hWnd, nCmdShow);
	UpdateWindow(g_hWnd);

	////////////////////////////////////////////////////////////////////////////////
	// 게임, 네트워크 초기화
	////////////////////////////////////////////////////////////////////////////////
	InitialGame();
	InitialNetwork(&client_sock, &g_hWnd);

	///////////////////////////////////////////////////////////////////////////////////////////////////////////
	// 윈도우 사이즈 맞추기
	///////////////////////////////////////////////////////////////////////////////////////////////////////////
	SetFocus(g_hWnd);

	RECT WindowRect;
	WindowRect.top = 0;
	WindowRect.left = 0;
	WindowRect.right = 640;
	WindowRect.bottom = 480;

	AdjustWindowRectEx(&WindowRect, GetWindowStyle(g_hWnd), GetMenu(g_hWnd) != NULL, GetWindowExStyle(g_hWnd));

	int iX = (GetSystemMetrics(SM_CXSCREEN) - 640) / 2;
	int iY = (GetSystemMetrics(SM_CYSCREEN) - 480) / 2;

	MoveWindow(g_hWnd, iX, iY, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, TRUE);
	///////////////////////////////////////////////////////////////////////////////////////////////////////////

	// 기본 메시지 루프입니다.
	while (1)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT)
				break;

			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		else
		{
			Update_Game();
		}
	}

	return (int) msg.wParam;
}