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

C++ IsKeyPressed函数代码示例

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

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



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

示例1: GetKeyboardUpdate

bool Application::GetKeyboardUpdate()
{
	if(IsKeyPressed('A'))
	{
		scene->UpdateCameraStatus('a');
	}
	
	if(IsKeyPressed('D'))
	{
		scene->UpdateCameraStatus('d');
	}
	
	if(IsKeyPressed('W'))
	{
		scene->UpdateCameraStatus('w');
	}
	
	else
	{
		scene->UpdateCameraStatus('w', false);
	}
	
	if(IsKeyPressed('S'))
	{
		scene->UpdateCameraStatus('s');
	}
	
	if(IsKeyPressed(32))
	{
		scene->UpdateCameraStatus(32);
	}
    
	return true;
}
开发者ID:BTXM09,项目名称:SPTHREE,代码行数:34,代码来源:Application.cpp


示例2: GetHotkeyModifierFlags

//! Returns current modifier keys pressed, using win32 MOD_* flags.
unsigned GetHotkeyModifierFlags() {
	unsigned ret = 0;
	if (IsKeyPressed(VK_CONTROL)) ret |= MOD_CONTROL;
	if (IsKeyPressed(VK_SHIFT)) ret |= MOD_SHIFT;
	if (IsKeyPressed(VK_MENU)) ret |= MOD_ALT;
	if (IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN)) ret |= MOD_WIN;
	return ret;
}
开发者ID:Irwin1138,项目名称:foo_bestversion,代码行数:9,代码来源:win-objects.cpp


示例3: if

void InputManager::UpdateVirtualAxisFromKeyboard(int i)
{
	if (IsKeyPressed(_myVirtualAxis[i].positiveAxis))
		_myVirtualAxis[i].state=1.0;
	else if (IsKeyPressed(_myVirtualAxis[i].negativeAxis))
		_myVirtualAxis[i].state=-1.0;
	else
		_myVirtualAxis[i].state=0.0;
}
开发者ID:CheVilCode,项目名称:Desolation_Of_Stoned,代码行数:9,代码来源:inputManager.cpp


示例4: WaitForKeyRelease

static void WaitForKeyRelease (void)
{
	if (IsKeyPressed())
		while (IsKeyPressed())
		{
			BE_ST_BiosScanCode(0);
			//getch();
		}
}
开发者ID:BSzili,项目名称:refkeen,代码行数:9,代码来源:loadscn.c


示例5: RedSquareUpdate

// Update function for this object type
void RedSquareUpdate   ( REDSQUARE *self )
{
  COLLISION_FLAG flag = CheckHotspotCollision( self->rect_ );
  char buffer[100] = { 0 };

  // Apply acceleration for keystrokes
  // Documentation for physics:    http://cecilsunkure.blogspot.com/2012/02/basic-2d-vector-physics.html
  // Documentation for collisions: http://cecilsunkure.blogspot.com/2012/07/collision-basic-2d-collision-detection.html
  //                               http://cecilsunkure.blogspot.com/2012/04/binary-collision-maps-platformer.html
  if(IsKeyPressed( VK_RIGHT ))
  {
    self->vel_.x_ += self->accel_ * GetDT( );
  }
  if(IsKeyPressed( VK_LEFT ))
  {
    self->vel_.x_ += -self->accel_ * GetDT( );
  }
  if(IsKeyPressed( VK_UP ))
  {
    self->vel_.y_ += -self->accel_ * GetDT( );
  }
  if(IsKeyPressed( VK_DOWN ))
  {
    self->vel_.y_ += self->accel_ * GetDT( );
  }

  // Clamp velocity within a max/min range
  VelocityClamp( &self->vel_, .02f );

  self->rect_.center_.x_ += self->vel_.x_ * GetDT( );
  self->rect_.center_.y_ += self->vel_.y_ * GetDT( );

  sprintf( buffer, "%.3f, %.3f", self->vel_.x_, self->vel_.y_ );
  WriteStringToScreen( buffer, 30, 30 );

  if(flag & COLLISION_BOTTOM)
  {
    SnapToCell( &self->rect_.center_.y_ );
    self->vel_.y_ = 0.f;
  }
  if(flag & COLLISION_TOP)
  {
    SnapToCell( &self->rect_.center_.y_ );
    self->vel_.y_ = 0.f;
  }
  if(flag & COLLISION_LEFT)
  {
    SnapToCell( &self->rect_.center_.x_ );
    self->vel_.x_ = 0.f;
  }
  if(flag & COLLISION_RIGHT)
  {
    SnapToCell( &self->rect_.center_.x_ );
    self->vel_.x_ = 0.f;
  }
}
开发者ID:seato,项目名称:AsciiEngine,代码行数:57,代码来源:RedSquare.c


示例6: getKeyboardUpdate

bool Application::getKeyboardUpdate()
{
	if(IsKeyPressed('W'))
		scene->UpdateInput('w');

	if(IsKeyPressed('A'))
		scene->UpdateInput('a');
	
	if(IsKeyPressed('S'))
		scene->UpdateInput('s');

	if(IsKeyPressed('D'))
		scene->UpdateInput('d');

	for (unsigned char i = '1'; i <= '9'; ++i)
	{
		if (IsKeyPressed(i))
			scene->UpdateInput(i);
	}

	if(IsKeyPressed(VK_SPACE))
		scene->UpdateInput(' ');
	
	if(IsKeyPressed(VK_SHIFT))
		scene->UpdateInput('S');

	if(IsKeyPressed(VK_CONTROL))
		scene->UpdateInput('C');
	
	if (IsKeyPressed(VK_RETURN))
		scene->UpdateInput('R');

	return true;
}
开发者ID:Dopelust,项目名称:SP3-13,代码行数:34,代码来源:Application.cpp


示例7: should_relay_key_restricted

static bool should_relay_key_restricted(UINT p_key) {
	switch(p_key) {
	case VK_LEFT:
	case VK_RIGHT:
	case VK_UP:
	case VK_DOWN:
		return false;
	default:
		return (p_key >= VK_F1 && p_key <= VK_F24) || IsKeyPressed(VK_CONTROL) || IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN);
	}
}
开发者ID:thenfour,项目名称:WMircP,代码行数:11,代码来源:menu_manager.cpp


示例8: glfwGetMouseButton

void Controller::UpdateKeys()
{
	/** Set all keys to false **/
	for(unsigned i = 0; i < TOTAL_CONTROLS; ++i)
		myKeys[i] = false;

	/**** See which keys are pressed ****/
	/** Keyboard **/
	for(int i = 0; i <= OPEN; ++i)
	{
		if(IsKeyPressed(inputChar[i]))
			myKeys[i] = true;
	}

	/** non-keyboard(mouse) **/
	mouseLeftButton = glfwGetMouseButton(glfwGetCurrentContext(), GLFW_MOUSE_BUTTON_LEFT);
	mouseRightButton = glfwGetMouseButton(glfwGetCurrentContext(), GLFW_MOUSE_BUTTON_RIGHT);

	if(mouseLeftButton == GLFW_PRESS)
		myKeys[SHOOT] = true;
	if(mouseRightButton == GLFW_PRESS)
		myKeys[AIM] = true;

	/** Arrow key **/
	if( IsKeyPressed(VK_UP) )
		myKeys[ARROW_UP] = true;

	if( IsKeyPressed(VK_DOWN) )
		myKeys[ARROW_DOWN] = true;

	if( IsKeyPressed(VK_LEFT) )
		myKeys[ARROW_LEFT] = true;

	if( IsKeyPressed(VK_RIGHT) )
		myKeys[ARROW_RIGHT] = true;

	/** Scrolling **/
	GLFWwindow* glfwGetCurrentContext(void);
	glfwSetScrollCallback(glfwGetCurrentContext(), scroll);

	if(scrollyPos > 0.0)
	{
		myKeys[SCROLL_UP] = true;
	}
	else if(scrollyPos < 0.0)
	{
		myKeys[SCROLL_DOWN] = true;
	}
	
	if(scrollyPos != 0.0)
	{
		scrollyPos = 0.0;
	}
}
开发者ID:FieryGazette,项目名称:2D-Game,代码行数:54,代码来源:Controller.cpp


示例9: CheckKey

    virtual KeyAction CheckKey(int key) {
#ifdef MFLD_PRX_KEY_LAYOUT
        if (IsKeyPressed(KEY_POWER) && key == KEY_VOLUMEUP) {
#else
        if (IsKeyPressed(KEY_VOLUMEDOWN) && key == KEY_VOLUMEUP) {
#endif
            return TOGGLE;
        }
        return ENQUEUE;
    }
};
开发者ID:e4basil,项目名称:android_device_asus_a500cg-1,代码行数:11,代码来源:recovery_ui.cpp


示例10: 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


示例11: GameOver

int GameOver(int player)
{
    //MOKHTAR,HAITHAM,BRAHIM,SALAH,WASSIM
    int FallIndexes[5]= {29,23,47,29,26},selection=0, button_pressed=0;;
    IMAGE **Pics;
    IMAGE*cadre=load_image("Resources/Images/ingame_bar.png");
    switch(player)
    {
    case 0:
        Pics=MokhtarPics;
        break;
    case 1:
        Pics=HaithamPics;
        break;
    case 2:
        Pics=BrahimPics;
        break;
    case 3:
        Pics=SalahPics;
        break;
    case 4:
        Pics=WassimPics;
        break;
    }

    while(!IsKeyPressed(1,ENTER))
    {

        button_pressed++;
        if((IsKeyPressed(1,LEFT) || IsKeyPressed(1,RIGHT)) && button_pressed>10)
        {
            selection=!selection;
            button_pressed=0;
        }
        draw_text(SharpCurve,"Game Over",20,50,5,CENTER_X,100);
        draw_text(Arista,"Continue?",8,50,30,CENTER_X,100);
        draw_text(Arista,"YES",8,25,50,CENTER_X,100);
        draw_text(Arista,"NO",8,75,50,CENTER_X,100);

        draw_image_ex(Pics[FallIndexes[player]],25,30,50,0,NONE,100);
        draw_image_ex(cadre,18+selection*50,40,15,30,NONE,100);
        next_frame();
    }
while(IsKeyPressed(1,ENTER))
rest(1);
	return !selection;

}
开发者ID:iBicha,项目名称:esprit-2013-1a3-sharp-vision-sharp-fighter,代码行数:48,代码来源:Arcade.c


示例12: CheckKey

// The default CheckKey implementation assumes the device has power,
// volume up, and volume down keys.
//
// - Hold power and press vol-up to toggle display.
// - Press power seven times in a row to reboot.
// - Alternate vol-up and vol-down seven times to mount /system.
RecoveryUI::KeyAction RecoveryUI::CheckKey(int key) {
    if (IsKeyPressed(KEY_POWER) && key == KEY_VOLUMEUP) {
        return TOGGLE;
    }

    if (key == KEY_POWER) {
        ++consecutive_power_keys;
        if (consecutive_power_keys >= 7) {
            return REBOOT;
        }
    } else {
        consecutive_power_keys = 0;
    }

    if ((key == KEY_VOLUMEUP &&
         (last_key == KEY_VOLUMEDOWN || last_key == -1)) ||
        (key == KEY_VOLUMEDOWN &&
         (last_key == KEY_VOLUMEUP || last_key == -1))) {
        ++consecutive_alternate_keys;
        if (consecutive_alternate_keys >= 7) {
            consecutive_alternate_keys = 0;
            return MOUNT_SYSTEM;
        }
    } else {
        consecutive_alternate_keys = 0;
    }
    last_key = key;

    return ENQUEUE;
}
开发者ID:JCROM-Android,项目名称:jcrom_bootable_recovery_,代码行数:36,代码来源:ui.cpp


示例13: IsKeyPressed

void InputManager::UpdateVirtualButtons()
{
	bool pressed;
	for (int i=0; i<(int)_myVirtualButtons.Size();i++)
	{
		pressed = IsKeyPressed(_myVirtualButtons[i].button);
		_myVirtualButtons[i].keyDown=_myVirtualButtons[i].keyUp=false;
		
		if (!_myVirtualButtons[i].keyPress && pressed)
		{
			_myVirtualButtons[i].keyDown=true;
			EventManager::Instance().CallbackVButton(_myVirtualButtons[i].name, Event::buttonDown);
		}
		else if (_myVirtualButtons[i].keyPress && !pressed)
		{
			_myVirtualButtons[i].keyUp=true;
			EventManager::Instance().CallbackVButton(_myVirtualButtons[i].name,Event::buttonUp);
		}
		
		_myVirtualButtons[i].keyPress = pressed;
	   /*if (pressed)
			EventManager::Instance().CallbackVButton(_myVirtualButtons[i].name,
													 static_cast<int>(EventVButton::buttonPressed));*/
	}
}
开发者ID:CheVilCode,项目名称:Desolation_Of_Stoned,代码行数:25,代码来源:inputManager.cpp


示例14: IsKeyPressed

BOOL InputClient_State::IsAltPressed() const
{
	return IsKeyPressed(EKeyCode::Key_Menu)
		//|| IsKeyPressed(EKeyCode::Key_LMenu)
		//|| IsKeyPressed(EKeyCode::Key_RMenu)
		;
}
开发者ID:S-V,项目名称:Lollipop,代码行数:7,代码来源:Client.cpp


示例15: Common_Update

void Common_Update()
{
    /*
        Capture key input
    */
    unsigned int newButtons = 0;
    while (IsKeyPressed())
    {   
        unsigned int key = getchar();

        if      (key == '1')    newButtons |= (1 << BTN_ACTION1);
        else if (key == '2')    newButtons |= (1 << BTN_ACTION2);
        else if (key == '3')    newButtons |= (1 << BTN_ACTION3);
        else if (key == '4')    newButtons |= (1 << BTN_ACTION4);
        else if (key == 'h')    newButtons |= (1 << BTN_LEFT);
        else if (key == 'l')    newButtons |= (1 << BTN_RIGHT);
        else if (key == 'k')    newButtons |= (1 << BTN_UP);
        else if (key == 'j')    newButtons |= (1 << BTN_DOWN);
        else if (key == 32)     newButtons |= (1 << BTN_MORE);
        else if (key == 'q')    newButtons |= (1 << BTN_QUIT);
    }

    gPressedButtons = (gDownButtons ^ newButtons) & newButtons;
    gDownButtons = newButtons;

    /*
        Update the screen
    */
    printf("%c[H", 0x1B);               // Move cursor to home position
    printf("%s", gConsoleText.c_str()); // Terminal console is already double buffered, so just print
    printf("%c[J", 0x1B);               // Clear the rest of the screen
    
    gConsoleText.clear();
}
开发者ID:DarrylVo,项目名称:OpenGl-Music-Visualizer,代码行数:34,代码来源:common_platform.cpp


示例16: OnKeyPressedMsgApply

	void Input::OnKeyPressedMsgApply(KeyboardKey key)
	{
		if (IsKeyDown(key) || IsKeyPressed(key))
			return;

		mPressedKeys.Add(key);
	}
开发者ID:zenkovich,项目名称:o2,代码行数:7,代码来源:Input.cpp


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


示例18: UpdateMissionScreen

// Mission Screen Update logic
void UpdateMissionScreen(void)
{
    UpdateMusicStream(musMission);

    if (!writeEnd) WriteMissionText();
    else
    {
        framesCounter++;

        if ((framesCounter%blinkFrames) == 0)
        {
            framesCounter = 0;
            blinkKeyWord = !blinkKeyWord;
        }
    }

    if (showButton)
    {
        if (IsKeyPressed(KEY_ENTER) || IsButtonPressed())
        {
            if (!writeEnd)
            {
                writeEnd = true;
                writeKeyword = true;
                writeNumber = true;
                missionLenght = missionMaxLength;
            }
            else
            {
                finishScreen = true;
                showButton = false;
            }
        }
    }
}
开发者ID:raysan5,项目名称:raylib,代码行数:36,代码来源:screen_mission.c


示例19: UpdateGameplayScreen

// Gameplay Screen Update logic
void UpdateGameplayScreen(void)
{
    
    if (IsKeyPressed('P')) 
    {
        pause = !pause;
        if (!pause) ResumeMusicStream();
        else PauseMusicStream();
    }
    
    if (!pause)
    {     
        if (!startGame && IsKeyPressed(KEY_SPACE)) 
        {
            startGame = TRUE;
            ResumeMusicStream();
        }
        // TODO: Update GAMEPLAY screen variables here!
        if (startGame)
        {
            UpdateMainCamera(&mainCamera);
            
            UpdateTrianglesPosition(mainCamera.position);
            UpdateTrianglesState();
            UpdatePlatformsPosition(mainCamera.position);
            UpdatePlatformsState();
            
            UpdatePlayer(&player);
        }
    }
    // Press enter to change to ENDING screen
    
    /*
    if (IsKeyPressed(KEY_ENTER) || !player.isAlive || mainCamera.position.x/CELL_SIZE>GRID_WIDTH+10)
    {
        finishScreen = 1;
    }
    */
    
    // WIN / LOSE Conditions
    if (!player.isAlive) GameplayEnd(1); // If player dies, reset gameplay screen
    else if (mainCamera.position.x/CELL_SIZE>GRID_WIDTH+20) GameplayEnd(2); // If player reaches the end level (+20 cells) game ends.   
    
    // MusicIsPlaying
    UpdateMusicStream();
}
开发者ID:MarcMDE,项目名称:TapToJump,代码行数:47,代码来源:screen_gameplay.c


示例20: CheckKey

 virtual KeyAction CheckKey(int key) {
     switch (key) {
     case KEY_VOLUMEUP:
     case KEY_UP:
         if (IsKeyPressed(KEY_VOLUMEDOWN) || IsKeyPressed(KEY_VOLUMEUP))
             return TOGGLE;
         break;
     case KEY_VOLUMEDOWN:
     case KEY_DOWN:
         if (IsKeyPressed(KEY_VOLUMEUP) || IsKeyPressed(KEY_UP))
             return TOGGLE;
         break;
     case KEY_ESC:
         return TOGGLE;
     }
     return ENQUEUE;
 }
开发者ID:quanganh2627,项目名称:platform_vendor_intel_recovery_plugins,代码行数:17,代码来源:bigcore_recovery_ui.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ IsLeaf函数代码示例发布时间:2022-05-30
下一篇:
C++ IsKeyDown函数代码示例发布时间: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