本文整理汇总了C++中idCVar::SetFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ idCVar::SetFloat方法的具体用法?C++ idCVar::SetFloat怎么用?C++ idCVar::SetFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idCVar
的用法示例。
在下文中一共展示了idCVar::SetFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateGame
/*
=============================
idGameBearShootWindow::UpdateGame
=============================
*/
void idGameBearShootWindow::UpdateGame() {
int i;
if ( onNewGame ) {
ResetGameState();
if ( goal ) {
goal->position.x = 550;
goal->position.y = 164;
goal->velocity.Zero();
}
if ( helicopter ) {
helicopter->position.x = 550;
helicopter->position.y = 100;
helicopter->velocity.Zero();
}
if ( bear ) {
bear->SetVisible( false );
}
bearTurretAngle.SetFloat( 0.f );
bearTurretForce.SetFloat( 200.f );
gamerunning = true;
}
if ( onContinue ) {
gameOver = false;
timeRemaining = 60.f;
onContinue = false;
}
if(gamerunning == true) {
int current_time = gui->GetTime();
idRandom rnd( current_time );
// Check for button presses
UpdateButtons();
if ( bear ) {
UpdateBear();
}
if ( helicopter && goal ) {
UpdateHelicopter();
}
// Update Wind
if ( windUpdateTime < current_time ) {
float scale;
int width;
windForce = rnd.CRandomFloat() * ( MAX_WINDFORCE * 0.75f );
if (windForce > 0) {
windForce += ( MAX_WINDFORCE * 0.25f );
wind->rotation = 0;
} else {
windForce -= ( MAX_WINDFORCE * 0.25f );
wind->rotation = 180;
}
scale = 1.f - (( MAX_WINDFORCE - idMath::Fabs(windForce) ) / MAX_WINDFORCE);
width = 100*scale;
if ( windForce < 0 ) {
wind->position.x = 500 - width + 1;
} else {
wind->position.x = 500;
}
wind->SetSize( width, 40 );
windUpdateTime = current_time + 7000 + rnd.RandomInt(5000);
}
// Update turret rotation angle
if ( turret ) {
turretAngle = bearTurretAngle.GetFloat();
turret->rotation = turretAngle;
}
for( i = 0; i < entities.Num(); i++ ) {
entities[i]->Update( timeSlice );
}
// Update countdown timer
timeRemaining -= timeSlice;
timeRemaining = idMath::ClampFloat( 0.f, 99999.f, timeRemaining );
gui->SetStateString( "time_remaining", va("%2.1f", timeRemaining ) );
if ( timeRemaining <= 0.f && !gameOver ) {
gameOver = true;
updateScore = true;
}
if ( updateScore ) {
UpdateScore();
updateScore = false;
//.........这里部分代码省略.........
示例2: AdjustOption
/*
========================
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustField
========================
*/
void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustField( const int fieldIndex, const int adjustAmount )
{
switch( fieldIndex )
{
case SYSTEM_FIELD_FRAMERATE:
{
static const int numValues = 2;
static const int values[numValues] = { 60, 120 };
com_engineHz.SetInteger( AdjustOption( com_engineHz.GetInteger(), values, numValues, adjustAmount ) );
break;
}
case SYSTEM_FIELD_VSYNC:
{
static const int numValues = 3;
static const int values[numValues] = { 0, 1, 2 };
r_swapInterval.SetInteger( AdjustOption( r_swapInterval.GetInteger(), values, numValues, adjustAmount ) );
break;
}
case SYSTEM_FIELD_ANTIALIASING:
{
// RB: disabled 16x MSAA
static const int numValues = 4;
static const int values[numValues] = { 0, 2, 4, 8 };
// RB end
r_multiSamples.SetInteger( AdjustOption( r_multiSamples.GetInteger(), values, numValues, adjustAmount ) );
break;
}
case SYSTEM_FIELD_MOTIONBLUR:
{
static const int numValues = 5;
static const int values[numValues] = { 0, 2, 3, 4, 5 };
r_motionBlur.SetInteger( AdjustOption( r_motionBlur.GetInteger(), values, numValues, adjustAmount ) );
break;
}
// RB begin
case SYSTEM_FIELD_SHADOWMAPPING:
{
static const int numValues = 2;
static const int values[numValues] = { 0, 1 };
r_useShadowMapping.SetInteger( AdjustOption( r_useShadowMapping.GetInteger(), values, numValues, adjustAmount ) );
break;
}
/*case SYSTEM_FIELD_LODBIAS:
{
const float percent = LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f );
const float adjusted = percent + ( float )adjustAmount * 5.0f;
const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted );
r_lodBias.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, -1.0f, 1.0f ) );
break;
}*/
// RB end
case SYSTEM_FIELD_BRIGHTNESS:
{
const float percent = LinearAdjust( r_lightScale.GetFloat(), 2.0f, 4.0f, 0.0f, 100.0f );
const float adjusted = percent + ( float )adjustAmount;
const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted );
r_lightScale.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, 2.0f, 4.0f ) );
break;
}
case SYSTEM_FIELD_VOLUME:
{
const float percent = 100.0f * Square( 1.0f - ( s_volume_dB.GetFloat() / DB_SILENCE ) );
const float adjusted = percent + ( float )adjustAmount;
const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted );
s_volume_dB.SetFloat( DB_SILENCE - ( idMath::Sqrt( clamped / 100.0f ) * DB_SILENCE ) );
break;
}
}
cvarSystem->ClearModifiedFlags( CVAR_ARCHIVE );
}