本文整理汇总了C++中CBlock::SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CBlock::SetPosition方法的具体用法?C++ CBlock::SetPosition怎么用?C++ CBlock::SetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlock
的用法示例。
在下文中一共展示了CBlock::SetPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
//=============================================================================
// 更新処理
//=============================================================================
void CGimmickBlock::Update()
{
// アントンのアドレスを取ってくる
CAnton *pAnton = CGame::GetPlayer()->GetAnton();
CBeecon *pBeecon = CGame::GetPlayer()->GetBeecon();
CBlockManager *pBlockManager = CGame::GetBlockManager();
// アントンの座標を調べる。
D3DXVECTOR3 antonPos = pAnton->GetPosition();
D3DXVECTOR3 antonPosOld = pAnton->GetPositionOld();
D3DXVECTOR3 antonSize = D3DXVECTOR3(50.0f, 60.0f, 0.0f);
D3DXVECTOR3 workPos = antonPos - antonPosOld;
D3DXVECTOR3 blockSize = D3DXVECTOR3(BLOCK_WIDTH / 2.0f, BLOCK_HEIGHT / 2.0f, 0.0f);
D3DXVECTOR3 blockPos = D3DXVECTOR3( m_pos.x, m_pos.y, 0.0f ) + blockSize;
// 木箱の判定に必要な変数
CBlock* pBlock = nullptr;
int nArrayNumX = 0, nArrayNumY = 0;
int nWorkBlockArrayNumX = 0, nWorkBlockArrayNumY = 0;
D3DXVECTOR3 underBlockPos = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 workBlockPos = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 workBlockPos2 = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
bool bCheckRightHit = false, bCheckLeftHit = false;
// ギミック系のものを更新する
switch (m_blockType)
{
case CBlock::BLOCKID_MAGNET:
// アントンがメタルの状態なら判定を行う
if (pAnton->GetState() == CAnton::STATE_METAL)
{
// マグネットブロックとメタルアントンの距離が一定の範囲内にいたら
// メタルアントンを吸い付かせる。
float fLength = sqrtf( ( blockPos.x - antonPos.x ) * ( blockPos.x - antonPos.x ) + ( blockPos.y - antonPos.y ) * ( blockPos.y - antonPos.y ) );
if ( fLength <= STICK_LENGTH )
{
if (antonPos.y + antonSize.y > blockPos.y - blockSize.y && antonPos.y < blockPos.y + blockSize.y)
{
if ( antonPos.x > blockPos.x )
{
antonPos.x += ( ( blockPos.x + blockSize.x ) - antonPos.x ) * 0.3f;
}
else if ( antonPos.x < blockPos.x )
{
antonPos.x += ( ( blockPos.x - blockSize.x ) - antonPos.x ) * 0.3f;
}
}
else if ( antonPos.y > blockPos.y )
{
antonPos.x += (blockPos.x - antonPos.x) * 0.3f;
antonPos.y += (blockPos.y - antonPos.y) * 0.3f;
}
else if (antonPos.y < blockPos.y)
{
antonPos.x += (blockPos.x - antonPos.x) * 0.3f;
}
pAnton -> SetPosition( antonPos );
//CManager::GetSoundXAudio2()->Play(CSoundXAudio2::SL_SE_MAGNET);
}
}
break;
case CBlock::BLOCKID_WOODBOX:
// ぶつかっており、パワフルアントンに変化していたら処理を行う
if (blockPos.y - blockSize.y < antonPos.y + antonSize.y && blockPos.y + blockSize.y > antonPos.y - antonSize.y
&& blockPos.x - blockSize.x < antonPos.x + ( antonSize.x * 1.65f ) && blockPos.x + blockSize.x > antonPos.x
&& (blockPos.x - blockSize.x ) - ( antonPos.x + antonSize.x ) < BLOCK_WIDTH
&& (blockPos.x - blockSize.x) - (antonPos.x + antonSize.x) >= WOODBOX_MOVE
&& pAnton->GetState() == CAnton::STATE_POWERFUL)
{
blockPos.x += WOODBOX_MOVE;
bCheckRightHit = true;
pAnton->SetAction(CAnton::ACTION_PUSH);
PlaySeBoxSlip();
}
else if (blockPos.y - blockSize.y < antonPos.y + antonSize.y && blockPos.y + blockSize.y > antonPos.y - antonSize.y
&& blockPos.x - blockSize.x < antonPos.x + ( antonSize.x * 1.65f ) && blockPos.x + blockSize.x > antonPos.x
&& (blockPos.x + blockSize.x) - (antonPos.x) > -BLOCK_WIDTH
&& (blockPos.x - blockSize.x) - (antonPos.x + antonSize.x) <= -WOODBOX_MOVE
&& pAnton->GetState() == CAnton::STATE_POWERFUL)
{
blockPos.x -= WOODBOX_MOVE;
bCheckLeftHit = true;
pAnton->SetAction(CAnton::ACTION_PUSH);
//.........这里部分代码省略.........