本文整理汇总了C++中speed函数的典型用法代码示例。如果您正苦于以下问题:C++ speed函数的具体用法?C++ speed怎么用?C++ speed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了speed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void Client::sendPlayerPos()
{
LocalPlayer *myplayer = m_env.getLocalPlayer();
if(myplayer == NULL)
return;
// Save bandwidth by only updating position when something changed
if(myplayer->last_position == myplayer->getPosition() &&
myplayer->last_speed == myplayer->getSpeed() &&
myplayer->last_pitch == myplayer->getPitch() &&
myplayer->last_yaw == myplayer->getYaw() &&
myplayer->last_keyPressed == myplayer->keyPressed)
return;
myplayer->last_position = myplayer->getPosition();
myplayer->last_speed = myplayer->getSpeed();
myplayer->last_pitch = myplayer->getPitch();
myplayer->last_yaw = myplayer->getYaw();
myplayer->last_keyPressed = myplayer->keyPressed;
u16 our_peer_id;
{
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
our_peer_id = m_con.GetPeerID();
}
// Set peer id if not set already
if(myplayer->peer_id == PEER_ID_INEXISTENT)
myplayer->peer_id = our_peer_id;
assert(myplayer->peer_id == our_peer_id);
v3f pf = myplayer->getPosition();
v3f sf = myplayer->getSpeed();
s32 pitch = myplayer->getPitch() * 100;
s32 yaw = myplayer->getYaw() * 100;
u32 keyPressed = myplayer->keyPressed;
v3s32 position(pf.X*100, pf.Y*100, pf.Z*100);
v3s32 speed(sf.X*100, sf.Y*100, sf.Z*100);
/*
Format:
[0] v3s32 position*100
[12] v3s32 speed*100
[12+12] s32 pitch*100
[12+12+4] s32 yaw*100
[12+12+4+4] u32 keyPressed
*/
NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4);
pkt << position << speed << pitch << yaw << keyPressed;
Send(&pkt);
}
示例2: switch
void frog::keyup(unsigned char key) {
switch (key) {
case 'o':
speed().x() += SPEED_X;
orientation_ -= 45;
break;
case 'p':
speed().x() -= SPEED_X;
orientation_ += 45;
break;
case 'q':
speed().z() += SPEED_Z;
break;
case 'a':
speed().z() -= SPEED_Z;
break;
default:
break;
}
}
示例3: main
int main(void)
{
init_MCU();
LED_R_ON;
speed(0,0);
while(1)
{
ctrrobot();
}
}
示例4: TEST
TEST(ValidMoveRightTest, ValidMoveReturnsSameMoveIfItIsValid){
std::list<Position> allPosns;
allPosns.push_back(Position(Vector2(0, 0), 50, 50));
ValidMove validity(Position(Vector2(0, 0), 500, 500), allPosns);
Vector2 speed(25, 0);
Position nextMove(Vector2(25, 0), 50, 50);
Position validMove = validity.getValidMove(Position(Vector2(0, 0), 50, 50), speed);
EXPECT_EQ(validMove, nextMove);
}
示例5: fillCubeArray
void Loadbar::createAnimation()
{
fillCubeArray(0x00);
for (quint8 i = 0; i < CUBE_SIZE; i++)
{
setPlane(m_axis, i);
if(m_abort)
return;
waitMs(speed());
}
waitMs(speed() * 2);
for (quint8 i = 0; i < CUBE_SIZE; i++)
{
clearPlane(m_axis, i);
if(m_abort)
return;
waitMs(speed());
}
Q_EMIT done();
}
示例6: speed
uint8 CPU::op_read(uint32 addr) {
debugger.op_read(addr);
status.clock_count = speed(addr);
dma_edge();
add_clocks(status.clock_count - 4);
regs.mdr = bus.read(addr);
add_clocks(4);
alu_edge();
return regs.mdr;
}
示例7: variable
/* ARGSUSED */
void
variable(int cc)
{
char buf[256];
if (prompt("[set] ", buf, sizeof (buf)))
return;
vlex(buf);
if (vtable[BEAUTIFY].v_access&CHANGED) {
vtable[BEAUTIFY].v_access &= ~CHANGED;
(void) kill(pid, SIGSYS);
}
if (vtable[SCRIPT].v_access&CHANGED) {
vtable[SCRIPT].v_access &= ~CHANGED;
setscript();
/*
* So that "set record=blah script" doesn't
* cause two transactions to occur.
*/
if (vtable[RECORD].v_access&CHANGED)
vtable[RECORD].v_access &= ~CHANGED;
}
if (vtable[RECORD].v_access&CHANGED) {
vtable[RECORD].v_access &= ~CHANGED;
if (boolean(value(SCRIPT)))
setscript();
}
if (vtable[TAND].v_access&CHANGED) {
vtable[TAND].v_access &= ~CHANGED;
if (boolean(value(TAND)))
tandem("on");
else
tandem("off");
}
if (vtable[LECHO].v_access&CHANGED) {
vtable[LECHO].v_access &= ~CHANGED;
boolean(value(HALFDUPLEX)) = boolean(value(LECHO));
}
if (vtable[PARITY].v_access&CHANGED) {
vtable[PARITY].v_access &= ~CHANGED;
setparity(NULL);
}
if (vtable[BAUDRATE].v_access&CHANGED) {
vtable[BAUDRATE].v_access &= ~CHANGED;
ttysetup(speed(number(value(BAUDRATE))));
}
if (vtable[HARDWAREFLOW].v_access & CHANGED) {
vtable[HARDWAREFLOW].v_access &= ~CHANGED;
if (boolean(value(HARDWAREFLOW)))
hardwareflow("on");
else
hardwareflow("off");
}
}
示例8: main
int main(){
long n(0), k(0); scanf("%ld %ld\n", &n, &k);
std::vector<long> speed(n,0);
for(int p = 0; p < n; p++){scanf("%ld", &speed[p]);}
std::sort(speed.begin(), speed.end());
printf("%ld\n", speed[n - k]);
return 0;
}
示例9: Q_D
void KJob::emitSpeed(unsigned long value)
{
Q_D(KJob);
if (!d->speedTimer) {
d->speedTimer = new QTimer(this);
connect(d->speedTimer, SIGNAL(timeout()), SLOT(_k_speedTimeout()));
}
emit speed(this, value);
d->speedTimer->start(5000); // 5 seconds interval should be enough
}
示例10: rodConfig
void T12SuperBallPayload::setup(tgWorld& world)
{
const tgRod::Config rodConfig(c.radius, c.density, c.friction,
c.rollFriction, c.restitution);
/// @todo acceleration constraint was removed on 12/10/14 Replace with tgKinematicActuator as appropreate
tgBasicActuator::Config muscleConfig(c.stiffness, c.damping, c.pretension,
c.history, c.maxTens, c.targetVelocity);
// Start creating the structure
tgStructure s;
addNodes(s);
addRods(s);
addMuscles(s);
// // Add a rotation. This is needed if the ground slopes too much,
// // otherwise glitches put a rod below the ground.
// btVector3 rotationPoint = btVector3(0, 0, 0); // origin
// btVector3 rotationAxis = btVector3(0, 1, 0); // y-axis
// double rotationAngle = M_PI/2;
// s.addRotation(rotationPoint, rotationAxis, rotationAngle);
//s.move(btVector3(0,30,0));
// Create the build spec that uses tags to turn the structure into a real model
tgBuildSpec spec;
spec.addBuilder("rod", new tgRodInfo(rodConfig));
spec.addBuilder("muscle", new tgBasicActuatorInfo(muscleConfig));
// Create your structureInfo
tgStructureInfo structureInfo(s, spec);
// Use the structureInfo to build ourselves
structureInfo.buildInto(*this, world);
// We could now use tgCast::filter or similar to pull out the
// models (e.g. muscles) that we want to control.
allMuscles = tgCast::filter<tgModel, tgBasicActuator> (getDescendants());
// call the onSetup methods of all observed things e.g. controllers
notifySetup();
// Actually setup the children
tgModel::setup(world);
//map the rods and add the markers to them
addMarkers(s);
btVector3 location(0,10.0,0);
btVector3 rotation(0.0,0.6,0.8);
btVector3 speed(0,20,100);
this->moveModel(location,rotation,speed);
}
示例11: speed
void KPrPageEffect::saveOdfSmilAttributes( KoGenStyle & style ) const
{
QString speed("slow");
if (m_duration < 2500) {
speed = "fast";
}
else if (m_duration < 7500) {
speed = "medium";
}
style.addProperty("presentation:transition-speed", speed);
return m_strategy->saveOdfSmilAttributes(style);
}
示例12: speed
void Ship::fire(std::vector<Shoot>&salvo, Fleet *enemy)
{
double ourspeed = speed();
for (auto weapon : weapons)
{
std::shared_ptr<Weapon> gun = weapon.lock();
if (gun)
{
gun->fire(salvo, enemy, ourspeed);
}
}
}
示例13: main
int main(){
double V0x,V0y,h,t,h0;
printf("h:\n");
scanf("%lf",&h0);
printf("V0y:\n");
scanf("%lf",&V0y);
t=0;
h=0;
while(h>=0){
h=h0-dist(V0y,t);
printf("t=%lf Speed=%lf h=%lf",t,speed(V0y,t),h);
usleep(100);
t=t+0.0001;
fflush(stdout);
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
}
printf("t=%lf Speed=%lf h=%lf\n",t,speed(V0y,t),h);
}
示例14: speed
void Car::update(double delta_t) {
bool pressed = false;
_acceleration = 0;
Vector3 speed(cos((_turnAngle)*(PI / 180)), sin((_turnAngle)*(PI / 180)), 0);
if (upKeyPressed) {
pressed = true;
_acceleration = FORWARD_ACCELERATION;
if (_currentSpeed + (delta_t * _acceleration) < MAX_FORWARD_SPEED) {
_currentSpeed = _currentSpeed + (delta_t * _acceleration);
}
else {
_currentSpeed = MAX_FORWARD_SPEED;
}
}
else if (downKeyPressed) {
pressed = true;
_acceleration = -BACKWARDS_ACCELERATION;
if (_currentSpeed + (delta_t * _acceleration) > -MAX_BACKWARDS_SPEED) {
_currentSpeed = _currentSpeed + (delta_t * _acceleration);
}
else {
_currentSpeed = -MAX_BACKWARDS_SPEED;
}
}
if (leftKeyPressed) {
_turnAngle += ANGLE_INCREASE;
}
if (rightKeyPressed) {
_turnAngle -= ANGLE_INCREASE;
}
if (!pressed) {
if (_currentSpeed > 0) {
if (_currentSpeed - (delta_t)* 0.0005 > 0) {
_currentSpeed -= (delta_t)* 0.0005;
}
else {
_currentSpeed = 0;
}
}
else if (_currentSpeed < 0) {
if (_currentSpeed + (delta_t)* FRICTION < 0) {
_currentSpeed += (delta_t)* FRICTION;
}
else {
_currentSpeed = 0;
}
}
}
_speed = speed * _currentSpeed;
_position = (_position + _speed);
}
示例15: do_ball
int do_ball(int cn,int x,int y)
{
int dir;
if (cn<1 || cn>=MAXCHARS) { error=ERR_ILLEGAL_CHARNO; return 0; }
if (ch[cn].flags&(CF_DEAD)) { error=ERR_DEAD; return 0; }
if ((ch[cn].flags&CF_NOMAGIC) && !(ch[cn].flags&CF_NONOMAGIC)) { error=ERR_UNCONCIOUS; return 0; }
if (warcried(cn)) { error=ERR_UNCONCIOUS; return 0; }
if (!ch[cn].value[0][V_FLASH]) { error=ERR_UNKNOWN_SPELL; return 0; }
if (x<1 || x>=MAXMAP-1 || y<1 || y>=MAXMAP-1) { error=ERR_ILLEGAL_COORDS; return 0; }
if (ch[cn].mana<FLASHCOST) { error=ERR_MANA_LOW; return 0; }
dir=offset2dx(ch[cn].x,ch[cn].y,x,y);
if (!dir) {
if (!may_add_spell(cn,IDR_FLASH)) { error=ERR_ALREADY_WORKING; return 0; }
ch[cn].action=AC_FLASH;
ch[cn].duration=speed(ch[cn].value[0][V_SPEED],ch[cn].speed_mode,DUR_MAGIC_ACTION);
ch[cn].dir=bigdir(ch[cn].dir);
} else {
ch[cn].action=AC_BALL1;
ch[cn].act1=x;
ch[cn].act2=y;
ch[cn].duration=speed(ch[cn].value[0][V_SPEED],ch[cn].speed_mode,DUR_MAGIC_ACTION/2);
ch[cn].dir=dir;
}
ch[cn].mana-=FLASHCOST;
if (ch[cn].speed_mode==SM_FAST) ch[cn].endurance-=end_cost(cn);
return 1;
}