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


C++ ClampChar函数代码示例

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


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

示例1: CL_Xbox360ControllerMove

void CL_Xbox360ControllerMove( usercmd_t *cmd )
{
//	int     movespeed;
	float anglespeed;

	if ( !( kb[ KB_SPEED ].active ^ cl_run->integer ) )
	{
		usercmdPressButton( cmd->buttons, BUTTON_WALKING );
	}

	if ( kb[ KB_SPEED ].active )
	{
		anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
	}
	else
	{
		anglespeed = 0.001 * cls.frametime;
	}

	cl.viewangles[ PITCH ] += anglespeed * cl_pitchspeed->value * ( cl.joystickAxis[ AXIS_PITCH ] / 127.0f );
	cl.viewangles[ YAW ] += anglespeed * cl_yawspeed->value * ( cl.joystickAxis[ AXIS_YAW ] / 127.0f );

	cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[ AXIS_SIDE ] );
	cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[ AXIS_FORWARD ] );
	cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[ AXIS_UP ] );
}
开发者ID:Wattos,项目名称:Unvanquished,代码行数:26,代码来源:cl_input.c

示例2: CL_JoystickMove

/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove( usercmd_t *cmd ) {
	float	anglespeed;

	if ( !(in_speed.active ^ cl_run->integer) ) {
		cmd->buttons |= BUTTON_WALKING;
	}

	if ( in_speed.active ) {
		anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
	} else {
		anglespeed = 0.001 * cls.frametime;
	}

	if ( !in_strafe.active ) {
		cl.viewangles[YAW] += anglespeed * j_yaw->value * cl.joystickAxis[j_yaw_axis->integer];
		cmd->rightmove = ClampChar( cmd->rightmove + (int) (j_side->value * cl.joystickAxis[j_side_axis->integer]) );
	} else {
		cl.viewangles[YAW] += anglespeed * j_side->value * cl.joystickAxis[j_side_axis->integer];
		cmd->rightmove = ClampChar( cmd->rightmove + (int) (j_yaw->value * cl.joystickAxis[j_yaw_axis->integer]) );
	}

	if ( in_mlooking ) {
		cl.viewangles[PITCH] += anglespeed * j_forward->value * cl.joystickAxis[j_forward_axis->integer];
		cmd->forwardmove = ClampChar( cmd->forwardmove + (int) (j_pitch->value * cl.joystickAxis[j_pitch_axis->integer]) );
	} else {
		cl.viewangles[PITCH] += anglespeed * j_pitch->value * cl.joystickAxis[j_pitch_axis->integer];
		cmd->forwardmove = ClampChar( cmd->forwardmove + (int) (j_forward->value * cl.joystickAxis[j_forward_axis->integer]) );
	}

	cmd->upmove = ClampChar( cmd->upmove + (int) (j_up->value * cl.joystickAxis[j_up_axis->integer]) );
}
开发者ID:qrealka,项目名称:ioq3,代码行数:36,代码来源:cl_input.c

示例3: CL_Xbox360ControllerMove

void CL_Xbox360ControllerMove(usercmd_t * cmd) {
    int     movespeed;
    float   anglespeed;

    if(kb[KB_SPEED].active ^ cl_run->integer ) {
        movespeed = 2;
    }
    else {
        movespeed = 1;
        cmd->buttons |= BUTTON_WALKING;
    }

    if(kb[KB_SPEED].active) {
        anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
    }
    else {
        anglespeed = 0.001 * cls.frametime;
    }

    cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * (cl.joystickAxis[j_pitch_axis->integer] / 127.0f);
    cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * (cl.joystickAxis[j_yaw_axis->integer] / 127.0f);

    cmd->rightmove = ClampChar(cmd->rightmove + cl.joystickAxis[j_side_axis->integer]);
    cmd->forwardmove = ClampChar(cmd->forwardmove + cl.joystickAxis[j_forward_axis->integer]);
    cmd->upmove = ClampChar(cmd->upmove + cl.joystickAxis[j_up_axis->integer]);
}
开发者ID:TheDushan,项目名称:OpenWolf,代码行数:26,代码来源:cl_input.cpp

示例4: CL_JoystickMove

/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove( usercmd_t *cmd ) {
	int movespeed;
	float anglespeed;

	if ( kb[KB_SPEED].active ^ cl_run->integer ) {
		movespeed = 2;
	} else {
		movespeed = 1;
		cmd->buttons |= BUTTON_WALKING;
	}

	if ( kb[KB_SPEED].active ) {
		anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
	} else {
		anglespeed = 0.001 * cls.frametime;
	}

#ifdef __MACOS__
	cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
#else
	if ( !kb[KB_STRAFE].active ) {
		cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * cl.joystickAxis[AXIS_SIDE];
	} else {
		cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
	}
#endif
	if ( kb[KB_MLOOK].active ) {
		cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * cl.joystickAxis[AXIS_FORWARD];
	} else {
		cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
	}

	cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
}
开发者ID:chegestar,项目名称:omni-bot,代码行数:39,代码来源:cl_input.c

示例5: CL_JoystickMove

/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove( usercmd_t *cmd ) {
	int		movespeed;
	float	anglespeed;

	if ( in_speed.active ^ cl_run->integer ) {
		movespeed = 2;
	} else {
		movespeed = 1;
		cmd->buttons |= BUTTON_WALKING;
	}

	if ( in_speed.active ) {
		anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
	} else {
		anglespeed = 0.001 * cls.frametime;
	}

	if ( !in_strafe.active ) {
		cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * cl.joystickAxis[AXIS_SIDE];
	} else {
		cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
	}

	if ( in_mlooking ) {
		cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * cl.joystickAxis[AXIS_FORWARD];
	} else {
		cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
	}

	cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
}
开发者ID:Amanieu,项目名称:tremfusion,代码行数:36,代码来源:cl_input.c

示例6: CL_JoystickMove

/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove( usercmd_t *cmd ) {
	float	anglespeed;

	if ( !in_joystick->integer )
	{
		return;
	}

	if( in_joystick->integer == 2 )
	{
		if(abs(cl.joystickAxis[AXIS_FORWARD]) >= 30) cmd->forwardmove = cl.joystickAxis[AXIS_FORWARD];
		if(abs(cl.joystickAxis[AXIS_SIDE]) >= 30) cmd->rightmove = cl.joystickAxis[AXIS_SIDE];
		anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
		cl.viewangles[YAW] -= (cl_yawspeed->value / 100.0f) * (cl.joystickAxis[AXIS_YAW]/1024.0f);
		cl.viewangles[PITCH] += (cl_pitchspeed->value / 100.0f) * (cl.joystickAxis[AXIS_PITCH]/1024.0f);
	}
	else
	{
		if ( !(in_speed.active ^ cl_run->integer) ) {
			cmd->buttons |= BUTTON_WALKING;
		}

		if ( in_speed.active ) {
			anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
		} else {
			anglespeed = 0.001 * cls.frametime;
		}

		if ( !in_strafe.active ) {
			if ( cl_mYawOverride )
			{
				cl.viewangles[YAW] += 5.0f * cl_mYawOverride * cl.joystickAxis[AXIS_SIDE];
			}
			else
			{
				cl.viewangles[YAW] += anglespeed * (cl_yawspeed->value / 100.0f) * cl.joystickAxis[AXIS_SIDE];
			}
		} else
		{
			cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
		}

		if ( in_mlooking ) {
			if ( cl_mPitchOverride )
			{
				cl.viewangles[PITCH] += 5.0f * cl_mPitchOverride * cl.joystickAxis[AXIS_FORWARD];
			}
			else
			{
				cl.viewangles[PITCH] += anglespeed * (cl_pitchspeed->value / 100.0f) * cl.joystickAxis[AXIS_FORWARD];
			}
		} else {
			cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
		}

		cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
	}
}
开发者ID:Malchio,项目名称:OpenJK,代码行数:63,代码来源:cl_input.cpp

示例7: CL_MouseMove

/*
=================
CL_MouseMove
=================
*/
void CL_MouseMove( usercmd_t *cmd ) {
	float	mx, my;
	float	accelSensitivity;
	float	rate;

	// allow mouse smoothing
	if ( m_filter->integer ) {
		mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
		my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
	} else {
		mx = cl.mouseDx[cl.mouseIndex];
		my = cl.mouseDy[cl.mouseIndex];
	}
	cl.mouseIndex ^= 1;
	cl.mouseDx[cl.mouseIndex] = 0;
	cl.mouseDy[cl.mouseIndex] = 0;

	rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
	accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;

	// scale by FOV
	accelSensitivity *= cl.cgameSensitivity;

	if ( rate && cl_showMouseRate->integer ) {
		Com_Printf( "%f : %f\n", rate, accelSensitivity );
	}

	mx *= accelSensitivity;
	my *= accelSensitivity;

	if (!mx && !my) {
		return;
	}

	// add mouse X/Y movement to cmd
	if ( in_strafe.active ) {
		cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
	} else {
		// hmm inverted?!
		cl.viewangles[YAW] += m_yaw->value * mx;
	}

	if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
		cl.viewangles[PITCH] += m_pitch->value * my;
	} else {
		cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
	}
}
开发者ID:alexander-pick,项目名称:Quake3-HD--iPAD-,代码行数:53,代码来源:cl_input.c

示例8: haptic_stuff

void haptic_stuff(cvar_t sens)
{
	int i;
	if(!haptic_ok)
		return;
	dhdGetPosition(&axes[0],&axes[1],&axes[2],DHD);
	if(axes[0] == 0 && axes[1] == 0 && axes[2] == 0)
		return;
	for(i=0;i<BTN_CNT;i++)
		buf->buttons[i] = (char)(haptic_btn() == 1<<i);
	if(cnt > 0)
		cnt -= 1;
	if(buf->buttons[0] && cnt < 5)
		cnt += (rand()%5)+3;
	//haptic_print(axes,"sts");
	// 0 -> down
	// 1 -> right -> 3
	buf->views[0] = (float)axes[2] * -15.0 * sens.value;
	buf->views[1] = (float)axes[1];
	//buf->views[0] = (float)axes[2];
	//buf->views[1] = (float)axes[1];
	haptic_move(buf->views,(sens.value)*15.0);
	double Y = axes[0]*100;
	if(Y < 1.0 && Y > -1.0)
		Y = 0;
	else
		Y *= -32.0;
	buf->fmove = ClampChar(Y);
	haptic_joystick(axes,cnt);
	//haptic_force(axes);
	dhdSetForce(axes[0],axes[1],axes[2],DHD);
	return;
}
开发者ID:pvtmert,项目名称:ioq3_dhd,代码行数:33,代码来源:haptics.cpp

示例9: CL_MouseMove

static void CL_MouseMove( usercmd_t* cmd )
{
	float mx, my;

	// allow mouse smoothing
	if ( m_filter->integer ) {
		mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
		my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
	} else {
		mx = cl.mouseDx[cl.mouseIndex];
		my = cl.mouseDy[cl.mouseIndex];
	}
	cl.mouseIndex ^= 1;
	cl.mouseDx[cl.mouseIndex] = 0;
	cl.mouseDy[cl.mouseIndex] = 0;

	if (!mx && !my)
		return;

	float rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
	float speed = m_speed->value + rate * m_accel->value;

	if (m_limit->value && (speed > m_limit->value))
		speed = m_limit->value;

	// scale by FOV (+zoom only)
	speed *= cl.cgameSensitivity;

	if ( cl_showMouseRate->integer )
		Com_Printf( "%f %f : %f\n", mx, my, speed );

	mx *= speed;
	my *= speed;

	// add mouse X/Y movement to cmd
	if ( in_strafe.active ) {
		cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
	} else {
		cl.viewangles[YAW] -= m_yaw->value * mx;
	}

	if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
		cl.viewangles[PITCH] += m_pitch->value * my;
	} else {
		cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
	}
}
开发者ID:DaTa-,项目名称:cnq3x,代码行数:47,代码来源:cl_input.cpp

示例10: CL_KeyMove

/*
================
CL_KeyMove

Sets the usercmd_t based on key states
================
*/
void
CL_KeyMove(usercmd_t * cmd)
{
  int movespeed;
  int forward, side, up;

  //
  // adjust for speed key / running
  // the walking flag is to keep animations consistant
  // even during acceleration and develeration
  //
  if (in_speed.active ^ cl_run->integer)
  {
    movespeed = 127;
    cmd->buttons &= ~BUTTON_WALKING;
  }
  else
  {
    cmd->buttons |= BUTTON_WALKING;
    movespeed = 64;
  }

  forward = 0;
  side = 0;
  up = 0;
  if (in_strafe.active)
  {
    side += movespeed * CL_KeyState(&in_right);
    side -= movespeed * CL_KeyState(&in_left);
  }

  side += movespeed * CL_KeyState(&in_moveright);
  side -= movespeed * CL_KeyState(&in_moveleft);


  up += movespeed * CL_KeyState(&in_up);
  up -= movespeed * CL_KeyState(&in_down);

  forward += movespeed * CL_KeyState(&in_forward);
  forward -= movespeed * CL_KeyState(&in_back);

  cmd->forwardmove = ClampChar(forward);
  cmd->rightmove = ClampChar(side);
  cmd->upmove = ClampChar(up);
}
开发者ID:lrq3000,项目名称:ioquake3-anti-cheat,代码行数:52,代码来源:cl_input.c

示例11: CG_MouseMove

/*
=================
CG_MouseMove
=================
*/
void CG_MouseMove( localPlayer_t *player, clientInput_t *ci, usercmd_t *cmd, float mx, float my )
{
	// ingame FOV
	mx *= player->zoomSensitivity;
	my *= player->zoomSensitivity;

	// add mouse X/Y movement to cmd
	if(ci->in_strafe.active)
	{
		cmd->rightmove = ClampChar(cmd->rightmove + m_side.value * mx);
	}
	else
		player->viewangles[YAW] -= m_yaw.value * mx;

	if ((ci->in_mlooking || cg_freelook.integer) && !ci->in_strafe.active)
		player->viewangles[PITCH] += m_pitch.value * my;
	else
		cmd->forwardmove = ClampChar(cmd->forwardmove - m_forward.value * my);
}
开发者ID:KuehnhammerTobias,项目名称:ioid3-game,代码行数:24,代码来源:cg_input.c

示例12: CL_AndroidMove

void CL_AndroidMove( usercmd_t *cmd )
{

	//cmd->forwardmove += forwardmove * cl_forwardspeed->value * 2; //Always run! (x2)
	//cmd->rightmove  += sidemove   * cl_sidespeed->value * 2;
	cmd->forwardmove = ClampChar(cmd->forwardmove + forwardmove * 127 );
	cmd->rightmove = ClampChar(cmd->rightmove + sidemove * 127 );

	if ((abs(cmd->forwardmove) > 80) || (abs(cmd->rightmove) > 80))
		cmd->buttons &= ~BUTTON_WALKING;
	else
		cmd->buttons |= BUTTON_WALKING;

	switch(look_pitch_mode)
	{
	case LOOK_MODE_MOUSE:
		cl.viewangles[PITCH] += look_pitch_mouse * 300;
		look_pitch_mouse = 0;
		break;
	case LOOK_MODE_ABSOLUTE:
		cl.viewangles[PITCH] = look_pitch_abs * 80;
		break;
	case LOOK_MODE_JOYSTICK:
		cl.viewangles[PITCH] += look_pitch_joy * 6;
		break;
	}


	switch(look_yaw_mode)
	{
	case LOOK_MODE_MOUSE:
		cl.viewangles[YAW] += look_yaw_mouse * 300;
		look_yaw_mouse = 0;
		break;
	case LOOK_MODE_JOYSTICK:
		cl.viewangles[YAW] += look_yaw_joy * 6;
		break;
	}

}
开发者ID:emileb,项目名称:OpenJK,代码行数:40,代码来源:in_android.cpp

示例13: BotDirectionToUsercmd

void BotDirectionToUsercmd( gentity_t *self, vec3_t dir, usercmd_t *cmd )
{
	vec3_t forward;
	vec3_t right;

	float forwardmove;
	float rightmove;
	signed char speed = BotGetMaxMoveSpeed( self );

	AngleVectors( self->client->ps.viewangles, forward, right, nullptr );
	forward[2] = 0;
	VectorNormalize( forward );
	right[2] = 0;
	VectorNormalize( right );

	// get direction and non-optimal magnitude
	forwardmove = speed * DotProduct( forward, dir );
	rightmove = speed * DotProduct( right, dir );

	// find optimal magnitude to make speed as high as possible
	if ( Q_fabs( forwardmove ) > Q_fabs( rightmove ) )
	{
		float highestforward = forwardmove < 0 ? -speed : speed;

		float highestright = highestforward * rightmove / forwardmove;

		cmd->forwardmove = ClampChar( highestforward );
		cmd->rightmove = ClampChar( highestright );
	}
	else
	{
		float highestright = rightmove < 0 ? -speed : speed;

		float highestforward = highestright * forwardmove / rightmove;

		cmd->forwardmove = ClampChar( highestforward );
		cmd->rightmove = ClampChar( highestright );
	}
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:39,代码来源:sg_bot_nav.cpp

示例14: CL_AccelMove

/*
==============
CL_AccelMove
==============
*/
void CL_AccelMove( usercmd_t *cmd ) {
	if (!cl_accelLook->integer) {
		if ( labs( cl.accelAngles[ROLL] ) > cl_accelDeadZone->integer )
		{
			int roll = cl.accelAngles[ROLL];

			roll+= (roll > 0) ? -cl_accelDeadZone->integer : cl_accelDeadZone->integer;
			cmd->rightmove = ClampChar( cmd->rightmove + roll * cl_accelScale->value );
		}

		if ( labs( cl.accelAngles[PITCH] ) > cl_accelDeadZone->integer )
		{
			int pitch = cl.accelAngles[PITCH];

			pitch+= (pitch > 0 ) ? -cl_accelDeadZone->integer : cl_accelDeadZone->integer;
			cmd->forwardmove = ClampChar( cmd->forwardmove + pitch * cl_accelScale->value );
		}
	} else {
		// TODO: Scale by FPS:
		cl.viewangles[YAW]-= cl.accelAngles[ROLL] * cl_accelLookScale->value;
		cl.viewangles[PITCH]+= cl.accelAngles[PITCH] * cl_accelLookScale->value;
	}
}
开发者ID:alexander-pick,项目名称:Quake3-HD--iPAD-,代码行数:28,代码来源:cl_input.c

示例15: CL_JoystickMove

/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove(usercmd_t* cmd) {
    //	int             movespeed;
    float anglespeed;

    if (kb[KB_SPEED].active == (cl_run->integer != 0)) {
        usercmdPressButton(cmd->buttons, BUTTON_WALKING);
    }

    if (kb[KB_SPEED].active) {
        anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
    } else {
        anglespeed = 0.001 * cls.frametime;
    }

#ifdef __MACOS__
    cmd->rightmove = ClampChar(cmd->rightmove + cl.joystickAxis[AXIS_SIDE]);
#else

    if (!kb[KB_STRAFE].active) {
        cl.viewangles[YAW] +=
                anglespeed * j_yaw->value * cl.joystickAxis[j_yaw_axis->integer];
        cmd->rightmove =
                ClampChar(cmd->rightmove +
                          (int) (j_side->value * cl.joystickAxis[j_side_axis->integer]));
    } else {
        cl.viewangles[YAW] +=
                anglespeed * j_side->value * cl.joystickAxis[j_side_axis->integer];
        cmd->rightmove =
                ClampChar(cmd->rightmove +
                          (int) (j_yaw->value * cl.joystickAxis[j_yaw_axis->integer]));
    }

#endif

    if (kb[KB_MLOOK].active) {
        cl.viewangles[PITCH] += anglespeed * j_forward->value *
                                cl.joystickAxis[j_forward_axis->integer];
        cmd->forwardmove = ClampChar(
                cmd->forwardmove +
                (int) (j_pitch->value * cl.joystickAxis[j_pitch_axis->integer]));
    } else {
        cl.viewangles[PITCH] +=
                anglespeed * j_pitch->value * cl.joystickAxis[j_pitch_axis->integer];
        cmd->forwardmove = ClampChar(
                cmd->forwardmove +
                (int) (j_forward->value * cl.joystickAxis[j_forward_axis->integer]));
    }

    cmd->upmove = ClampChar(
            cmd->upmove + (int) (j_up->value * cl.joystickAxis[j_up_axis->integer]));
}
开发者ID:Kangz,项目名称:Unvanquished,代码行数:56,代码来源:cl_input.cpp


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