Exemplo n.º 1
0
void DemoApp::keyHandler()
{		
	unsigned int ball = GameEngine::entityWorldID("Ball");
	if( m_keys[118] )  // F7
	{
		h3dSetOption( H3DOptions::DebugViewMode, h3dGetOption(H3DOptions::DebugViewMode) != 0 ? 0 : 1 );	
		m_keys[118] = 0;
	}
	if( m_keys['W'] ) 
		GameEngine::translateEntityLocal(m_camID, 0, 0, -1);
	if( m_keys['S'] ) 
		GameEngine::translateEntityLocal(m_camID, 0, 0, 1);
	if( m_keys['A'] )
		GameEngine::translateEntityLocal(m_camID, -1, 0, 0);
	if( m_keys['D'] )
		GameEngine::translateEntityLocal(m_camID, 1, 0, 0);
	if( m_keys['I'] )
		GameEngine::translateEntityLocal( ball, 0, 0, 1 );
	if( m_keys['K'] )
		GameEngine::translateEntityLocal( ball, 0, 0, -1 );
	if( m_keys['J'] )
		GameEngine::translateEntityLocal( ball, -1, 0, 0 );
	if( m_keys['L'] )
		GameEngine::translateEntityLocal( ball, 1, 0, 0 );

	m_running = m_keys[27] == 0;
}
Exemplo n.º 2
0
void DemoApp::keyHandler()
{
	unsigned int ball = GameEngine::entityWorldID("Ball");
	float fps = GameEngine::FPS();

	if( m_keys[GLFW_KEY_F7] )
	{
		h3dSetOption( H3DOptions::DebugViewMode, h3dGetOption(H3DOptions::DebugViewMode) != 0 ? 0 : 1.0f );
		m_keys[GLFW_KEY_F7] = 0; // reset key state so we only change it once
	}
	if( m_keys[GLFW_KEY_F6] )
	{
		GameEngine::setPhysicsShapeRenderingEnabled(!GameEngine::physicsShapeRenderingEnabled());
		m_keys[GLFW_KEY_F6] = 0; // reset key state so we only change it once
	}
	if( m_keys['R'])
	{
		GameEngine::resetPhysics();
		m_keys['R'] = 0; // reset key state so we only change it once
	}

	if( m_keys['W'] )
		GameEngine::translateEntityLocal(m_camID, 0, 0, -10 / fps);
	if( m_keys['S'] )
		GameEngine::translateEntityLocal(m_camID, 0, 0, 10 / fps);
	if( m_keys['A'] )
		GameEngine::translateEntityLocal(m_camID, -10 / fps, 0, 0);
	if( m_keys['D'] )
		GameEngine::translateEntityLocal(m_camID, 10 / fps, 0, 0);

	if( m_keys['I'] )
		GameEngine::translateEntityGlobal( ball, 0, 0, -10 / fps );
	if( m_keys['K'] )
		GameEngine::translateEntityGlobal( ball, 0, 0, 10 / fps );
	if( m_keys['J'] )
		GameEngine::translateEntityGlobal( ball, -10 / fps, 0, 0 );
	if( m_keys['L'] )
		GameEngine::translateEntityGlobal( ball, 10 / fps, 0, 0 );
	if( m_keys['U'] )
		GameEngine::translateEntityGlobal( ball, 0, 10 / fps, 0 );
	if( m_keys['O'] )
		GameEngine::translateEntityGlobal( ball, 0, -10 / fps, 0 );

	m_running = m_keys[27] == 0;
}