本文整理汇总了C++中Coordinate::GetMagnitude方法的典型用法代码示例。如果您正苦于以下问题:C++ Coordinate::GetMagnitude方法的具体用法?C++ Coordinate::GetMagnitude怎么用?C++ Coordinate::GetMagnitude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Coordinate
的用法示例。
在下文中一共展示了Coordinate::GetMagnitude方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Play
/**\brief Plays the sound at a specified coordinate from origin.
*/
bool Sound::Play( Coordinate offset ){
if ( this->sound == NULL )
return false;
// Distance fading
double dist = this->fadefactor * offset.GetMagnitude();
if ( dist > 255 )
return false; // Sound is out of range
Uint8 sounddist = static_cast<Uint8>( dist );
// Left-Right panning
float panx = this->panfactor * static_cast<float>(offset.GetX())+127.f;
Uint8 soundpan = 127;
if ( panx < 0 )
soundpan = 0;
else if ( panx > 254 )
soundpan = 254;
else
soundpan = static_cast<Uint8>( panx );
int freechan = Audio::Instance().GetFreeChannel();
if( Mix_SetDistance( freechan, sounddist ) == 0 )
LogMsg(ERR,"Set distance %d failed on channel %d.", sounddist, freechan );
//else
// LogMsg(INFO,"Distance set to %d on channel %d.", sounddist, freechan );
/**\bug SDL_mixer bug possibly: Need to check whether SDL_mixer is getting
* Left/Right speaker switched around.
*/
if( Mix_SetPanning( freechan, 254 - soundpan, soundpan ) == 0 )
LogMsg(ERR,"Set panning %d failed on channel %d.", soundpan - 127, freechan );
//else
// LogMsg(INFO,"Panning set to %d on channel %d.", soundpan - 127, freechan );
Mix_Volume( freechan, this->volume );
this->channel = Audio::Instance().PlayChannel( freechan, this->sound, 0 );
if ( channel == -1 )
return false;
return true;
}