本文整理汇总了C++中getSpeed函数的典型用法代码示例。如果您正苦于以下问题:C++ getSpeed函数的具体用法?C++ getSpeed怎么用?C++ getSpeed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSpeed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChild
void Sprite3DWithSkinTest::addNewSpriteWithCoords(Vec2 p)
{
std::string fileName = "Sprite3DTest/orc.c3b";
auto sprite = EffectSprite3D::create(fileName);
sprite->setScale(3);
sprite->setRotation3D(Vec3(0,180,0));
addChild(sprite);
sprite->setPosition( Vec2( p.x, p.y) );
auto animation = Animation3D::create(fileName);
if (animation)
{
auto animate = Animate3D::create(animation);
bool inverse = (std::rand() % 3 == 0);
int rand2 = std::rand();
float speed = 1.0f;
if(rand2 % 3 == 1)
{
speed = animate->getSpeed() + CCRANDOM_0_1();
}
else if(rand2 % 3 == 2)
{
speed = animate->getSpeed() - 0.5 * CCRANDOM_0_1();
}
animate->setSpeed(inverse ? -speed : speed);
sprite->runAction(RepeatForever::create(animate));
}
}
示例2: getAddress
void SBBTA252::sendSpeedCommand(int thruster, int speed)
{
// Declare variables.
char cmd[10];
Serial::buf_send = cmd;
// Send command.
if (Serial::fd > 0)
{
cmd[0] = SBBTA252_SC;
cmd[1] = getAddress(1, thruster);
cmd[2] = getAddress(2, thruster);
cmd[3] = getSpeed(1, speed);
cmd[4] = getSpeed(2, speed);
cmd[5] = '0';
cmd[6] = '0';
cmd[7] = getChecksum(1, cmd, 10);
cmd[8] = getChecksum(2, cmd, 10);
cmd[9] = SBBTA252_EC;
Serial::length_send = 10;
send();
usleep(SBBTA252_SERIAL_DELAY);
ROS_DEBUG("Send Speed Command (%d): %s.", thruster, cmd);
}
} // end sendSpeedCommand()
示例3: getPosition
std::string Player::toString() {
std::stringstream ss ;
ss << " name: " << m_playername ;
ss << " pos: [" << getPosition().x << ", " << getPosition().y << "]" ;
ss << " speed: [" << getSpeed().x << ", " << getSpeed().y << "]";
return ss.str();
}
示例4: setSpeed
void PlayerShip::accelerate()
{
if (getSpeed() < 5.0F)
setSpeed(getSpeed() + 1.0F);
writeVelocity().x_ += cos(deg2rad(getAngle())) * getSpeed();
writeVelocity().y_ += sin(deg2rad(getAngle())) * getSpeed();
}
示例5: millis
// Implements steps according to the current speed
// You must call this at least once per step
// returns true if a step occurred
boolean EightAccelStepper::runSpeed()
{
unsigned long time = millis();
if (time > getLastStepTime() + getStepInterval())
{
if (getSpeed() > 0)
{
// Clockwise
setCurrentPos(getCurrentPos() + 1);
}
else if (getSpeed() < 0)
{
// Anticlockwise
setCurrentPos(getCurrentPos() - 1);
}
if (getPins() == 8) {
step(getCurrentPos() & 0x7); // Bottom 3 bits (same as mod 8, but works with + and - numbers)
} else {
step(getCurrentPos() & 0x3); // Bottom 2 bits (same as mod 4, but works with + and - numbers)
}
setLastStepTime(time);
return true;
}
else
return false;
}
示例6: setX
void Ball::update(double aDelta)
{
//Calculate the ball's x and y position
setX(getX() + (getDirectionX() * getSpeed() * aDelta));
setY(getY() + (getDirectionY() * getSpeed() * aDelta));
//Vertical bounds check
if(getY() - getRadius() < 0.0f)
{
//There was a collision at the top, reverse the y-direction
setY(getRadius());
setDirectionY(getDirectionY() * -1.0f);
}
else if(getY() > ScreenManager::getInstance()->getScreenHeight() - getRadius())
{
//There was a collision at the bottom, reverse the y-direction
setY(ScreenManager::getInstance()->getScreenHeight() - getRadius());
setDirectionY(getDirectionY() * -1.0f);
}
//Horizontal bounds check
if(getX() + getRadius() < 0.0f)
{
//The ball went off the left side of the screen, that means the right side scored
Game* game = (Game*)ScreenManager::getInstance()->getScreenForName(GAME_SCREEN_NAME);
game->rightGoal();
}
else if(getX() > ScreenManager::getInstance()->getScreenWidth() + getRadius())
{
//The ball went off the right side of the screen, that means the left side scored
Game* game = (Game*)ScreenManager::getInstance()->getScreenForName(GAME_SCREEN_NAME);
game->leftGoal();
}
}
示例7: globalUp
void
OpenSteer::SimpleVehicle::regenerateLocalSpaceForBanking (const Vector3& newVelocity,
const float elapsedTime)
{
// the length of this global-upward-pointing vector controls the vehicle's
// tendency to right itself as it is rolled over from turning acceleration
const Vector3 globalUp (0, 0.2f, 0);
// acceleration points toward the center of local path curvature, the
// length determines how much the vehicle will roll while turning
const Vector3 accelUp = _smoothedAcceleration * 0.05f;
// combined banking, sum of UP due to turning and global UP
const Vector3 bankUp = accelUp + globalUp;
// blend bankUp into vehicle's UP basis vector
const float smoothRate = elapsedTime * 3;
Vector3 tempUp = getUp();
blendIntoAccumulator (smoothRate, bankUp, tempUp);
setUp (tempUp.normalisedCopy());
// annotationLine (getPosition(), getPosition() + (globalUp * 4), gWhite); // XXX
// annotationLine (getPosition(), getPosition() + (bankUp * 4), gOrange); // XXX
// annotationLine (getPosition(), getPosition() + (accelUp * 4), gRed); // XXX
// annotationLine (getPosition(), getPosition() + (getUp() * 1), gYellow); // XXX
// adjust orthonormal basis vectors to be aligned with new velocity
if (getSpeed() > 0) regenerateOrthonormalBasisUF (newVelocity / getSpeed());
}
示例8: getPosition
void Projectile::moveProjectile(sf::Time dt)
{
sf::Vector2f pos = getPosition();
if (bHasTarget) {
if (!reachedTarget) {
fDistance = sqrt(pow(targetPos.x - pos.x,2) + pow(targetPos.y - pos.y,2));
//Calculate new velocity
velocity.x = getSpeed() * (targetPos.x - pos.x) / fDistance;
velocity.y = getSpeed() * (targetPos.y - pos.y) / fDistance;
if (fDistance > -1 && fDistance < 1)
{
reachedTarget = true;
resetVelocity();
}
}
}
//Rotate to face the target
float dx = targetPos.x - pos.x;
float dy = targetPos.y - pos.y;
const float Pi = 3.141;
setRotation(atan2(dy,dx) * (180 / Pi) + 90); //Calculates rotation
move(getVelocity() * dt.asSeconds());
}
示例9:
void
OpenSteer::SimpleVehicle::regenerateLocalSpace (const Vector3& newVelocity,
const float /* elapsedTime */)
{
// adjust orthonormal basis vectors to be aligned with new velocity
if (getSpeed() > 0) regenerateOrthonormalBasisUF (newVelocity / getSpeed());
}
示例10: neededLaneModeForSpeed
BcmPortGroup::LaneMode BcmPortGroup::calculateDesiredLaneMode(
const std::vector<Port*>& ports, LaneSpeeds laneSpeeds) {
auto desiredMode = LaneMode::QUAD;
for (int lane = 0; lane < ports.size(); ++lane) {
auto port = ports[lane];
if (!port->isDisabled()) {
auto neededMode = neededLaneModeForSpeed(port->getSpeed(), laneSpeeds);
if (neededMode < desiredMode) {
desiredMode = neededMode;
}
// Check that the lane is expected for SINGLE/DUAL modes
if (desiredMode == LaneMode::SINGLE) {
if (lane != 0) {
throw FbossError("Only lane 0 can be enabled in SINGLE mode");
}
} else if (desiredMode == LaneMode::DUAL) {
if (lane != 0 && lane != 2) {
throw FbossError("Only lanes 0 or 2 can be enabled in DUAL mode");
}
}
VLOG(3) << "Port " << port->getID() << " enabled with speed " <<
static_cast<int>(port->getSpeed());
}
}
return desiredMode;
}
示例11: ownerPos
void ProjectileWeapon::fireBurst()
{
if(getAmmoType()!=ammo_unlimited)
{
if(ammo==0)
return;
ammo--;
owner->weapons.updateWeapons();
}
Position ownerPos(owner->getPosition());
const Position *shotOffsets = owner->type->getWeaponMounts(numProjectiles());
doSound();
for(unsigned ii=0; ii<numProjectiles(); ii++)
if(linkedFire() || ii==fireOrder)
{
Position shotPosition(ownerPos);
shotPosition.setX(ownerPos.getX() + shotOffsets[ii].getX()*cos(ownerPos.getR()) + shotOffsets[ii].getY()*sin(ownerPos.getR()));
shotPosition.setY(ownerPos.getY() - shotOffsets[ii].getX()*sin(ownerPos.getR()) + shotOffsets[ii].getY()*cos(ownerPos.getR()));
shotPosition.setR_vel(0);
if(!shotsGetShipVel) {
shotPosition.setX_vel(0);
shotPosition.setY_vel(0);
}
shotPosition.impulse( getSpeed()*cos(shotPosition.getR()), -getSpeed()*sin(shotPosition.getR()) );
createProjectile(&shotPosition);
}
fireOrder++;
if(fireOrder >= numProjectiles())
fireOrder = 0;
}
示例12: getSpeed
void
OpenSteer::SimpleVehicle::applyBrakingForce (const float rate, const float deltaTime)
{
const float rawBraking = getSpeed() * rate;
const float clipBraking = ((rawBraking < getMaxForce()) ?
rawBraking :
getMaxForce());
setSpeed (getSpeed() - (clipBraking * deltaTime));
}
示例13: atanf
bool StrategyDown::init(void)
{
this->setSpeed(Point(10, -1.2f));
float angleRadians = atanf(getSpeed().y / getSpeed().x);
float angleDegrees = CC_RADIANS_TO_DEGREES(angleRadians);
this->setRotation(-angleDegrees);
return true;
}
示例14: setSpeed
void AObject::updateStat(Map::status status)
{
if (status == Map::SPEED)
if (getSpeed() > 0.5f)
setSpeed(getSpeed() - 0.01f);
if (status == Map::SIMULT)
setSimult(getSimult() + 1);
if (status == Map::RANGE)
setRange(getRange() + 1);
}
示例15: update
/** This function is called each timestep, and it collects most of the
* statistics for this kart.
* \param dt Time step size.
*/
void KartWithStats::update(int ticks)
{
Kart::update(ticks);
if(getSpeed()>m_top_speed ) m_top_speed = getSpeed();
float dt = stk_config->ticks2Time(ticks);
if(getControls().getSkidControl()) m_skidding_time += dt;
if(getControls().getBrake() ) m_brake_count ++;
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
if(world && !world->isOnRoad(getWorldKartId()))
m_off_track_count ++;
} // update