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


C++ KEYDOWN函数代码示例

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


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

示例1: pitch

void CCamera::ProcInput(GameInput *gameInput)
{ 
	float fDelta = 0.005f;
	
	float x = gameInput->m_CurMState.pos.x - gameInput->m_OldMState.pos.x;
	float y = gameInput->m_CurMState.pos.y - gameInput->m_OldMState.pos.y;

	pitch(y * fDelta * 0.5);
	yaw(x * fDelta * 0.5);

	if(KEYDOWN('W'))
	{
		walk(5000.0f * fDelta);
	}
	if(KEYDOWN('S'))
	{
		walk(-5000.0f * fDelta);
	}
	if(KEYDOWN('A'))
	{
		strafe(-5000.0f * fDelta);
	}
	if(KEYDOWN('D'))
	{
		strafe(5000.0f * fDelta);
	}

	return;
}
开发者ID:ly772696417,项目名称:SolarSystem,代码行数:29,代码来源:Camera.cpp

示例2: Graphics

void cBSPDemoCallbacks::OnUpdate( float _fDeltaTime )
{
    Graphics()->CalculateFrustum();

    m_pWorld->Update( _fDeltaTime );

	m_pNearestDoor = g_pBspEntity->m_pBSPFile->GetNearestDoor( m_pWorld->m_Camera.m_Loc, m_pWorld->m_Camera.m_Fwd );
    if ( m_pNearestDoor )
    {
        if ( KEYDOWN( TWISTER_KEY_SPACE ) )
        {
            m_pNearestDoor->OpenFrom( m_pWorld->m_Camera.m_Loc );
        }
    }

	if ( LightsManager()->m_SceneLightsContext.GetDirectionalLightsCount() > 0 )
	{
		m_pLight1Data = LightsManager()->m_SceneLightsContext.m_DirectionalLights[ 0 ];
		m_pLight1Data->m_Direction = m_pWorld->m_Camera.m_Fwd;
	}
	else
    {
		m_pLight1Data = 0;
    }
   
#ifdef WIN32
	m_pWorld->SetDeferredEnabled( !KEYDOWN( TWISTER_KEY_SPACE ) );
#endif 

}
开发者ID:ShadyEM,项目名称:Twister3D,代码行数:30,代码来源:BspMain.cpp

示例3: D3DXMatrixIdentity

HRESULT APPLICATION::Update(float deltaTime)
{
	//Control camera
	D3DXMATRIX  matWorld;
	D3DXMatrixIdentity(&matWorld);
	m_pDevice->SetTransform(D3DTS_WORLD, &matWorld);

	//Rotate farmers
	m_farmer1.SetRotation(m_farmer1.m_rot + D3DXVECTOR3(0.0f, deltaTime * 0.5f, 0.0f));
	if(m_farmer1.m_rot.y > D3DX_PI * 2.0f)m_farmer1.m_rot.y -= D3DX_PI * 2.0f;

	m_farmer2.SetRotation(m_farmer2.m_rot + D3DXVECTOR3(0.0f, deltaTime * 0.5f, 0.0f));
	if(m_farmer2.m_rot.y > D3DX_PI * 2.0f)m_farmer2.m_rot.y -= D3DX_PI * 2.0f;

	if(KEYDOWN(VK_DOWN))
	{
		m_farmer2.SetLOD(m_farmer2.GetNumProgressiveFaces() - 5);
		Sleep(30);
	}
	else if(KEYDOWN(VK_UP))
	{
		m_farmer2.SetLOD(m_farmer2.GetNumProgressiveFaces() + 5);
		Sleep(30);
	}
	else if(KEYDOWN('W'))
	{
		m_wireframe = !m_wireframe;
		Sleep(300);
	}
	else if(KEYDOWN(VK_ESCAPE))
		Quit();

	return S_OK;
}	
开发者ID:Alriightyman,项目名称:RTS,代码行数:34,代码来源:app.cpp

示例4: thread_function

DWORD WINAPI thread_function(LPVOID param)
{
    everquest_chat_helper_write_chat_text(APPLICATION_NAME " loaded.");
    Sleep(1000);

    while (1)
    {
        if (everquest_function_is_in_game() == false)
        {
            Sleep(100);
            continue;
        }

        if (mem.is_foreground_window_current_process_id() == true)
        {
            if
            (
                (KEYDOWN(VK_CONTROL)) &&
                (KEYDOWN(VK_ALT)) &&
                (KEYDOWN(VK_BACK))
            )
            {
                break;
            }
        }

        if
        (
            (change_height_minimum > 0) &&
            (change_height_maximum > 0)
        )
        {
            float player_height = everquest_function_get_player_height();

            if (change_height_use_minimum == true)
            {
                if (player_height < change_height_minimum)
                {
                    everquest_function_set_player_height(change_height_minimum);
                }
            }

            if (change_height_use_maximum == true)
            {
                if (player_height > change_height_maximum)
                {
                    everquest_function_set_player_height(change_height_maximum);
                }
            }
        }

        Sleep(10);
    }

    everquest_chat_helper_write_chat_text(APPLICATION_NAME " unloaded.");
    Sleep(1000);

    FreeLibraryAndExitThread(module_global, 0);
    return 0;
}
开发者ID:carriercomm,项目名称:eqmac,代码行数:60,代码来源:dllmain.cpp

示例5: main

int main(void)
{
	POINT pt;
	int i;
	int delaytime;
	int keynum;
	printf("input the delay time(ms):");
	scanf("%d",&delaytime);
	while(1) {
		switch (KEYDOWN(VK_ESCAPE)) {
		case 0:
			keybd_event(VK_NUMLOCK , 0, 0, 0);
			Sleep(delaytime / 2);
			keybd_event(VK_NUMLOCK, 0, KEYEVENTF_KEYUP, 0);
			Sleep(delaytime / 2);
			break;
		case 1:
			while (!KEYDOWN(VK_RETURN )) {
				Sleep(10);
			}
			break;
		}
	}
	return 0;
}
开发者ID:jzj1993,项目名称:KeySimulation,代码行数:25,代码来源:SimulateKeyWindows.c

示例6: GetDeviceState

 HRESULT _stdcall GetDeviceState(THIS_ DWORD a,LPVOID b) {
     //This needs to be modified to use b instead of bytes - it would save one copymemory
     BYTE bytes[256];
     HRESULT hr=RealDevice->GetDeviceState(sizeof(bytes),bytes);
     //push escape to skip the intro
     if(SkipIntro) {
         if(SkipIntro2) {
             bytes[0x01]=0x80;
             SkipIntro2=false;
         } else {
             SkipIntro2=true;
         }
     } else if(FinishedFake) {
         FinishedFake=false;
         bytes[0x29]=0x80;
     } else if(UseFakeBuffer==0) {
         //Only want to respond to keypresses if the buffer is empty
         for(BYTE b=0;b<32;b++) {
             if(FakeKeys[b].KeyCode==0) break;
             if(KEYDOWN(bytes,FakeKeys[b].KeyCode)&&!KEYDOWN(LastBytes,FakeKeys[b].KeyCode)) {
                 bytes[0x29]=0x80;
                 bytes[FakeKeys[b].KeyCode]=0x00;
                 FakeString(FakeKeys[b].chars,FakeKeys[b].data,FakeKeys[b].size);
             }
         }
     }
     ::CopyMemory(b,bytes,a);
     ::CopyMemory(LastBytes,bytes,a);
     return hr;
 }
开发者ID:angeld29,项目名称:morrgraphext,代码行数:30,代码来源:DInput+(original).cpp

示例7: D3DXVECTOR3

HRESULT APPLICATION::Update(float deltaTime)
{
	//Control camera
	m_angle += deltaTime * 0.5f;
	D3DXMATRIX  matWorld, matView, matProj;		
	D3DXVECTOR3 Eye    = D3DXVECTOR3(cos(m_angle) * 2.0f, 1.5f, sin(m_angle) * 2.0f);
	D3DXVECTOR3 Lookat = D3DXVECTOR3(0.0f, 0.5f, 0.0f);

	D3DXMatrixIdentity(&matWorld);
	D3DXMatrixLookAtLH(&matView, &Eye, &Lookat, &D3DXVECTOR3(0.0f, 1.0f, 0.0f));
	D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.3333f, 1.0f, 1000.0f );

	m_pDevice->SetTransform( D3DTS_WORLD,      &matWorld );
	m_pDevice->SetTransform( D3DTS_VIEW,       &matView );
	m_pDevice->SetTransform( D3DTS_PROJECTION, &matProj );

	if(KEYDOWN(VK_SPACE))
	{
		m_activeMesh++;
		if(m_activeMesh >= 2)m_activeMesh = 0;
		Sleep(300);
	}
	else if(KEYDOWN('W'))
	{
		m_wireframe = !m_wireframe;
		Sleep(300);
	}
	else if(KEYDOWN(VK_ESCAPE))
		Quit();

	return S_OK;
}	
开发者ID:Alriightyman,项目名称:RTS,代码行数:32,代码来源:app.cpp

示例8: HEIGHTMAP

HRESULT APPLICATION::Update(float deltaTime)
{	
	if(m_pHeightMap == NULL)		//Create Heightmap
	{
		//Load heightmap from file
		m_pHeightMap = new HEIGHTMAP(m_pDevice, INTPOINT(100, 100));
		if(FAILED(m_pHeightMap->LoadFromFile("images/abe.jpg")))
		{
			debug.Print("Failed to load from file");
			Quit();
		}

		//Create particles to visualize the heightmap
		if(FAILED(m_pHeightMap->CreateParticles()))
		{
			debug.Print("Failed to create particles");
			Quit();
		}
	}
	else
	{
		//Control camera
		m_angle += deltaTime * 0.5f;
		D3DXMATRIX  matWorld, matView, matProj;		
		D3DXVECTOR2 centre = m_pHeightMap->GetCentre();
		D3DXVECTOR3 Eye    = D3DXVECTOR3(centre.x + cos(m_angle) 
			* centre.x * 2.0f, m_pHeightMap->m_maxHeight * 8.0f, 
			-centre.y + sin(m_angle) * centre.y * 2.0f);
		D3DXVECTOR3 Lookat = D3DXVECTOR3(centre.x, 0.0f,  -centre.y);

		D3DXMatrixIdentity(&matWorld);
		D3DXMatrixLookAtLH(&matView, &Eye, &Lookat, &D3DXVECTOR3(0.0f, 1.0f, 0.0f));
		D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.3333f, 1.0f, 1000.0f );

		m_pDevice->SetTransform( D3DTS_WORLD,      &matWorld );
		m_pDevice->SetTransform( D3DTS_VIEW,       &matView );
		m_pDevice->SetTransform( D3DTS_PROJECTION, &matProj );

		//Change heightmap image
		if(KEYDOWN(VK_SPACE))
		{
			m_image++;
			if(m_image > 2)m_image = 0;
			if(m_image == 0)m_pHeightMap->LoadFromFile("images/abe.jpg");
			if(m_image == 1)m_pHeightMap->LoadFromFile("images/smiley.bmp");
			if(m_image == 2)m_pHeightMap->LoadFromFile("images/heightmap.jpg");

			m_pHeightMap->CreateParticles();
			Sleep(300);
		}
	}

	if(KEYDOWN(VK_ESCAPE))
		Quit();

	return S_OK;
}	
开发者ID:Alriightyman,项目名称:RTS,代码行数:57,代码来源:app.cpp

示例9: DoAcquire

/**
 * Function:	InputKeyboard::ProcessKBInput(...)
 * Description:	Method to see if the keyboardbuffer can be red or that a aquire is needed
 * @ param argIsToggle
 *	 Boolean to see if the key that is pressed a togglebutton is
 * @ param argKeyIsPressed
 *	 Byte containing the key that must be checked
 */
bool InputKeyboard::ProcessKBInput( byte argKeyIsPressed ) 
{ 
	if(!SUCCEEDED( dDevice->Poll() ))
	{
		DoAcquire();
	}
	
	dDevice->GetDeviceState( sizeof( keyBuffer ) , (LPVOID)&keyBuffer );

	// Check if keybuffer contains given key
	int pressed = KEYDOWN( keyBuffer, argKeyIsPressed );

	// pressed == 0 or 128 (0x80); meaning false or true
	if( pressed == 0 )
	{
		return false;
	}
	else
	{
		return true;
	}

	if (KEYDOWN( keyBuffer, DIK_W ) || KEYDOWN( keyBuffer, DIK_UP ))
		;//Move forward
	else if (KEYDOWN( keyBuffer, DIK_A || KEYDOWN( keyBuffer, DIK_LEFT )))
		;//Move left
	else if (KEYDOWN( keyBuffer, DIK_S || KEYDOWN( keyBuffer, DIK_DOWN )))
		;//Move backward
	else if (KEYDOWN( keyBuffer, DIK_D || KEYDOWN( keyBuffer, DIK_RIGHT)))
		;//Move right


}
开发者ID:Feugel,项目名称:KB01,代码行数:41,代码来源:InputKeyboard.cpp

示例10: Game_Main

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if

// clear out the back buffer
DDraw_Fill_Surface(lpddsback, 0);

// lock primary buffer
DDRAW_INIT_STRUCT(ddsd);

if (FAILED(lpddsback->Lock(NULL,&ddsd,
                           DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                           NULL)))
return(0);

// do the graphics
Draw_Polygon2D(&asteroid, (UCHAR *)ddsd.lpSurface, ddsd.lPitch);

// test for scale
if (KEYDOWN('A')) // scale up
   Scale_Polygon2D(&asteroid, 1.1, 1.1);
else
if (KEYDOWN('S')) // scale down
   Scale_Polygon2D(&asteroid, 0.9, 0.9);

// rotate the polygon by 5 degrees
Rotate_Polygon2D(&asteroid, 5);

// unlock primary buffer
if (FAILED(lpddsback->Unlock(NULL)))
   return(0);

// perform the flip
while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT)));

// wait a sec
Sleep(33);

// return success or failure or your own return code here
return(1);

} // end Game_Main
开发者ID:7er,项目名称:T3DCHAP08,代码行数:54,代码来源:demo8_5.cpp

示例11: AutoGun

//----------------------------- Update -----------------------------------
//
//  Checks for user keypresses and updates the gun's parameters accordingly
//  When the gun has been updated any active bullets are also updated.
//------------------------------------------------------------------------
void CGun::Update()
{
  //if auto gun enabled, update accordingly
  if (m_bAutoGun)
  {
    AutoGun();
    
    return;
  }

  //move gun left
  if (KEYDOWN(VK_LEFT) && (!(m_vPos.x < m_dScale)))
  {
    m_vPos.x -= CParams::dMaxTranslationPerTick;   
  }

  //move right
  if ( KEYDOWN(VK_RIGHT) && (!(m_vPos.x > CParams::WindowWidth-m_dScale)) )
  {
    m_vPos.x += CParams::dMaxTranslationPerTick;   
  }
 
  //fire
  if (KEYDOWN(VK_SPACE) && (m_iTicksToNextBullet < 0))
  {
    //create a new bullet
    for (int blt=0; blt<m_vecBullets.size(); ++blt)
    {
      //choose the first non active bullet to switch on
      if (!m_vecBullets[blt].Active())
      {
         m_vecBullets[blt].SwitchOn(m_vPos.x);

         m_iTicksToNextBullet = CParams::iFiringRate;

         break;
      }
    }
  }

  
  //now update any active bullets.
  for (int blt=0; blt<m_vecBullets.size(); ++blt)
  {
    m_vecBullets[blt].Update();
  }

  m_iTicksToNextBullet -= 1;

}
开发者ID:pxli168,项目名称:source,代码行数:55,代码来源:CGun.cpp

示例12: checkKeyboard

static void checkKeyboard()
{
    // mham fix. Patch #1378104
    UCHAR keystate[256];
    HRESULT hret = pDevices[0].device->Acquire();

    if (pDevices[0].first) {
        pDevices[0].device->GetDeviceState(256, (LPVOID)pDevices[0].data);
        pDevices[0].first = FALSE;
        return;
    }

    hret = pDevices[0].device->
           GetDeviceState(256, (LPVOID)keystate);

    if (hret == DIERR_INPUTLOST || hret == DIERR_NOTACQUIRED) {
        return;
    }

    if (hret == DI_OK) {
        for (int i = 0; i < 256; i++) {
            if (keystate[i] == pDevices[0].data[i]) continue;
            if (KEYDOWN(keystate, i)) {
                SendMessage(GetFocus(), JOYCONFIG_MESSAGE,0,i);
                break;
            }
        }
    }
    memcpy(pDevices[0].data, keystate, sizeof(UCHAR) * 256);
}
开发者ID:john-peterson,项目名称:vbam,代码行数:30,代码来源:DirectInput.cpp

示例13: ReadKeyboard

HRESULT MyInput::ReadKeyboard(){
	
	if (FAILED(pKeyboard->GetDeviceState(sizeof(keyboard), (LPVOID)&keyboard)))
		return FALSE;
	if (KEYDOWN(keyboard, DIK_LEFT)){
		if (Angle > MaxAngle) Angle -= MaxAngle + MaxAngle;
		Angle += 0.1f;
		return TRUE;
	}
	if (KEYDOWN(keyboard, DIK_RIGHT)){
		if (Angle < -MaxAngle) Angle += MaxAngle + MaxAngle;
		Angle -= 0.1f;
		return TRUE;
	}
	return TRUE;
}
开发者ID:Dargoth,项目名称:DirectX-app2,代码行数:16,代码来源:MyInput.cpp

示例14: GameLoop

VOID GameLoop()
{
	if(KEYDOWN(VK_ESCAPE))
	{
		SendMessage(g_hwnd, WM_CLOSE, 0, 0);
		return;
	}

	DDBLTFX ddbltfx;
	RECT srcRect;
	RECT destRect;
	DDRAW_INIT_STRUCT(ddbltfx);

	srcRect.left = rand() % WND_WIDTH;
	srcRect.top = rand() % WND_HEIGHT;
	srcRect.right = rand() % WND_WIDTH;
	srcRect.bottom = rand() % WND_HEIGHT;

	destRect.left = rand() % WND_WIDTH;
	destRect.top = rand() % WND_HEIGHT;
	destRect.right = rand() % WND_WIDTH;
	destRect.bottom = rand() % WND_HEIGHT;

	lpddsPrimary->Blt(&destRect, lpddsBack, &srcRect, DDBLT_WAIT, NULL);

	Sleep(30);
}
开发者ID:chengkehan,项目名称:lab,代码行数:27,代码来源:test7.cpp

示例15: if

// Keyboard interface handler
int MMU::clbkConsumeDirectKey (char *kstate)
{
	OBJHANDLE hvessel;
	if (KEYMOD_SHIFT (kstate)) 
	{
		return 0; // shift combinations are reserved
	}
	else if (KEYMOD_CONTROL (kstate)) 
	{
		// insert ctrl key combinations here
	}
	else 
	{ // unmodified keys
		if (KEYDOWN (kstate, OAPI_KEY_E)) { // "End EVA"
			if (oapiAcceptDelayedKey (OAPI_KEY_E, 1.0))
			{
				char name[256];
				char vname[256];
				UINT i;
				strcpy (vname, GetName());
				for (i=0;i<strlen(vname)+1;i++)
					name[i]=0;

				for (i=0;i<strlen(vname)-4;i++)
					name[i]=vname[i];
				//strncpy (name, vname,strlen(vname)+1-4);
				hvessel=oapiGetVesselByName(name);
				if (hvessel != 0)
					oapiSetFocusObject(hvessel);
			};
			return 1;
		}
	}
	return 0;
}
开发者ID:EbenezerEdelman,项目名称:orbiter-sdk,代码行数:36,代码来源:mmu.cpp


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