这篇教程C++ IsKeyDown函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中IsKeyDown函数的典型用法代码示例。如果您正苦于以下问题:C++ IsKeyDown函数的具体用法?C++ IsKeyDown怎么用?C++ IsKeyDown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了IsKeyDown函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: MoveY// Player movement behaviour and controls //void Player::Move(int screenX, int screenY){ if(IsKeyDown(KEY_UP) && y > height/2) { MoveY(-1.4); } else if(IsKeyDown(KEY_DOWN) && y < screenY-height/2) { MoveY(1.4); } if(IsKeyDown(KEY_LEFT) && x > width/2) { state = 3; MoveX(-1.4); } else if(IsKeyDown(KEY_RIGHT) && x < screenX-width/2) { state = 4; MoveX(1.4); } else state = 0; UpdatePosition();}
开发者ID:gillstudio,项目名称:AIEProjects,代码行数:26,
示例2: event//-----------------------------------------------------voidnsNativeDragTarget::DispatchDragDropEvent(PRUint32 aEventType, POINTL aPT){ nsEventStatus status; nsDragEvent event(PR_TRUE, aEventType, mWindow); nsWindow * win = static_cast<nsWindow *>(mWindow); win->InitEvent(event); POINT cpos; cpos.x = aPT.x; cpos.y = aPT.y; if (mHWnd != NULL) { ::ScreenToClient(mHWnd, &cpos); event.refPoint.x = cpos.x; event.refPoint.y = cpos.y; } else { event.refPoint.x = 0; event.refPoint.y = 0; } event.isShift = IsKeyDown(NS_VK_SHIFT); event.isControl = IsKeyDown(NS_VK_CONTROL); event.isMeta = PR_FALSE; event.isAlt = IsKeyDown(NS_VK_ALT); mWindow->DispatchEvent(&event, status);}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:30,
示例3: absbool nuiMatrixView::MouseMoved(nuiSize X, nuiSize Y){ if (!mClicked || !mCanChange) return false; nuiSize deltaX = X - mClickPos[0]; nuiSize deltaY = mClickPos[1] - Y; mClickPos[0] = X; mClickPos[1] = Y; nuiSize delta = (abs(deltaX) > abs(deltaY))? deltaX : deltaY; // fine change if (IsKeyDown(mFineSensitivityKey)) delta = (delta > 0)? 1 : (-1); // look at the selection if (mSelectedItems.size() >0) { if (IsKeyDown(mRelativeKey)) RelativeSpinCells(delta); else SpinCells(delta); return true; } // no selection. change the currently clicked item mClickedItem->SetRelativeValue(delta); return true;}
开发者ID:YetToCome,项目名称:nui3,代码行数:33,
示例4: GetRightThumbStickValueXMFLOAT2 Input::GetLookVector() const{ float x = 0.0f; float y = 0.0f; GetRightThumbStickValue(&x, &y); if (IsKeyDown(VK_RIGHT)) { x = 1.0f; } if (IsKeyDown(VK_LEFT)) { x = -1.0f; } if (IsKeyDown(VK_UP)) { y = 1.0f; } if (IsKeyDown(VK_DOWN)) { y = -1.0f; } return XMFLOAT2(x, y);}
开发者ID:rezanour,项目名称:randomoldstuff,代码行数:25,
示例5: OnMouseMovevoid PathFindApp::OnMouseMove(float X, float Y){ if (this->IsLeftButtonDown() && !IsKeyDown(HK_LCONTROL) && !IsKeyDown(HK_RCONTROL)) { m_map.Set(X,Y,this->IsShiftKeyDown() ? 1:0); }}
开发者ID:gejza,项目名称:Hoe3D,代码行数:7,
示例6: GetLeftThumbStickValueXMFLOAT2 Input::GetMovementVector() const{ float x = 0.0f; float y = 0.0f; GetLeftThumbStickValue(&x, &y); if (IsKeyDown('D')) { x = 1.0f; } if (IsKeyDown('A')) { x = -1.0f; } if (IsKeyDown('W')) { y = 1.0f; } if (IsKeyDown('S')) { y = -1.0f; } return XMFLOAT2(x, y);}
开发者ID:rezanour,项目名称:randomoldstuff,代码行数:25,
示例7: WinLose// checks if score is greater than zero to decide winner //void WinLose(int &redScore, int &blueScore, bool &winLose, bool &quit){ static char cWinText[128] = {'/n'}; static char cOptionsText[128] = {'/n'}; if(redScore >= 5) { winLose = true; sprintf_s(cWinText, "You Won! Play again?"); sprintf_s(cOptionsText, "Y / N"); DrawString(cWinText, 520, 300, SColour(0,255,0,255)); DrawString(cOptionsText, 620, 345, SColour(0,255,0,255)); } else if(blueScore >= 5) { winLose = true; sprintf_s(cWinText, "You Lost.. Play again?"); sprintf_s(cOptionsText, "Y / N"); DrawString(cWinText, 520, 300, SColour(0,255,0,255)); DrawString(cOptionsText, 620, 345, SColour(0,255,0,255)); } if(IsKeyDown('Y')) { winLose = false; redScore = 0; blueScore = 0; } else if(IsKeyDown('N')) { quit = true; }}
开发者ID:gillstudio,项目名称:AIEProjects,代码行数:34,
示例8: UpdateMenu// menu state draws screen and checks for a key command //void UpdateMenu(bool &play, bool &quit){ DrawSprite(menu); if(IsKeyDown(294)) play = true; if(IsKeyDown('Q')) quit = true;}
开发者ID:gillstudio,项目名称:AIEProjects,代码行数:10,
示例9: ifvoid PathFindApp::OnLeftButtonUp(){ if (IsKeyDown(HK_LCONTROL)) m_from.Set(GetMouseX(),GetMouseY()); else if (IsKeyDown(HK_RCONTROL)) m_to.Set(GetMouseX(),GetMouseY()); else m_map.Set(GetMouseX(),GetMouseY(),this->IsShiftKeyDown() ? 1:0);}
开发者ID:gejza,项目名称:Hoe3D,代码行数:9,
示例10: ServerPacketParsingSTATE StateTemp::Update(){ SmartPointer<PacketAddr> pAddr; m_pNetworkControl->ReceivePacket(); ISceneManager * smgr = Irrdevice::GetInstance()->GetSceneManager(); if((pAddr= m_pNetworkControl->GetPacket()) != NULL) { ServerPacketParsing(pAddr.getPoint()); } if(IsKeyDown(irr::KEY_KEY_T)) { smgr->setActiveCamera(m_pCamera); } if(IsKeyDown(irr::KEY_KEY_H)) { m_pMe->SetActiveCamera(); } if(IsKeyDown(irr::KEY_KEY_N)) { m_pYou->SetActiveCamera(); } // if(IsKeyDown(irr::KEY_KEY_T))// {// Packet p(BASE_ACK,m_MyId); // p<<1;// m_pNetworkControl->SendClientToPacket(p);// }// if(IsKeyDown(irr::KEY_KEY_F))// {// Packet p(BASE_ACK,m_MyId); // p<<2;// m_pNetworkControl->SendClientToPacket(p);// }// if(IsKeyDown(irr::KEY_KEY_G))// {// Packet p(BASE_ACK,m_MyId); // p<<3;// m_pNetworkControl->SendClientToPacket(p);// }// if(IsKeyDown(irr::KEY_KEY_H))// {// Packet p(BASE_ACK,m_MyId); // p<<4;// m_pNetworkControl->SendClientToPacket(p);// } return STATE_NONE;}
开发者ID:JeongSeungSU,项目名称:FightingSprit,代码行数:53,
示例11: UpdateGame// Update game (one frame)void UpdateGame(void){ if (!gameOver) { if (IsKeyPressed('P')) pause = !pause; if (!pause) { // Player movement if (IsKeyDown(KEY_LEFT)) player.position.x -= 5; if ((player.position.x - player.size.x/2) <= 0) player.position.x = player.size.x/2; if (IsKeyDown(KEY_RIGHT)) player.position.x += 5; if ((player.position.x + player.size.x/2) >= screenWidth) player.position.x = screenWidth - player.size.x/2; // Launch ball if (!ball.active) { if (IsKeyPressed(KEY_SPACE)) { ball.active = true; ball.speed = (Vector2){ 0, -5 }; } } UpdateBall(); // Game over logic if (player.life <= 0) gameOver = true; else { gameOver = true; for (int i = 0; i < LINES_OF_BRICKS; i++) { for (int j = 0; j < BRICKS_PER_LINE; j++) { if (brick[i][j].active) gameOver = false; } } } } } else { if (IsKeyPressed(KEY_ENTER)) { InitGame(); gameOver = false; } } }
开发者ID:AdanBB,项目名称:raylib,代码行数:54,
示例12: HandleEventsvoid IntroState::HandleEvents(GameEngine* a_opGame){ // look for key presses to quit or go to the menu?? if (IsKeyDown(GLFW_KEY_ENTER)) { a_opGame->ChangeState(PlayState::Instance()); } if (IsKeyDown('Q')) { a_opGame->Quit(); }}
开发者ID:iancarnation,项目名称:AIE_Projects,代码行数:12,
示例13: get_button_statevoid get_button_state(bool *a, bool *b, bool *up, bool *down, bool *l, bool *r){ KeyInputConfig *keyConf = config->get_key_config(); if (a) *a = IsKeyJustUp(KeyConfig::KEY_MENU_SELECT) || IsControllerButtonJustUp(KeyConfig::KEY_MENU_SELECT); if (b) *b = IsKeyJustUp(KeyConfig::KEY_MENU_BACK) || IsControllerButtonJustUp(KeyConfig::KEY_MENU_BACK); if (up) *up = IsKeyDown(KeyConfig::KEY_MENU_UP) || IsControllerButtonDown(KeyConfig::KEY_MENU_UP); if (down) *down = IsKeyDown(KeyConfig::KEY_MENU_DOWN) || IsControllerButtonDown(KeyConfig::KEY_MENU_DOWN); if (r) *r = IsKeyDown(KeyConfig::KEY_MENU_RIGHT) || IsControllerButtonDown(KeyConfig::KEY_MENU_RIGHT); if (l) *l = IsKeyDown(KeyConfig::KEY_MENU_LEFT) || IsControllerButtonDown(KeyConfig::KEY_MENU_LEFT);}
开发者ID:ky0ncheng,项目名称:GTAV-EnhancedNativeTrainer,代码行数:12,
示例14: SetTransform static void SetTransform (const NewtonBody* body, const dFloat* matrix, int threadId) { NewtonUserJoint* player; PlayerController* controller; // find the player joint; player = NULL; for (NewtonJoint* joint = NewtonBodyGetFirstJoint(body); joint; joint = NewtonBodyGetNextJoint(body, joint)) { NewtonUserJoint* tmp; tmp = (NewtonUserJoint*) NewtonJointGetUserData(joint); if (CustomGetJointID (tmp) == PLAYER_JOINT_ID) { player = tmp; break; } } // call the generic transform callback controller = (PlayerController*) CustomGetUserData(player);#if 1 // this will project the visual mesh to the ground dMatrix visualMatrix; CustomPlayerControllerGetVisualMaTrix (player, &visualMatrix[0][0]);#else // this will display the player at the collision shape position const dMatrix& visualMatrix = *((dMatrix*) matrix);#endif controller->m_setTransformOriginal (body, &visualMatrix[0][0], threadId); // now we will set the camera to follow the player dVector eyePoint (visualMatrix.TransformVector(controller->m_point)); // check if the player wants third person view static int prevCKeyDown = IsKeyDown ('C'); int isCkeyDwon = IsKeyDown ('C'); if (isCkeyDwon && !prevCKeyDown) { controller->m_isThirdView = !controller->m_isThirdView; } prevCKeyDown = isCkeyDwon; if (controller->m_isThirdView) { dVector dir (GetCameraDir ()); eyePoint -= dir.Scale (8.0f); } SetCameraEyePoint (eyePoint);// NewtonBodyGetMatrix (body, &matrix[0][0]);// cameraEyepoint = matrix.m_posit;// cameraEyepoint.m_y += 1.0f; }
开发者ID:jardinier,项目名称:newton-dynamics,代码行数:52,
示例15: ProcessInputvoid ProcessInput(Game_Input *input){ input->UP.KeyDown = IsKeyDown(&Keys, input->UP.Button); input->UP.KeyUp = IsKeyUp(&Keys, input->UP.Button); input->DOWN.KeyDown = IsKeyDown(&Keys, input->DOWN.Button); input->DOWN.KeyUp = IsKeyUp(&Keys, input->DOWN.Button); input->RIGHT.KeyDown = IsKeyDown(&Keys, input->RIGHT.Button); input->RIGHT.KeyUp = IsKeyUp(&Keys, input->RIGHT.Button); input->LEFT.KeyDown = IsKeyDown(&Keys, input->LEFT.Button); input->LEFT.KeyUp = IsKeyUp(&Keys, input->LEFT.Button);}
开发者ID:EmanGalal,项目名称:Phase-1,代码行数:14,
示例16: speed void CPlayerController::ProcessKeys(void) { DIRECTION tDir = m_player->GetDirection(); b2Vec2 speed(0,0); if (IsKeyDown(ALLEGRO_KEY_D) && !IsKeyDown(ALLEGRO_KEY_A)) { speed.x += 5; tDir = RIGHT; } else if (IsKeyDown(ALLEGRO_KEY_A) && !IsKeyDown(ALLEGRO_KEY_D)) { speed.x -= 5; tDir = LEFT; } if (IsKeyDown(ALLEGRO_KEY_W) && !IsKeyDown(ALLEGRO_KEY_S)) { speed.y -= 5; tDir = UP; } else if (IsKeyDown(ALLEGRO_KEY_S) && !IsKeyDown(ALLEGRO_KEY_W)) { speed.y += 5; tDir = DOWN; } m_player->SetSpeed(speed); m_player->SetDirection(tDir); }
开发者ID:NaturalDre,项目名称:Nature,代码行数:29,
示例17: IsKeyDownbool InputHandler::IsKeyDown(int key, int modifiers){ if (!IsKeyDown(key)) return false; if ((modifiers & 1) != 0 && !IsKeyDown(0x11)) // Ctrl return false; if ((modifiers & 2) != 0 && !IsKeyDown(0x10)) // Shift return false; if ((modifiers & 4) != 0 && !IsKeyDown(0x12)) // Alt return false; return true;}
开发者ID:PickledMonkey,项目名称:SkyrimViveController,代码行数:14,
示例18: Updatevoid Update(){ // Calculate delta time clock_t clockNow = clock(); clock_t deltaClock = clockNow - clockLastFrame; float deltaTime = float(deltaClock) / CLOCKS_PER_SEC; clockLastFrame = clockNow; // Calculate FPS framesCounter++; framesTimeCounter += deltaTime; if( framesTimeCounter >= 1.0 ) { framesTimeCounter -= 1.0; fps = framesCounter; framesCounter = 0; } // Hero control if( IsKeyDown(VK_UP) ) unitsData[heroIndex].yOrder = UnitOrder_Backward; else unitsData[heroIndex].yOrder = UnitOrder_None; if( IsKeyDown(VK_LEFT) ) unitsData[heroIndex].xOrder = UnitOrder_Backward; else { if( IsKeyDown(VK_RIGHT) ) unitsData[heroIndex].xOrder = UnitOrder_Forward; else unitsData[heroIndex].xOrder = UnitOrder_None; } // Update all units for( int u = 0; u < unitsCount; u++ ) UpdateUnit( &unitsData[u], deltaTime ); // Update AI UpdateAI(); // Hero dead if( unitsData[heroIndex].health <= 0 ) Initialize();}
开发者ID:Dansken,项目名称:gamedev,代码行数:49,
示例19: WeaponManagervoid Player::Control(){ WeaponManager(); SetSpeed(c_v2DStill); if(IsKeyDown('A')) SetSpeedX(-1.0f); if(IsKeyDown('D')) SetSpeedX(1.0f); if(IsKeyDown('W')) SetSpeedY(-1.0f); if(IsKeyDown('S')) SetSpeedY(1.0f);}
开发者ID:blueskies9041,项目名称:Sam,代码行数:15,
示例20: OnUpdatevoid OnUpdate(float dt){ if (IsKeyDown('W')) walk(30 * dt); else if (IsKeyDown('S')) walk(-30 * dt); if (IsKeyDown('A')) strafe(30 * dt); else if (IsKeyDown('D')) strafe(-30 * dt); float calcedX = GetMouseX() - lastMouseX, calcedY = GetMouseY() - lastMouseY; lastMouseX = GetMouseX(); lastMouseY = GetMouseY(); if (calcedY < 0) pitch(0.5f * dt * abs(calcedY)); else if (calcedY > 0) pitch(-0.5f * dt * abs(calcedY)); if (calcedX > 0) yaw(0.5f * dt * abs(calcedX)); else if (calcedX < 0) yaw(-0.5f * dt * abs(calcedX));}
开发者ID:GROWrepo,项目名称:GameTeam_Study_Direct3D9,代码行数:15,
示例21: IsKeyDownvoid CKeyEdit::OnKeyDown( UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/ ) { //debug( _T("OnKeyDown: nChar=%u nRepCnt=%u nFlags=%08x/n"), nChar, nRepCnt, nFlags ); if ( IsKeyDown( VK_MENU ) ) { return; } if ( IsKeyDown( VK_CONTROL ) ) { return; } if ( ! KEY_XALNUM( nChar ) ) return; m_dwVk = (DWORD) nChar | ( IsKeyDown( VK_SHIFT ) ? 0x80000000UL : 0UL ); _Update( );}
开发者ID:TReKiE,项目名称:freecompose,代码行数:15,
示例22: Updatevoid Player::Update(float a_dt){ m_fTimer += a_dt; // Why are we incrementing m_fTimer? To set a bullet fire rate if (IsKeyDown('A')) m_x -= m_speed * a_dt; if (IsKeyDown('D')) m_x += m_speed * a_dt; if (IsKeyDown('W')) m_y -= m_speed * a_dt; if (IsKeyDown('S')) m_y += m_speed * a_dt; if (IsKeyDown(' ')) Fire(); // Check tos ee if we hit a boundary, this is concise- but if you expand // it a little bit, it doesn't look much different from what you have done already if (m_x < 0 + (m_pad + m_w2)) m_x = 0 + (m_pad + m_w2); if (m_x > g_w - (m_pad + m_w2)) m_x = g_w - (m_pad + m_w2);}
开发者ID:DylanGuidry95,项目名称:Assessment1Project,代码行数:15,
示例23: if// Received Mouse events:bool nuiKnob::MouseClicked(nuiSize X, nuiSize Y, nglMouseInfo::Flags Button){ mClickX = X; mClickY = Y; if ((Button & nglMouseInfo::ButtonLeft) && (Button & nglMouseInfo::ButtonDoubleClick)) { return false; } else if (Button & nglMouseInfo::ButtonLeft) { mClicked = true; Grab(); Invalidate(); mClickValue = mRange.GetValue(); return true; } else if (Button & nglMouseInfo::ButtonWheelUp) { if (IsKeyDown(mFineSensitivityKey)) { mRange.SetValue(mRange.GetValue() + mRange.GetIncrement() / mFineSensitivityRatio); } else { mRange.Increment(); } InteractiveValueChanged(); ActivateToolTip(this, true); return true; } else if (Button & nglMouseInfo::ButtonWheelDown) { if (IsKeyDown(mFineSensitivityKey)) { mRange.SetValue(mRange.GetValue() - mRange.GetIncrement() / mFineSensitivityRatio); } else { mRange.Decrement(); } InteractiveValueChanged(); ActivateToolTip(this, true); return true; } return false;}
开发者ID:YetToCome,项目名称:nui3,代码行数:49,
示例24: OnKeyPressedMsgApply void Input::OnKeyPressedMsgApply(KeyboardKey key) { if (IsKeyDown(key) || IsKeyPressed(key)) return; mPressedKeys.Add(key); }
开发者ID:zenkovich,项目名称:o2,代码行数:7,
示例25: IsKeyDown char CInputManager::GetChar(bool enableShift, bool enableCapslock) const { BYTE input[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', 0xc0, 0xbd, 0xbb, 0xdc, 0xdb, 0xdd, 0xba, 0xde, 0xbc, 0xbe, 0xbf, ' ', 0x0d, '/t', '/b' }; BYTE output[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', '`', '-', '=', '//', '[', ']', ';', '/'', ',', '.', '/', ' ', '/n', '/t', '/b' }; BYTE output2[] = { ')', '!', '@', '#', '$', '%', '^', '&', '*', '(', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '~', '_', '+', '|', '{', '}', ':', '/"', '<', '>', '?', ' ', '/n', '/t', '/b' }; // from combination of capslock and shit, figure out what is the case char mod = (enableShift && IsKeyDown(Keys::Shift)) + (enableCapslock && IsCapslockActive()); for (int i = 0; i < sizeof(input); i++) { if (IsKeyPressed((Keys)input[i])) { if (mod == 1) return output2[i]; else return output[i]; } } return 0; }
开发者ID:MaciejSzpakowski,项目名称:dx2d,代码行数:29,
示例26: HandleUIvoid HermiteSpline::HandleUI(StateManager* stateMan){ if (IsKeyDown('M')) { stateMan->PopState(); return; } if (GetMouseButtonDown(MOUSE_BUTTON_1)) { //loop through objects and see if clicked for (Sprite* object : objectList) { if (object->ID == objectList[0]->ID) { double mousePosX = 0.0; double mousePosY = 0.0; GetMouseLocation(mousePosX, mousePosY); mousePosY = screenHeight - mousePosY; //std::cout << "x: " << mousePosX << " y: " << mousePosY << std::endl; bool isCollided = object->IsCollided(Vector2(mousePosX, mousePosY)); //std::cout << "object: " << object->name << " clicked: " << isCollided << std::endl; if (object->IsCollided(Vector2(mousePosX, mousePosY))) { object->position = Vector2(mousePosX, mousePosY); } } } }}
开发者ID:JeffreyMJohnson,项目名称:exercises,代码行数:32,
示例27: PaddleMovement// movement code used to position the red paddle //void PaddleMovement(DynamObject &obj){ if(IsKeyDown('W') && obj.position.y > 0) { obj.position.y -= 1.1f; } else if(IsKeyDown('S') && obj.position.y < 652) { obj.position.y += 1.1f; } MoveSprite(obj.sprite, obj.position.x, obj.position.y);}
开发者ID:gillstudio,项目名称:AIEProjects,代码行数:17,
示例28: SetSpeedvoid Player::Control(){ SetSpeed(0,0); if(IsKeyDown('A')) SetSpeedX(-1.0f); if(IsKeyDown('D')) SetSpeedX(1.0f); if(IsKeyDown('W')) SetSpeedY(-1.0f); if(IsKeyDown('S')) SetSpeedY(1.0f); if(IsKeyDown('T')) Shoot();}
开发者ID:blueskies9041,项目名称:Sam,代码行数:16,
示例29: entervoid enter(bool &bSplashActive){ if (IsKeyDown(32)) { bSplashActive = false; }}
开发者ID:Steakfries,项目名称:Shooter,代码行数:7,
注:本文中的IsKeyDown函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ IsKeyPressed函数代码示例 C++ IsItemIn函数代码示例 |