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


C++ IsKeyDown函数代码示例

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


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


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