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


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

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


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

示例1: frameStarted

	bool frameStarted(const Ogre::FrameEvent& evt){
		_key->capture();
		_mouse->capture();
		
		float movSpeed = 500.0f;


		if (_key->isKeyDown(OIS::KC_ESCAPE))
			return false;

		Ogre::Vector3 t(0,0,0);

		if (_key->isKeyDown(OIS::KC_W))
			t += Ogre::Vector3(0,0,-10);

		if (_key->isKeyDown(OIS::KC_S))
			t += Ogre::Vector3(0,0,10);

		if (_key->isKeyDown(OIS::KC_A))
			t += Ogre::Vector3(-10,0,0);

		if (_key->isKeyDown(OIS::KC_D))
			t += Ogre::Vector3(10,0,0);

		_cam->moveRelative(t*evt.timeSinceLastFrame*movSpeed);
		float rotX = _mouse->getMouseState().X.rel * evt.timeSinceLastFrame* -1;
		float rotY = _mouse->getMouseState().Y.rel * evt.timeSinceLastFrame * -1;
		_cam->yaw(Ogre::Radian(rotX));
		_cam->pitch(Ogre::Radian(rotY));
		

		return true;
	}
开发者ID:luiscarlo6,项目名称:Computacion-Grafica-USB,代码行数:33,代码来源:OgreSemana10.cpp

示例2: OnUpdate

void SimplePlayerComponent::OnUpdate(double time_diff) {
    OIS::Keyboard* k = InputManager::Get()->GetKeyboard();

    if(mWASDEnabled || mArrowsEnabled) {
        Ogre::Vector3 move(Ogre::Vector3::ZERO);

        if((mWASDEnabled && k->isKeyDown(OIS::KC_W)) || (mArrowsEnabled && k->isKeyDown(OIS::KC_UP))) {
            move.z -= 1.0;
        }
        if((mWASDEnabled && k->isKeyDown(OIS::KC_S)) || (mArrowsEnabled && k->isKeyDown(OIS::KC_DOWN))) {
            move.z += 1.0;
        }
        if((mWASDEnabled && k->isKeyDown(OIS::KC_A)) || (mArrowsEnabled && k->isKeyDown(OIS::KC_LEFT))) {
            move.x -= 1.0;
        }
        if((mWASDEnabled && k->isKeyDown(OIS::KC_D)) || (mArrowsEnabled && k->isKeyDown(OIS::KC_RIGHT))) {
            move.x += 1.0;
        }

        if(move.length() > 0) {
            move.normalise(); // do not move too fast :P

            move = GetNode()->GetRotation() * move;
            GetNode()->SetPosition(GetNode()->GetPosition() + move * time_diff * mMoveSpeed);
        }
    }

}
开发者ID:LMG,项目名称:ducttape-engine,代码行数:28,代码来源:SimplePlayerComponent.cpp

示例3: frameStarted

	bool frameStarted(const Ogre::FrameEvent& evt)
	{
		if (mExit)
			return false;
		if (mWindow->isClosed())
			return false;

		mKeyboard->capture();
		mMouse->capture();

		if (mKeyboard->isKeyDown(OIS::KC_A) || mKeyboard->isKeyDown(OIS::KC_LEFT))
			mCamera->moveRelative(Ogre::Vector3(-evt.timeSinceLastFrame*20, 0, 0));

		if (mKeyboard->isKeyDown(OIS::KC_D) || mKeyboard->isKeyDown(OIS::KC_RIGHT))
			mCamera->moveRelative(Ogre::Vector3(evt.timeSinceLastFrame*20, 0, 0));

		if (mKeyboard->isKeyDown(OIS::KC_W) || mKeyboard->isKeyDown(OIS::KC_UP))
			mCamera->moveRelative(Ogre::Vector3(0, 0, -evt.timeSinceLastFrame*20));

		if (mKeyboard->isKeyDown(OIS::KC_S) || mKeyboard->isKeyDown(OIS::KC_DOWN))
			mCamera->moveRelative(Ogre::Vector3(0, 0, evt.timeSinceLastFrame*20));

		mGUI->injectFrameEntered(evt.timeSinceLastFrame);

		return true;
	}
开发者ID:ItzFluffy,项目名称:csclone,代码行数:26,代码来源:editor.cpp

示例4: processInputs

bool OgreARAppLogic::processInputs(Ogre::Real deltaTime)
{
	OIS::Keyboard *keyboard = mApplication->getKeyboard();
	if(keyboard->isKeyDown(OIS::KC_ESCAPE))
	{
		return false;
	}
	if(keyboard->isKeyDown(OIS::KC_SPACE))
	{
		pause = !pause;

	}
	return true;
}
开发者ID:Dymanik,项目名称:anarcards,代码行数:14,代码来源:OgreARAppLogic.cpp

示例5: NewImGuiFrame

void GUIManager::NewImGuiFrame(float dt)
{
    // Update screen size
    int left, top, width, height;
    gEnv->mainCamera->getViewport()->getActualDimensions(left, top, width, height); // output params

     // Read keyboard modifiers inputs
    OIS::Keyboard* kb = App::GetInputEngine()->GetOisKeyboard();
    bool ctrl  = kb->isKeyDown(OIS::KC_LCONTROL);
    bool shift = kb->isKeyDown(OIS::KC_LSHIFT);
    bool alt   = kb->isKeyDown(OIS::KC_LMENU);

    // Call IMGUI
    m_imgui.NewFrame(dt, static_cast<float>(width), static_cast<float>(height), ctrl, alt, shift);
}
开发者ID:monwarez,项目名称:rigs-of-rods,代码行数:15,代码来源:GUIManager.cpp

示例6: handleInput

void PendulumTest::handleInput(opal::real elapsedRealTime, 
	const SimulationEngine& engine)
{
	OIS::Keyboard* keyboard = engine.getKeyboard();

	// This variable can be used to keep keys from repeating too fast.
	static Ogre::Real toggleTimer = 0;
	if (toggleTimer >= 0)
	{
		toggleTimer -= elapsedRealTime;
	}

	// Toggle GUI.
	if (keyboard->isKeyDown(OIS::KC_G) && toggleTimer <= 0)
	{
		Ogre::Overlay* debugOverlay = Ogre::OverlayManager::getSingleton().
			getByName("Verve/TrialNumber");

		if (debugOverlay->isVisible())
        {
			debugOverlay->hide();
			mAgentDebugger->setDisplayEnabled(false);
		}
		else
		{
			debugOverlay->show();
			mAgentDebugger->setDisplayEnabled(true);
		}

		toggleTimer = 0.5;
	}
}
开发者ID:sub77,项目名称:hobbycode,代码行数:32,代码来源:PendulumTest.cpp

示例7: frameStarted

  bool frameStarted(const FrameEvent &evt)
  {
    // Fill Here ----------------------------------------------
	  if (mKeyboard->isKeyDown(OIS::KC_1))
		  mProfessorNode->setScale(1.0f, 1.0f, 1.0f);
	  else if (mKeyboard->isKeyDown(OIS::KC_2))
		  mProfessorNode->setScale(2.0f, 1.0f, 1.0f);
	  else if (mKeyboard->isKeyDown(OIS::KC_3))
		  mProfessorNode->setScale(3.0f, 1.0f, 1.0f);
	  else if (mKeyboard->isKeyDown(OIS::KC_E))
		  mProfessorNode->scale(1.01f, 1.0f, 1.0f);
	  else if (mKeyboard->isKeyDown(OIS::KC_I))
		  // 닌자 노드의 상속 노드를 설정
		  mNinjaNode->setInheritScale(!mNinjaNode->getInheritScale());
    // --------------------------------------------------------
    return true;
  }
开发者ID:jonghyunChae,项目名称:2016OgrePractice,代码行数:17,代码来源:main.cpp

示例8: work

ret_code RTSState::work(const TimeDuration &elapsed)
{
    injectCameraEvents();
    OIS::Keyboard *keys = OgreContextManager::get()->getInputManager()->getKeyboard();
    if (keys->isKeyDown(OIS::KeyCode::KC_F))
    {
        const TypeUnite *type = nullptr;
        if (m_selectedUnitsCommands.availableBuilds().size() > 0)
        {
            type = *m_selectedUnitsCommands.availableBuilds().begin();
            if(type != nullptr)
            m_selectedUnitsCommands.addBuild(type, 1);
        }
    }
    return ret_code::CONTINUE;
}
开发者ID:xabufr,项目名称:meteor-falls,代码行数:16,代码来源:RTSState.cpp

示例9: getInput

void GameState::getInput() {
if(!isPaused){
  OIS::Keyboard* keyboard = OgreFramework::getSingletonPtr()->m_pKeyboard;

  if (keyboard->isKeyDown(OIS::KC_Q)) {
    physics->rotate(0, Ogre::Degree(3).valueRadians());
  }
  if (keyboard->isKeyDown(OIS::KC_E)) {
    physics->rotate(0, Ogre::Degree(-3).valueRadians());
  }
  Ogre::Vector3 dir = PenguinNode->getOrientation() * Ogre::Vector3::UNIT_Z;
  if (keyboard->isKeyDown(OIS::KC_W) || keyboard->isKeyDown(OIS::KC_UP)) {
    physics->translate(0, 5.0f * dir[0], 0.0f, 5.0f * dir[2]);
  }
  if (keyboard->isKeyDown(OIS::KC_S) || keyboard->isKeyDown(OIS::KC_DOWN)) {
    physics->translate(0, -5.0f * dir[0], 0.0f, -5.0f * dir[2]);
  }
  if (keyboard->isKeyDown(OIS::KC_A) || keyboard->isKeyDown(OIS::KC_LEFT)) {
    physics->translate(0, 5.0f * dir[2], 0.0f, -5.0f * dir[0]);
  }
  if (keyboard->isKeyDown(OIS::KC_D) || keyboard->isKeyDown(OIS::KC_RIGHT)) {
    physics->translate(0, -5.0f * dir[2], 0.0f, 5.0f * dir[0]);
  }

  if (keyboard->isKeyDown(OIS::KC_SPACE)) {
    if(!graphics->getJumping() && physics->has_jumping()){
      physics->applyForce(0, 0, 14000, 0);
      graphics->playSound(0);
      graphics->setJumping(true);
    }
  }
}
}
开发者ID:klt592,项目名称:GTFinal,代码行数:33,代码来源:GameState.cpp

示例10: keyPressed

bool RenderState::keyPressed(const OIS::KeyEvent &keyEventRef)
{
        OgreFramework* framework = OgreFramework::getSingletonPtr();
        OIS::Keyboard* keyboard =  framework->_keyboard;
        OgreBites::SdkTrayManager* trayMgr = framework->_trayMgr;
        OgreBites::SelectMenu* pMenu = 
                (OgreBites::SelectMenu*)trayMgr->getWidget("DisplayModeSelMenu");

        if(_settingsMode == true)
        {
                if(keyboard->isKeyDown(OIS::KC_S))
                {
                        if(pMenu->getSelectionIndex() + 1 < (int)pMenu->getNumItems())
                                pMenu->selectItem(pMenu->getSelectionIndex() + 1);
                }

                if(keyboard->isKeyDown(OIS::KC_W))
                {
                        if(pMenu->getSelectionIndex() - 1 >= 0)
                                pMenu->selectItem(pMenu->getSelectionIndex() - 1);
                }

                if(keyboard->isKeyDown(OIS::KC_R))
                {
                        steps = 20;
                }
        }

        if(keyboard->isKeyDown(OIS::KC_ESCAPE))
        {
                // pushAppState(findByName("PauseState"));
                exit();
                return true;
        }

        if(keyboard->isKeyDown(OIS::KC_I))
        {
                if(_detailsPanel->getTrayLocation() == OgreBites::TL_NONE)
                {
                        framework->_trayMgr->moveWidgetToTray(_detailsPanel, 
                                                              OgreBites::TL_BOTTOMRIGHT, 
                                                              0);
                        _detailsPanel->show();
                }
                else
                {
                        framework->_trayMgr->removeWidgetFromTray(_detailsPanel);
                        _detailsPanel->hide();
                }
        }

        if(keyboard->isKeyDown(OIS::KC_TAB))
        {
                _settingsMode = !_settingsMode;
                return true;
        }

        if(_settingsMode && keyboard->isKeyDown(OIS::KC_RETURN) ||
           keyboard->isKeyDown(OIS::KC_NUMPADENTER))
        {
        }

        if(!_settingsMode || (_settingsMode && !keyboard->isKeyDown(OIS::KC_O)))
                framework->keyPressed(keyEventRef);

        return true;
}
开发者ID:rbaravalle,项目名称:breaddemo,代码行数:67,代码来源:RenderState.cpp

示例11: processInputs

bool OgreAppLogic::processInputs(Ogre::Real deltaTime)
{
	const Degree ROT_SCALE = Degree(40.0f);
	const Real MOVE_SCALE = 5.0f;
	Vector3 translateVector(Vector3::ZERO);
	Degree rotX(0);
	Degree rotY(0);
	OIS::Keyboard *keyboard = mApplication->getKeyboard();
	OIS::Mouse *mouse = mApplication->getMouse();

	if(keyboard->isKeyDown(OIS::KC_ESCAPE))
	{
		return false;
	}

	//////// moves  //////

	// keyboard moves
	if(keyboard->isKeyDown(OIS::KC_A))
		translateVector.x = -MOVE_SCALE;	// Move camera left

	if(keyboard->isKeyDown(OIS::KC_D))
		translateVector.x = +MOVE_SCALE;	// Move camera RIGHT

	if(keyboard->isKeyDown(OIS::KC_UP) || keyboard->isKeyDown(OIS::KC_W) )
		translateVector.z = -MOVE_SCALE;	// Move camera forward

	if(keyboard->isKeyDown(OIS::KC_DOWN) || keyboard->isKeyDown(OIS::KC_S) )
		translateVector.z = +MOVE_SCALE;	// Move camera backward

	if(keyboard->isKeyDown(OIS::KC_PGUP))
		translateVector.y = +MOVE_SCALE;	// Move camera up

	if(keyboard->isKeyDown(OIS::KC_PGDOWN))
		translateVector.y = -MOVE_SCALE;	// Move camera down

	if(keyboard->isKeyDown(OIS::KC_RIGHT))
		rotX -= ROT_SCALE;					// Turn camera right

	if(keyboard->isKeyDown(OIS::KC_LEFT))
		rotX += ROT_SCALE;					// Turn camea left

	rotX *= deltaTime;
	rotY *= deltaTime;
	translateVector *= deltaTime;

	// mouse moves
	const OIS::MouseState &ms = mouse->getMouseState();
	if (ms.buttonDown(OIS::MB_Right))
	{
		translateVector.x += ms.X.rel * 0.003f * MOVE_SCALE;	// Move camera horizontaly
		translateVector.y -= ms.Y.rel * 0.003f * MOVE_SCALE;	// Move camera verticaly
	}
	else
	{
		rotX += Degree(-ms.X.rel * 0.003f * ROT_SCALE);		// Rotate camera horizontaly
		rotY += Degree(-ms.Y.rel * 0.003f * ROT_SCALE);		// Rotate camera verticaly
	}	



	mCamera->moveRelative(translateVector);
	mCamera->yaw(rotX);
	mCamera->pitch(rotY);

	return true;
}
开发者ID:aufheben1,项目名称:visual-experiments,代码行数:67,代码来源:OgreAppLogic.cpp

示例12: processInput

void World::processInput()
{
	using namespace OIS;
	static Ogre::Timer timer;
	static unsigned long lastTime = 0;
	unsigned long currentTime = timer.getMilliseconds();

	//Calculate the amount of time passed since the last frame
	Real timeScale = (currentTime - lastTime) * 0.001f;
	if (timeScale < 0.001f)
		timeScale = 0.001f;
	lastTime = currentTime;

	//Get the current state of the keyboard and mouse
	keyboard->capture();
	mouse->capture();
	const OIS::MouseState &ms = mouse->getMouseState();

	//[NOTE] When the left mouse button is pressed, add trees
	if (ms.buttonDown(MB_Left)){
		//Choose a random tree rotation
		Degree yaw = Degree(Math::RangeRandom(0, 360));

		//Choose a random scale
		Real scale = Math::RangeRandom(0.5f, 0.6f);

		//Calculate a position
		Ogre::Vector3 centerPos = camera->getPosition() + (camera->getOrientation() * Ogre::Vector3(0, 0, -50));
		Radian rndAng = Radian(Math::RangeRandom(0, Math::TWO_PI));
		Real rndLen = Math::RangeRandom(0, 20);
		centerPos.x += Math::Sin(rndAng) * rndLen;
		centerPos.z += Math::Cos(rndAng) * rndLen;

		//And add the tree
		treeLoader->addTree(myTree, centerPos, yaw, scale);
		//[NOTE] Dynamic trees are very easy, as you can see. No additional setup is required for
		//the dynamic addition / removal of trees to work. Simply call addTree(), etc. as needed.
	}

	//[NOTE] When the right mouse button is pressed, delete trees
	if (ms.buttonDown(MB_Right)){
		//Calculate a position in front of the camera
		Ogre::Vector3 centerPos = camera->getPosition() + (camera->getOrientation() * Ogre::Vector3(0, 0, -50));

		//Delete trees within 20 units radius of the center position
		treeLoader->deleteTrees(centerPos, 20);
		//[NOTE] Dynamic trees are very easy, as you can see. No additional setup is required for
		//the dynamic addition / removal of trees to work. Simply call deleteTrees(), etc. as needed.
	}

	//Always exit if ESC is pressed
	if (keyboard->isKeyDown(KC_ESCAPE))
		running = false;

	//Reload the scene if R is pressed
	static bool reloadedLast = false;
	if (keyboard->isKeyDown(KC_R) && !reloadedLast){
		unload();
		load();
		reloadedLast = true;
	}
	else {
		reloadedLast = false;
	}

	//Update camera rotation based on the mouse
	camYaw += Radian(-ms.X.rel / 200.0f);
	camPitch += Radian(-ms.Y.rel / 200.0f);
	camera->setOrientation(Quaternion::IDENTITY);
	camera->pitch(camPitch);
	camera->yaw(camYaw);

	//Allow the camera to move around with the arrow/WASD keys
	Ogre::Vector3 trans(0, 0, 0);
	if (keyboard->isKeyDown(KC_UP) || keyboard->isKeyDown(KC_W))
		trans.z = -1;
	if (keyboard->isKeyDown(KC_DOWN) || keyboard->isKeyDown(KC_S))
		trans.z = 1;
	if (keyboard->isKeyDown(KC_RIGHT) || keyboard->isKeyDown(KC_D))
		trans.x = 1;
	if (keyboard->isKeyDown(KC_LEFT) || keyboard->isKeyDown(KC_A))
		trans.x = -1;
	if (keyboard->isKeyDown(KC_PGUP) || keyboard->isKeyDown(KC_E))
		trans.y = 1;
	if (keyboard->isKeyDown(KC_PGDOWN) || keyboard->isKeyDown(KC_Q))
		trans.y = -1;

	//Shift = speed boost
	if (keyboard->isKeyDown(KC_LSHIFT) || keyboard->isKeyDown(KC_RSHIFT))
		trans *= 2;

	trans *= 100;
	camera->moveRelative(trans * timeScale);

	//Make sure the camera doesn't go under the terrain
	Ogre::Vector3 camPos = camera->getPosition();
	float terrY = HeightFunction::getTerrainHeight(camPos.x, camPos.z);
	if (camPos.y < terrY + 5 || keyboard->isKeyDown(KC_SPACE)){		//Space = walk
		camPos.y = terrY + 5;
		camera->setPosition(camPos);
//.........这里部分代码省略.........
开发者ID:ghoulsblade,项目名称:vegaogre,代码行数:101,代码来源:Example5.cpp

示例13: WinMain


//.........这里部分代码省略.........

#if defined OIS_WIN32_PLATFORM
    paramList.insert(pair<string, string>("w32_mouse", "DISCL_FOREGROUND"));
    paramList.insert(pair<string, string>("w32_mouse", "DISCL_NONEXCLUSIVE"));
#elif defined OIS_LINUX_PLATFORM
    paramList.insert(pair<string, string>("x11_mouse_grab", "false"));
    paramList.insert(pair<string, string>("x11_mouse_hide", "false"));
#endif

    OIS::InputManager* inputManager = OIS::InputManager::createInputSystem(paramList);

    OIS::Keyboard* keyboard = static_cast<OIS::Keyboard*>(inputManager->createInputObject(OIS::OISKeyboard, false));
    OIS::Mouse* mouse = static_cast<OIS::Mouse*>(inputManager->createInputObject(OIS::OISMouse, false));

    const OIS::MouseState& ms = mouse->getMouseState();
    ms.width = window.GetWidth();
    ms.height = window.GetHeight();
#endif

    //Renderer::GetInstance()->SetRenderFillMode(RENDER_MODE_WIREFRAME);
    float splashForce = 0.1f;
    float damping = 0.999f;
    float maxHeight = 0.15f;

    while (window.IsOpen()) {
        WindowEvent windowEvent;
        if (window.PollEvents(windowEvent)) {
        }

        // Poll the mouse if OIS is present
#ifdef OIS_AVAILABLE
        keyboard->capture();

        if (keyboard->isKeyDown(OIS::KC_ESCAPE)) {
            break;
        }

        mouse->capture();

        // If we clicked on the surface, get the point on the water plane and send it to the shader
        // for it to compute the ripples

        if (mouse->getMouseState().buttonDown(OIS::MB_Left)) {
            Vector3 pos = Renderer::GetInstance()->ScreenToWorldPoint(Vector2((float)mouse->getMouseState().X.abs, (float)mouse->getMouseState().Y.abs));

            // Transform the position into the range [0, 1] so that we can map it as texture coordinates of the water plane
            // Because the water plane ranges from (-1, -1) to (1, 1), the transformation is trivial
            Vector2 point;
            point.y = pos.x / 2.0f + 0.5f;
            point.x = pos.y / 2.0f + 0.5f;

            if (point.x >= 0.0f && point.y >= 0.0f && point.x <= 1.0f && point.y <= 1.0f) {
                //waterShader->SetUniformVector2("disturbancePoint", pos.x, pos.y);
                /*
                size_t i = (size_t) min(maxf(point.x * NUM_VERTICES, 1), NUM_VERTICES - 1);
                size_t j = (size_t) minsf(maxf(point.y * NUM_VERTICES, 1), NUM_VERTICES - 1);
                size_t idx = i * NUM_VERTICES + j;

                buffer[idx].z = splashForce;
                buffer[idx + 1].z = splashForce;
                buffer[idx - 1].z = splashForce;
                buffer[(i + 1) * NUM_VERTICES + j].z = splashForce;
                buffer[(i - 1) * NUM_VERTICES + j].z = splashForce;
                buffer[(i + 1) * NUM_VERTICES + j + 1].z = splashForce;
                buffer[(i + 1) * NUM_VERTICES + j - 1].z = splashForce;
                buffer[(i - 1) * NUM_VERTICES + j + 1].z = splashForce;
开发者ID:gviau,项目名称:sketch-3d,代码行数:67,代码来源:Main.cpp

示例14: handleInput

void handleInput(Ogre::Real elapsedRealTime)
{
	// This variable can be used to keep keys from repeating too fast.
	static Ogre::Real toggleTimer = 0;
	if (toggleTimer >= 0)
	{
		toggleTimer -= elapsedRealTime;
	}

	OIS::Keyboard* keyboard = gEngine.getKeyboard();

	if (keyboard->isKeyDown(OIS::KC_W))
	{
		gCar->forward();
	}
	else if (keyboard->isKeyDown(OIS::KC_S))
	{
		gCar->reverse();
	}
	else
	{
		gCar->idle();
	}

	if (keyboard->isKeyDown(OIS::KC_A))
	{
		gCar->setSteering(-1);
	}
	else if (keyboard->isKeyDown(OIS::KC_D))
	{
		gCar->setSteering(1);
	}
	else
	{
		gCar->setSteering(0);
	}

	// If available, get data from the game controller.
	if (gGamePad)
	{
		// Update the game controller state.
		SDL_JoystickUpdate();

		Ogre::Real joy0X = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 0) / 
			(Ogre::Real)32768;
		Ogre::Real joy0Y = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 1) / 
			(Ogre::Real)32768;
		Ogre::Real joy1X = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 4) / 
			(Ogre::Real)32768;
		Ogre::Real joy1Y = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 3) / 
			(Ogre::Real)32768;

		if (fabs(joy0Y) > 0.1)
		{
			gCar->setThrottle(-joy0Y);
		}
		else
		{
			gCar->idle();
		}

		if (fabs(joy0X) > 0.1)
		{
			gCar->setSteering(joy0X);
		}
		else
		{
			gCar->setSteering(0);
		}

		if (joy1X > 0.2 || joy1X < -0.2)
		{
			Ogre::Degree rotAroundY = -Ogre::Degree(joy1X);
			gEngine.getCamera()->yawRelative(rotAroundY.valueDegrees());
		}

		if (joy1Y > 0.2 || joy1Y < -0.2)
		{
			Ogre::Degree rotAroundX = -Ogre::Degree(joy1Y);
			gEngine.getCamera()->pitchRelative(rotAroundX.valueDegrees());
		}
	}

	// Toggle GUI.
	if (keyboard->isKeyDown(OIS::KC_G) && toggleTimer <= 0)
	{
		Ogre::Overlay* debugOverlay = Ogre::OverlayManager::getSingleton().
			getByName("Verve/Debug");

		if (debugOverlay->isVisible())
        {
			debugOverlay->hide();
			gAgentDebugger->setDisplayEnabled(false);
		}
		else
		{
			debugOverlay->show();
			gAgentDebugger->setDisplayEnabled(true);
		}

//.........这里部分代码省略.........
开发者ID:sub77,项目名称:hobbycode,代码行数:101,代码来源:main.cpp

示例15: DoControll

bool PerspectiveController::DoControll( float a_timeSinceLastFrame)
{
	Ogre::Vector3 transVector = Ogre::Vector3::ZERO;

	m_gameView->UpdateInput();
	OIS::Keyboard *keyEvent = m_gameView->GetKeyEvent();
	Ogre::Vector2 mouseInput = m_gameView->GetMouseMovement();
	bool updateCamera = false; 
	m_time += a_timeSinceLastFrame;

	if (keyEvent != NULL) {
		if (m_time > 1000 && keyEvent->isKeyDown( OIS::KC_F1 )) {
			m_time = 0;
			m_gameSettings->SetGameState(GameSettings::GAME_STATE_DEBUG);
			return false;
		}
		if ( keyEvent->isKeyDown( OIS::KC_E )) {
			m_game->SpawnEnemy();
		}
		if ( keyEvent->isKeyDown( OIS::KC_R )) {
			m_activeCamera->ResetOrientation();
		}
		if ( m_gameView->MouseLeftPressed()) {
			if (m_game->CollisionAOE(m_mouseAnim->GetPosition(), m_mouseAnim->GetRadius(), true)) {
				m_game->DamageEnemies(5, 0);
			}
			else if (m_game->IsMouseOverWeapon(m_mouseAnim->GetPosition(), m_mouseAnim->GetRadius())) {
				m_player->SetActiveWeapon(m_game->GetSelectedWeaponAt(m_mouseAnim->GetPosition(), m_mouseAnim->GetRadius()));
				m_gameSettings->SetGameView(GameSettings::GAME_VIEW_FIRST_PERSON);
				m_time = 0;
				return false;
			}
		}
	}
	// Flyttar player om transVector inte är "tom"
	if (transVector != Ogre::Vector3::ZERO) {
		m_player->Move( transVector, a_timeSinceLastFrame);
		updateCamera = true;
	}
	// flyttar musen om musen rört på sig
	if ( mouseInput != Ogre::Vector2::ZERO){
		m_mouseAnim->MoveRelative(mouseInput, a_timeSinceLastFrame);
		if (m_game->CollisionAOE(m_mouseAnim->GetPosition(), m_mouseAnim->GetRadius(), false)) {
			m_mouseAnim->SetAboveEnemy();
		}
		else if (m_game->IsMouseOverWeapon(m_mouseAnim->GetPosition(), m_mouseAnim->GetRadius())) {
			m_mouseAnim->SetAboveWeapon();
		}
		else {
			m_mouseAnim->SetNoTarget();
		}
		updateCamera = true;
	}

	// Updaterar kameran..
	if (updateCamera) {
		m_activeCamera->Update( m_player->GetPosition(), m_player->GetWeaponOrientation(), mouseInput );
	}
	m_hudMgr->UpdateMoney(m_game->m_playerMoney);
	m_gameView->Update( a_timeSinceLastFrame);
	if (!m_game->Update( a_timeSinceLastFrame )) {
		m_gameSettings->SetGameState(GameSettings::GAME_STATE_GAMEOVER);
		return false;
	}

	return true;
}
开发者ID:Argos86,项目名称:dt2370,代码行数:67,代码来源:PerspectiveController.cpp


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