本文整理汇总了C++中getSpeed函数的典型用法代码示例。如果您正苦于以下问题:C++ getSpeed函数的具体用法?C++ getSpeed怎么用?C++ getSpeed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSpeed函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
}
开发者ID:EduardovEduard,项目名称:Spike,代码行数:30,代码来源:Sprite3DTest.cpp
示例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()
开发者ID:Anuragch,项目名称:stingray-3-0,代码行数:26,代码来源:sbBTA252-1.cpp
示例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();
}
开发者ID:mstroud,项目名称:MoveCircle,代码行数:7,代码来源:Player.cpp
示例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();
}
开发者ID:stuckie,项目名称:ludumdare,代码行数:7,代码来源:PlayerShip.cpp
示例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;
}
开发者ID:sammchardy,项目名称:EightAccelStepper,代码行数:31,代码来源:EightAccelStepper.cpp
示例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();
}
}
开发者ID:bouc0277,项目名称:Assignment-2.1,代码行数:34,代码来源:Ball.cpp
示例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());
}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:29,代码来源:SimpleVehicle.cpp
示例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());
}
开发者ID:rzsavilla,项目名称:miniLD62,代码行数:33,代码来源:Projectile.cpp
示例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());
}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:7,代码来源:SimpleVehicle.cpp
示例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;
}
开发者ID:HengWang,项目名称:fboss,代码行数:28,代码来源:BcmPortGroup.cpp
示例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;
}
开发者ID:yixu34,项目名称:Mastrix,代码行数:35,代码来源:weapons.cpp
示例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));
}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:10,代码来源:SimpleVehicle.cpp
示例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;
}
开发者ID:flybird,项目名称:Seminar,代码行数:10,代码来源:StrategyDown.cpp
示例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);
}
开发者ID:RavivarmanPerinpanathan,项目名称:Bomberman,代码行数:10,代码来源:AObject.cpp
示例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
开发者ID:toymak3r,项目名称:Beyond-The-Mirror---Weird-Rancing-Game,代码行数:15,代码来源:kart_with_stats.cpp
示例16: getSpeed
void Hanger::setMovePostion(GameControl * _gameControl)
{
//unsigned char res = 0;
#ifdef GOLDEN_MINER_2_VERSION_TIME
double speed = getSpeed() / HANGER_SPEED_CONTROL * Global::getInstance()->getTimeRatio();
#else
double speed = getSpeed() / HANGER_SPEED_CONTROL;
#endif
double speedX = 0;
double speedY = 0;
if((status == HANGER_STATUS_PULL_UNHAVING) || (status == HANGER_STATUS_PULL_HAVING))
{
speedX = speed * cos((angle - angleChange) / angleChange * pi);
speedY = speed * sin((angle - angleChange) / angleChange * pi);
currX += speedX;
currY += speedY;
if(currY >= y)
{
// 收回
//setStatus(HANGER_STATUS_SWAYING_STOP_THROW);
//Global::getInstance()->setHangerCanThrow(canThrow);
currX = x;
currY = y;
if (status == HANGER_STATUS_PULL_HAVING)
{
_gameControl->addExplode(HANGER_GOT_AWARD, currX, currY);
}
tmpStatusTimeCount = HANGER_SWAP_STOP_THROW_TIME;
setStatus(HANGER_STATUS_SWAYING);
}
}
else
{
speedX = speed * cos(angle / angleChange * pi);
speedY = speed * sin(angle / angleChange * pi);
currX += speedX;
currY += speedY;
if((currY < 0) || (currX < 0) || (currX > CCDirector::sharedDirector()->getWinSize().width))
{
// 放空
Player::getInstance()->getMusicControl()->stopEffect(MUSICCONTROL_EFFECT_ID_THROW);
setStatus(HANGER_STATUS_PULL_UNHAVING);
}
}
setPosition(CCPoint(currX, currY));
//Global::getInstance()->setHangerCurrX(currX);
//Global::getInstance()->setHangerCurrY(currY);
//return res;
}
开发者ID:wjf1616,项目名称:TheMiners,代码行数:54,代码来源:Hanger.cpp
示例17: 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(float dt)
{
Kart::update(dt);
if(getSpeed()>m_top_speed) m_top_speed = getSpeed();
if(getControls().m_skid)
m_skidding_time += dt;
if(getControls().m_brake)
m_brake_count ++;
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
if(world && !world->isOnRoad(getWorldKartId()))
m_off_track_count ++;
} // update
开发者ID:kiennguyen1994,项目名称:game-programming-cse-hcmut-2012,代码行数:16,代码来源:kart_with_stats.cpp
示例18: getPosition
void DynamicObject::update(double time)
{
float deltaX, deltaY, deltaZ;
deltaX = getPosition()->getX();
deltaY = getPosition()->getY();
deltaZ = getPosition()->getZ();
deltaX = (deltaX + cos(getAngle()* PI / 180)* getSpeed() * time + 0.5 * getAcelaration() * time *time);
deltaY = (deltaY + sin(getAngle()* PI / 180)* getSpeed() * time + 0.5 * getAcelaration() * time *time);
setPosition(deltaX, deltaY, deltaZ);
getHitBox()->setPosition(deltaX, deltaY, deltaZ);
}
开发者ID:Gisson,项目名称:micro-machines,代码行数:13,代码来源:DynamicObject.cpp
示例19: main
int main()
{
// Handle CTLR + C
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = handleSignal;
sigemptyset(&sigIntHandler.sa_mask);
sigaction(SIGINT, &sigIntHandler, NULL);
quit = false;
auto lead = new car("lead");
auto follower = new car("follower");
auto controller = new pidController();
follower->setSpeed(0);
lead->setSpeed(0);
controller->setSetPoint(lead->getSpeed());
controller->setKi(1);
controller->setKd(1);
controller->setKp(.2);
auto pvThread = std::thread(runPv, controller);
auto pidThread = std::thread(runPid, controller);
auto simThread = std::thread(runSim, lead, follower, controller);
std::random_device rd; // only used once to initialise (seed) engine
std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case)
std::uniform_int_distribution<int> uni(0,4); // guaranteed unbiased
while (!quit)
{
int randomSpeed = uni(rng);
lead->setSpeed(randomSpeed);
controller->setSetPoint(lead->getSpeed());
sleepSim(2);
}
pvThread.join();
simThread.join();
pidThread.join();
delete lead;
delete follower;
delete controller;
return 0;
}
开发者ID:slater1,项目名称:AdaptiveCruiseControl,代码行数:49,代码来源:main.cpp
示例20: FbossError
BcmPortGroup::LaneMode BcmPortGroup::getDesiredLaneMode(
const std::shared_ptr<SwitchState>& state) const {
std::vector<Port*> ports;
for (auto bcmPort : allPorts_) {
auto swPort = bcmPort->getSwitchStatePort(state).get();
// Make sure the ports support the configured speed.
// We check this even if the port is disabled.
if (!bcmPort->supportsSpeed(swPort->getSpeed())) {
throw FbossError("Port ", swPort->getID(), " does not support speed ",
static_cast<int>(swPort->getSpeed()));
}
ports.push_back(swPort);
}
return calculateDesiredLaneMode(ports, controllingPort_->maxLaneSpeed());
}
开发者ID:coxley,项目名称:fboss,代码行数:15,代码来源:BcmPortGroup.cpp
注:本文中的getSpeed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论