int PlayerObject::update(long elapsedTime) { if (isKeyDown(IM_W)) walkForward(); if (isKeyDown(IM_S)) walkBackward(); if (isKeyDown(IM_A)) walkLeft(); if (isKeyDown(IM_D)) walkRight(); //if (isKeyPressed(IM_SPACE)) jump(); if (isKeyDown(IM_SPACE)) jump(); if (isKeyPressed(IM_M1)) primaryClick(); if (isKeyReleased(IM_M1)) primaryRelease(); if (isKeyDown(IM_M1)) primaryDown(); if (isKeyUp(IM_M1)) primaryUp(); if (isKeyPressed(IM_M2)) secondaryClick(); if (isKeyReleased(IM_M2)) secondaryRelease(); if (isKeyDown(IM_M2)) secondaryDown(); if (isKeyUp(IM_M2)) secondaryUp(); if (isKeyPressed(IM_1)) changeSpell(0); if (isKeyPressed(IM_2)) changeSpell(1); if (isKeyPressed(IM_3)) changeSpell(2); if (isKeyPressed(IM_4)) changeSpell(3); if (isKeyPressed(IM_5)) changeSpell(4); if (getNetworkState() == NETWORK_STATE_OFFLINE) { if (isMouseScrollUp()) { PropObject * temp = new PropObject("sword.obj", "error.tga", "default.glsl", camera->getPos() + camera->getLookAtVector(), camera->getLookAtVector(), camera->getUpVector(), "sword.prop"); //RagdollObject * temp = new RagdollObject(box, t, s, camera->getPos(), camera->getLookAtVector(), camera->getUpVector()); temp->setVelocity(camera->getLookAtVector()*10.0f); temp->setRotation(camera->getLookAtVector(), camera->getUpVector()); } if (isMouseScrollDown()) { PropObject * temp = new PropObject("box.obj", "error.tga", "default.glsl", camera->getPos() + camera->getLookAtVector(), camera->getLookAtVector(), camera->getUpVector(), "box1x1.prop"); //RagdollObject * temp = new RagdollObject(box, t, s, camera->getPos(), camera->getLookAtVector(), camera->getUpVector()); temp->setVelocity(camera->getLookAtVector()*10.0f); temp->setRotation(camera->getLookAtVector(), camera->getUpVector()); } } POINT p = inputManager->getMouseMovement(); turn(p.x*0.05f, p.y*0.05f); int ret = CharacterObject::update(elapsedTime); //setDirection(camera->getLookAtVector()); camera->setPosition(btToGLM3(&getBTPosition()) + glm::vec3(0,1,0)); camera->setLookAtVector(getDirection()); //camera->update(elapsedTime); return ret; }
void CTastaturGER::read() { int iKey = tastatur->GetKey(); if (iKey != 0) { if (!checkDoublePressed(iKey)) { if (!createString(iKey)) { //False, String durch Eingabe fertig gestellt. Tastatur Off, Listener wieder On. bTastaturOn = false; if (bListenErlauben) bListenOn = true; liKeysPressed.clear(); } } } std::list<int>::iterator it; for (it = liKeysPressed.begin(); it != liKeysPressed.end(); ++it) { //liKeysPressed.remove_if(isKeyUp((int) *it)); int iAKey = (int)*it; if (isKeyUp(iAKey)) { liKeysPressed.remove(iAKey); break; } } }
bool InputSystem::isKeyReleased(KeyboardKey key) { bool a = 0; if(m_oldKeys[key] && isKeyUp(key)) { a = 1; } else { a = 0; } //m_oldKeys[k] = getKeyState(k); return a; }
void SDLInput::update() { impl->recentlyPressedKeys.clear(); impl->recentlyReleasedKeys.clear(); impl->recentlyPressedMouseButtons = 0; impl->recentlyReleasedMouseButtons = 0; SDL_Event e; while (SDL_PollEvent(&e) != 0) { if (e.type == SDL_QUIT) { impl->windowClosed = true; } if (isKeyDown(e)) { Key key = getKey(e); impl->recentlyPressedKeys.insert(key); impl->pressedKeys.insert(key); } if (isKeyUp(e)) { Key key = getKey(e); impl->recentlyReleasedKeys.insert(key); impl->pressedKeys.erase(key); } if (isMouseMove(e)) { impl->mousePosition = Vec2{(double) e.motion.x, (double) e.motion.y}; } if (isMouseButtonDown(e)) { impl->pressedMouseButtons |= mouseButtonToInt(getMouseButton(e)); impl->recentlyPressedMouseButtons |= mouseButtonToInt(getMouseButton(e)); } if (isMouseButtonUp(e)) { impl->pressedMouseButtons &= ~(mouseButtonToInt(getMouseButton(e))); impl->recentlyReleasedMouseButtons |= mouseButtonToInt(getMouseButton(e)); } } }
bool UserController::isKeyReleased( int charId ) const { return isKeyUp( charId ) && wasKeyPressed[charId]; }
bool Keyboard::wasKeyReleasedThisFrame(byte key)const { return isKeyUp(key) && wasKeyDown(key); }