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


C++ IsKeyPressed函数代码示例

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


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


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