• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ IsKeyDown函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IsKeyDown函数的典型用法代码示例。如果您正苦于以下问题:C++ IsKeyDown函数的具体用法?C++ IsKeyDown怎么用?C++ IsKeyDown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IsKeyDown函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:Player.cpp


示例2: event

//-----------------------------------------------------
void
nsNativeDragTarget::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,代码来源:nsNativeDragTarget.cpp


示例3: abs

bool 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,代码来源:nuiMatrixView.cpp


示例4: GetRightThumbStickValue

XMFLOAT2 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,代码来源:input.cpp


示例5: OnMouseMove

void 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,代码来源:pathfinding.cpp


示例6: GetLeftThumbStickValue

XMFLOAT2 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,代码来源:input.cpp


示例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,代码来源:Functions.cpp


示例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,代码来源:Functions.cpp


示例9: if

void 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,代码来源:pathfinding.cpp


示例10: ServerPacketParsing

STATE 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,代码来源:StateTemp.cpp


示例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,代码来源:arkanoid.c


示例12: HandleEvents

void 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,代码来源:IntroState.cpp


示例13: get_button_state

void 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,代码来源:io.cpp


示例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,代码来源:TutorialCode.cpp


示例15: ProcessInput

void 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,代码来源:main.cpp


示例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,代码来源:PlayerController.cpp


示例17: IsKeyDown

bool 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,代码来源:Input.cpp


示例18: Update

void 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,代码来源:main.cpp


示例19: WeaponManager

void 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,代码来源:Player.cpp


示例20: OnUpdate

void 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,代码来源:Main.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IsKeyPressed函数代码示例发布时间:2022-05-30
下一篇:
C++ IsItemIn函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap