当前位置: 首页>>代码示例>>C++>>正文


C++ Keyboard::GetKeyState方法代码示例

本文整理汇总了C++中Keyboard::GetKeyState方法的典型用法代码示例。如果您正苦于以下问题:C++ Keyboard::GetKeyState方法的具体用法?C++ Keyboard::GetKeyState怎么用?C++ Keyboard::GetKeyState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Keyboard的用法示例。


在下文中一共展示了Keyboard::GetKeyState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Update

void PostPlayScreen::Update(float DeltaTime)
{
	Controller*	tC	=	InputManager::GetInstance()->GetController(0);
	Keyboard*	tK	=	InputManager::GetInstance()->GetKeyboard();

	bool	UP		=	tC->GetButtonState( D_UP ) == PRESSED		|| tK->GetKeyState( VK_UP ) == PRESSED		|| tK->GetKeyState( 'W' ) == PRESSED;
	bool	DOWN	=	tC->GetButtonState( D_DOWN ) == PRESSED		|| tK->GetKeyState( VK_DOWN ) == PRESSED	|| tK->GetKeyState( 'S' ) == PRESSED;
	bool	CONFIRM	=	tC->GetButtonState( A ) == PRESSED			|| tK->GetKeyState( VK_RETURN ) == PRESSED;
	bool	BACK	=	tC->GetButtonState( B ) == PRESSED			|| tK->GetKeyState( VK_ESCAPE ) == PRESSED;

	if( CONFIRM )
	{
		gGotoNextFrame	=	MAIN_MENU_SCREEN;
		gScreenData->PLAYER_SCORE_LIST.clear();
	}
}
开发者ID:CarlRapp,项目名称:CodenameGamma,代码行数:16,代码来源:PostPlayScreen.cpp

示例2: Update

//-----------------------------------------------------------------------------
// Game::Update()
//      Called once per frame, update data, tranformations, etc
//      Use this function to control process order
//      Input, AI, Physics, Animation, and Graphics
//-----------------------------------------------------------------------------
void Game::Update()
{
	// Grabs the current time
	Time_Engine time = timer->toc();
	float curTime = Time_Engine::quotientFloat(time, Time_Engine(TIME_ONE_MILLISECOND)) /1000;

	// Update cameras - make sure everything is consistent
	pCam2D->updateCamera();

	// Add your update below this line: ----------------------------

	//KeyboardTest();
	//MouseTest();

	// Updates the Physics system
	World::Update();

	
	GameManager::Update(curTime);

	
	Mouse * mouse = Mouse::GetInstance();
	Keyboard *key = Keyboard::GetInstance();

	if (key->GetKeyState(AZUL_KEY::KEY_W))
	{
		Bot * bot = GameManager::getBot(playerBot->getBotID());

		Vect dir = bot->getPos() + Vect(0.0f, 1.0f, 0.0f);

		bot->MoveToPosition(dir);

	}

	if (key->GetKeyState(AZUL_KEY::KEY_D))
	{
		Bot * bot = GameManager::getBot(playerBot->getBotID());

		Vect dir = bot->getPos() + Vect(1.0f, 0.0f, 0.0f);

		bot->MoveToPosition(dir);

	}

	if (key->GetKeyState(AZUL_KEY::KEY_A))
	{
		Bot * bot = GameManager::getBot(playerBot->getBotID());

		Vect dir = bot->getPos() + Vect(-1.0f, 0.0f, 0.0f);

		bot->MoveToPosition(dir);

	}
	if (key->GetKeyState(AZUL_KEY::KEY_S))
	{
		Bot * bot = GameManager::getBot(playerBot->getBotID());

		Vect dir = bot->getPos() + Vect(0.0f, -1.0f, 0.0f);

		bot->MoveToPosition(dir);

	}

	if (key->GetKeyState(AZUL_KEY::KEY_J))
	{
		Bot * bot = GameManager::getBot(playerBot->getBotID());

		angle += 2.0f;

		bot->RotateToAngle(angle);
	}
	if (key->GetKeyState(AZUL_KEY::KEY_K))
	{
		Bot * bot = GameManager::getBot(playerBot->getBotID());

		angle += -2.0f;

		bot->RotateToAngle(angle);
	}

	if (key->GetKeyState(AZUL_KEY::KEY_R))
	{
	//	search2 = true;
	}

	if (key->GetKeyState(AZUL_KEY::KEY_SPACE))
	{
		Bot * bot = GameManager::getBot(playerBot->getBotID());

 		if (bot->getRifleAmmo() > 0)
		{
 			bot->Fire(LASER);
		}
		else
//.........这里部分代码省略.........
开发者ID:geeosp,项目名称:IAProject,代码行数:101,代码来源:Game.cpp


注:本文中的Keyboard::GetKeyState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。