• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setVelocity函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setVelocity

void Simulation::setVelocity(const Vec3f& v1) {
  setVelocity(v1, Vec3f(0,0,0));
}
开发者ID:evanminto,项目名称:tectonic-terrain,代码行数:3,代码来源:Simulation.cpp


示例2: getPhysicsBody

void Ball::increaseVelocity() {
  auto body = getPhysicsBody();
  body->setVelocity(body->getVelocity() * VELOCITY_INCREASE);
}
开发者ID:changbiao,项目名称:cocos2d-x-pong-cpp,代码行数:4,代码来源:Ball.cpp


示例3: rand

void GiantSlimeEntity::animate(float delay)
{
  slimeTimer -= delay;
  if (slimeTimer <= 0.0f)
  {
    slimeTypeEnum slimeType = SlimeTypeStandard;
    if (game().isAdvancedLevel())
    {
      slimeType =  (slimeTypeEnum)(slimeType + rand() % 3);
    }
    switch (slimeCounter)
    {
    case 0:
      new SlimeEntity(TILE_WIDTH * 1.5f, TILE_HEIGHT * 1.5f, slimeType, true);
      break;
    case 1:
      new SlimeEntity(TILE_WIDTH * (MAP_WIDTH - 2) + TILE_WIDTH * 0.5f, TILE_HEIGHT * 1.5f, slimeType, true);
      break;
    case 2:
      new SlimeEntity(TILE_WIDTH * (MAP_WIDTH - 2) + TILE_WIDTH * 0.5f, TILE_HEIGHT * (MAP_HEIGHT - 2) + TILE_HEIGHT * 0.5f, slimeType, true);
      break;
    case 3:
      new SlimeEntity(TILE_WIDTH * 1.5f, TILE_HEIGHT * (MAP_HEIGHT - 2) + TILE_HEIGHT * 0.5f, slimeType, true);
      break;
    }
    slimeTimer = 7.0f;
    slimeCounter ++;
    if (slimeCounter == 4) slimeCounter = 0;
  }

  if (age <= 0.0f)
  {
    age += delay;
    return;
  }
  EnemyEntity::animate(delay);
  if (specialState[SpecialStateIce].active) delay *= specialState[SpecialStateIce].param1;

  timer -= delay;
  if (timer <= 0.0f)
  {
    if (state == 0) // walking
    {
      counter--;
      if (counter >= 0)
      {
        timer = 0.5f;
        if (hp <= hpMax / 4)
          creatureSpeed = GIANT_SLIME_SPEED * 1.4f;
        if (hp <= hpMax / 2)
          creatureSpeed = GIANT_SLIME_SPEED * 1.2f;
        else
          creatureSpeed = GIANT_SLIME_SPEED;

        setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), GIANT_SLIME_SPEED ));
      }
      else
      {
        int r = rand() % 3;
        if (r == 0) changeToState(1);
        else if (r == 1) changeToState(3);
        else changeToState(5);
      }
    }
    else if (state == 1) // waiting for jumping
    {
      changeToState(2);
    }
    else if (state == 2) // jumping
    {
      changeToState(8);
    }
    else if (state == 3)
    {
      changeToState(4);
    }
    else if (state == 4) // walking
    {
      counter--;
      if (counter >= 0)
      {
        if (hp <= hpMax / 4)
          timer = missileDelay * 0.6f;
        if (hp <= hpMax / 2)
          timer = missileDelay * 0.8f;
        else
          timer = missileDelay;
        fire();
      }
      else
      {
        changeToState(8);
      }
    }
    else if (state == 5)
    {
      changeToState(6);
    }
    else if (state == 6)  // jump
    {
//.........这里部分代码省略.........
开发者ID:Cirrus-Minor,项目名称:witchblast,代码行数:101,代码来源:GiantSlimeEntity.cpp


示例4: rand

void Robot::setRandDirection()
{
	int randAngle = rand() % 360;
	setVelocity(Vector3(1, 0, 0).GetRotatedY(randAngle));
  setRotation(Vector3(0, -randAngle+90.f, 0));
}
开发者ID:MHDante,项目名称:CPS511_Assignment1,代码行数:6,代码来源:Robot.cpp


示例5: switch

void SimpleWalkingMonster::update()
{
	switch(mState)
	{
	case State_Walking:
		{
			mVelocity.y += 6.0f;
			mVelocity.x = 20.0f * ((mFacing==Facing_Left)?-1:1);

			setVelocity(mVelocity);
			int bumps = moveWithCollision();

			if ((bumps & (Direction_Up | Direction_Down)) != 0) 
			{
				mVelocity.y = 0;
			}

			if ((bumps & (Direction_Left)) != 0)
			{
				mFacing = Facing_Right;
			}

			if ((bumps & (Direction_Right)) != 0)
			{
				mFacing = Facing_Left;
			}


			int offsetX = (mState==Facing_Right)?-getHalfSize().x-2:getHalfSize().x+2;
			int offsetY = getHalfSize().y+2;
		
			float2 position = getPosition();

			int x = (position.x+offsetX) / (float)mRoom->getTileWidth();
			int y = (position.y+offsetY) / (float)mRoom->getTileHeight();

			if (!mRoom->isCollidable(x, y))
			{
				if (mFacing == Facing_Left)
				{
					mFacing = Facing_Right;
				}
				else
				{
					mFacing = Facing_Left;
				}
			}

			if (mRand.getFloat(1.0f) < WALK_TO_IDLE_CHANCE)
			{
				mState = State_Idling;
			}
		}

		break;
	case State_Idling:

		if (mRand.getFloat(1.0f) < IDLE_TO_WALK_CHANCE)
		{
			if (mRand.getFloat(1.0f) > 0.5)
			{
				mFacing = Facing_Left;
			}
			else
			{
				mFacing = Facing_Right;
			}
			mState = State_Walking;
		}

		break;
	}

	Hero* hero = mRoom->getHero();
	if (Collides(hero->getCollisionRect(), getCollisionRect()))
	{
		hero->kill();
	}

	mFrame++;
}
开发者ID:kulgan,项目名称:playn-greengrappler,代码行数:81,代码来源:SimpleWalkingMonster.cpp


示例6: to_string

bool HelloWorld::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    this->isGameOver = false;
    
    visibleSize = Director::getInstance()->getVisibleSize();
    
    // Ground setup
    groundSprite0 = Sprite::create("ground.png");
    this->addChild(groundSprite0);
    groundSprite0->setPosition(Vec2(groundSprite0->getContentSize().width/2.0 , groundSprite0->getContentSize().height/2));
    
    groundSprite1 = Sprite::create("ground.png");
    this->addChild(groundSprite1);
    groundSprite1->setPosition(Vec2(visibleSize.width + groundSprite1->getContentSize().width/2.0 -10, groundSprite1->getContentSize().height/2));
    
    auto groundbody0 = PhysicsBody::createBox(groundSprite0->getContentSize());
    groundbody0->setDynamic(false);
    groundbody0->setContactTestBitmask(true);
    groundSprite0->setPhysicsBody(groundbody0);
    auto groundbody1 = PhysicsBody::createBox(groundSprite1->getContentSize());
    groundbody1->setDynamic(false);
    groundbody1->setContactTestBitmask(true);
    groundSprite1->setPhysicsBody(groundbody1);
    
    // SkyGround setup
    Sprite *skySprite0 = Sprite::create("flappy_background.png");
    Sprite *skySprite1 = Sprite::create("flappy_background.png");
    Sprite *skySprite2 = Sprite::create("flappy_background.png");
    this->addChild(skySprite0);
    this->addChild(skySprite1);
    this->addChild(skySprite2);
    skySprite0->setPosition(visibleSize.width/2, 168 + 200);
    skySprite1->setPosition(visibleSize.width/2 - skySprite1->getContentSize().width, 168 + 200);
    skySprite2->setPosition(visibleSize.width/2 + skySprite1->getContentSize().width, 168 + 200);
    
    // bird setup
    /*
    Sprite *birdSprite = Sprite::create("flappybird1.png");
    this->addChild(birdSprite);
    birdSprite->setPosition(visibleSize.width/2, visibleSize.height/2 + 120);
    */

    SpriteFrameCache* cache = SpriteFrameCache::getInstance();
    cache->addSpriteFramesWithFile("bird.plist");
    
    auto flyAnim = Animation::create();
    for (int i = 1; i < 4; i++) {
        SpriteFrame * frame = cache->getSpriteFrameByName("flappybird" + to_string(i) + ".png");
        flyAnim->addSpriteFrame(frame);
    }
    auto birdSprite = Sprite::createWithSpriteFrameName("flappybird1.png");

    flyAnim->setDelayPerUnit(0.2f);
    
    auto action = Animate::create(flyAnim);
    auto animation = RepeatForever::create(action);
    birdSprite->runAction(animation);
    
    birdSprite->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2 + 80));
    this->addChild(birdSprite);

    auto birdBody = PhysicsBody::createCircle(17.0);
    birdBody->setDynamic(true);
    birdBody->setMass(1.0f);
    birdBody->setVelocity(Vec2(4.0f, 2.0f));
    birdBody->setVelocityLimit(50);
    birdBody->setContactTestBitmask(true);
    birdSprite->setPhysicsBody(birdBody);
    
    //pipe setup
    topPipeSprite = Sprite::create("top_pipe.png");
    bottomPipeSprite = Sprite::create("bottom_pipe.png");
    topPipeSprite->setPosition(visibleSize.width + topPipeSprite->getContentSize().width/2, 600);
    
    auto pipebody0 = PhysicsBody::createBox(topPipeSprite->getContentSize());
    pipebody0->setDynamic(false);
    topPipeSprite->setPhysicsBody(pipebody0);
    pipebody0->setContactTestBitmask(true);
    auto pipebody1 = PhysicsBody::createBox(bottomPipeSprite->getContentSize());
    pipebody1->setDynamic(false);
    pipebody1->setContactTestBitmask(true);
    bottomPipeSprite->setPhysicsBody(pipebody1);
    
    this->positionBottomPipe();
    this->addChild(topPipeSprite);
    this->addChild(bottomPipeSprite);
    
    //setup touch listener
    auto listener = EventListenerTouchOneByOne::create();
    listener->setSwallowTouches(true);

    listener->onTouchBegan = [=](Touch *touch, Event *event){
        if (!this->isGameOver) {
            birdBody->applyImpulse(Vec2(0, 90.0f));
        }
        log("touch detected!");
//.........这里部分代码省略.........
开发者ID:rdtr,项目名称:cocos2dx_flappy,代码行数:101,代码来源:HelloWorldScene.cpp


示例7: setVelocity

void BouncyLogo::initSpeed()
{
    const double speed = 4.0;
    double d = (double)(rand()%1024) / 1024.0;
    setVelocity( d*speed*2-speed, (1-d)*speed*2-speed );
}
开发者ID:nightfly19,项目名称:renyang-learn,代码行数:6,代码来源:canvas.cpp


示例8: setVelocity

	void Listener::setVelocity(const Ogre::Vector3& vec)
	{
		setVelocity(vec.x, vec.y, vec.z);
	}
开发者ID:barsnadcat,项目名称:steelandconcrete,代码行数:4,代码来源:OgreALListener.cpp


示例9: AssertFatal

bool SFXSound::_allocVoice( SFXDevice* device )
{
   // We shouldn't have any existing voice!
   AssertFatal( !mVoice, "SFXSound::_allocVoice() - Already had a voice!" );

   // Must not assign voice to source that isn't playing.
   AssertFatal( getLastStatus() == SFXStatusPlaying,
      "SFXSound::_allocVoice() - Source is not playing!" );

   // The buffer can be lost when the device is reset 
   // or changed, so initialize it if we have to.  If
   // that fails then we cannot create the voice.
   
   if( mBuffer.isNull() )
   {
      SFXProfile* profile = getProfile();
      if( profile != NULL )
      {
         SFXBuffer* buffer = profile->getBuffer();
         if( buffer )
            _setBuffer( buffer );
      }

      if( mBuffer.isNull() )
         return false;
   }

   // Ask the device for a voice based on this buffer.
   mVoice = device->createVoice( is3d(), mBuffer );
   if( !mVoice )
      return false;
            
   // Set initial properties.
   
   mVoice->setVolume( mPreAttenuatedVolume );
   mVoice->setPitch( mEffectivePitch );
   mVoice->setPriority( mEffectivePriority );
   if( mDescription->mRolloffFactor != -1.f )
      mVoice->setRolloffFactor( mDescription->mRolloffFactor );
      
   // Set 3D parameters.
   
   if( is3d() )
   {
      // Scatter the position, if requested.  Do this only once so
      // we don't change position when resuming from virtualized
      // playback.
      
      if( !mTransformScattered )
         _scatterTransform();
      
      // Set the 3D attributes.

      setTransform( mTransform );
      setVelocity( mVelocity );
      _setMinMaxDistance( mMinDistance, mMaxDistance );
      _setCone( mConeInsideAngle, mConeOutsideAngle, mConeOutsideVolume );
   }
   
   // Set reverb, if enabled.

   if( mDescription->mUseReverb )
      mVoice->setReverb( mDescription->mReverb );
   
   // Update the duration... it shouldn't have changed, but
   // its probably better that we're accurate if it did.
   mDuration = mBuffer->getDuration();

   // If virtualized playback has been started, we transfer its position to the
   // voice and stop virtualization.

   const U32 playTime = mPlayTimer.getPosition();
   
   if( playTime > 0 )
   {
      const U32 pos = mBuffer->getFormat().getSampleCount( playTime );
      mVoice->setPosition( pos);
   }

   mVoice->play( isLooping() );
   
   #ifdef DEBUG_SPEW
   Platform::outputDebugString( "[SFXSound] allocated voice for source '%i' (pos=%i, 3d=%i, vol=%f)",
      getId(), playTime, is3d(), mPreAttenuatedVolume );
   #endif
   
   return true;
}
开发者ID:03050903,项目名称:Torque3D,代码行数:88,代码来源:sfxSound.cpp


示例10: setVelocity

void Player::setVelocity(float dx, float dy)
{
	setVelocity(Vector(dx, dy));
}
开发者ID:simplerr,项目名称:Project-Thrust,代码行数:4,代码来源:Player.cpp


示例11: updateHead

void Player::update(float dt)
{
	if(mStunnedCounter > 0.0f)
		mStunnedCounter -= dt;
	else
		mStunned = false;

	// Update the animation
	mAnimation->animate(dt);

	// Update the head rotation
	updateHead();

	// Update the weapon
	if(mWeapon != NULL)	{
		mWeapon->updatePosition(getPosition());
		mWeapon->incrementCooldownCounter(dt);
	}

	/* Update the velocity */

	// Strafing sideways
	if(gDInput->keyDown(DIK_A) && !mStunned && getVelocity().x > -mMaxVelocity)	{	// Left
		getBody()->ApplyForce(Vector(-mAcceleration, 0), getPosition());
		setFacingDirection(LEFT);

		if(mWeapon != NULL)
			mWeapon->setFlipped(true);

		// If the player is on the ground, continue the animation
		if(!mInAir)	
			mAnimation->resume();
	}
	else if(gDInput->keyDown(DIK_D) && !mStunned && getVelocity().x < mMaxVelocity)	{	// Right
		getBody()->ApplyForce(Vector(mAcceleration, 0), getPosition());
		setFacingDirection(RIGHT);

		if(mWeapon != NULL)
			mWeapon->setFlipped(false);

		// If the player is on the ground, continue the animation
		if(!mInAir)	
			mAnimation->resume();
	}
	
	// If A or D is released set the frame to 0 if the player not is in the air
	if(gDInput->keyReleased(DIK_A) || gDInput->keyReleased(DIK_D))	{
		mAnimation->pause();

		if(!mInAir)
			mAnimation->setFrame(0);
	}

	// Jump if the player is on the ground
	if(gDInput->keyDown(DIK_SPACE) && !mInAir)	{
		setVelocity(getVelocity() + Vector(0, -500));
		getBody()->Move(0, -1);		// Move it out of collision (:HACK:)
		mAnimation->setFrame(7);	// Set the jumping frame
		mAnimation->pause();		// Pause the animation
		mInAir = true;				// The player is now in the air
	}

	// Shooting with the left mouse button
	if(gDInput->mouseButtonDown(0))	{
		if(mWeapon != NULL)	{
			if(mWeapon->isReady())	{
				mWeapon->attack();
				mWeapon->setCooldownCounter(0.0f);
				mWeapon->setAttacking(true);
			}
		}
	}

	// Drop the equipped weapon if the drop button was pressed
	if(gDInput->keyPressed(DIK_G))
		dropWeapon();

	// Loot
	if(gDInput->keyPressed(DIK_E))
		checkLoot();
}
开发者ID:simplerr,项目名称:Project-Thrust,代码行数:81,代码来源:Player.cpp


示例12: loop

	void loop() {
		
		//Variable Initialization
		
        time ++;
		api.getMyZRState(myState);
        api.getOtherZRState(otherState);
		phase = game.getCurrentPhase();
		fuel = game.getFuelRemaining();
		myScore = game.getScore();
		otherScore = game.getOtherScore();
		dust = game.getRemainingMaterial();
		chg = game.getCharge();
		
		if (time < 2) {
			red = statePos(myState)[0] < floatZero;
		}
		
		//Debug Console
		
		DEBUG(("\nDevilTech Message Screen: Fall 2012\n"));
#if printDebug
		DEBUG(("Debug Info\n"));
		DEBUG(("\tTime (s)\t%d\tPhase\t%d\tPlayer\t%s\n", time, phase, (red ? "Red" : "Blue")));
		DEBUG(("\tFuel\t%.3f\tDust\t%.3f\tChg\t%d\n", fuel, dust, chg));
		DEBUG(("\tScore\t%.2f\tOther Score\t%.2f\n", myScore, otherScore));
		DEBUG(("\tOther Message\t%u\n", otherMessage));
		printVec("\tMy Pos (m)", statePos(myState));
		printVec("\tMy Vel (m/s)", stateVel(myState));
		printVec("\tMy Att (unitvec)", stateAtt(myState));
		printVec("\tMy AngVel (rad/s)", stateAngVel(myState));
		printVec("\tOther Pos (m)", statePos(otherState));
		printVec("\tOther Vel (m/s)", stateVel(otherState));
		printVec("\tOther Att (unitvec)", stateAtt(otherState));
		printVec("\tOther AngVel (rad/s)", stateAngVel(otherState));
#endif
		
		vec att = {floatZero, -1.0f, floatZero};
		if (!obsCreated) {
			if (makeObs(red ? -0.17f : 0.17f, -0.63f)) obsCreated ++;
		}
		else if (obsCreated == 1) {
			if (makeObs(red ? -0.47f : 0.47f, -0.03f)) obsCreated ++;
		}
		else if (phase == 1) {
			vec temp = {norm((red ? -0.45f : 0.45f) - myState[0], 0.015f), 0.05f, floatZero};
			setVelocity(temp);
			//api.setAttitudeTarget(att);
		}
		else {
			if (!game.haveObject(0)) getItem(0);
			else if (!game.haveObject(1) && !game.otherHasObject(1)) getItem(1);
            else if (!game.haveObject(2) && !game.otherHasObject(2) && !game.haveObject(1)) getItem(2);
            else {
				if (game.haveObject(1) || game.haveObject(2)) {
                    api.setAttitudeTarget(att);
				}
                vec temp = {floatZero, floatZero, floatZero};
                if (phase == 2) {
                    vec temp2 = {(red ? 0.04f : -0.04f), 0.09f, floatZero};
                    attToTarget(myState, temp2, temp);
                    vecScale(temp, 0.057f);
                    temp[2] = maintainZ();
                    setVelocity(temp);
                }
                else {
                    if (!alreadySet) {
                        alreadySet = true;
                        top = myState[2] > floatZero;
                    }
                    if (myState[1] > -0.4f) {
						remDust();
                        temp[0] = norm((red ? 0.045f : -0.045f) - myState[0], 0.015f);
                        temp[1] = -0.051f;
                        temp[2] = maintainZ();
                    }
                    else if (myState[1] > -0.6f) {
						temp[0] = norm((red ? 0.045f : -0.045f) - myState[0], 0.015f);
                        temp[1] = -0.022f;
                        temp[2] = maintainZ();
                    }
                    else {
						temp[0] = norm((red ? 0.045f : -0.045f) - myState[0], 0.015f);
                        temp[1] = floatZero;
                        temp[2] = (top ? -0.055f : 0.055f);
                        DEBUG(("Top:\t%d\t%.3f\n", top, temp[2]));
                    }
                    setVelocity(temp);
                }
            }
        }
	}
开发者ID:jma127,项目名称:zerorobotics,代码行数:92,代码来源:3D+Competition.c


示例13: length

	void Physics::shock(cg::Vector2d collisionPoint, double Force) {
		cg::Vector2d collisionVector = cg::Vector2d(_position[0] - collisionPoint[0], _position[1] - collisionPoint[1]);
			collisionVector /= length(collisionVector);
			setVelocity(Force*collisionVector[0]/_mass + _velocity[0],Force*collisionVector[1]/_mass + _velocity[1]);
	}
开发者ID:jpaires,项目名称:Asteroids,代码行数:5,代码来源:Physics.cpp


示例14: setVelocity

    void Physics::decelerate(double step, double limit) {
        _velocity = _velocity -  _velocity/step;
		if (length(_velocity) < limit)
            setVelocity(0,0);
    }
开发者ID:jpaires,项目名称:Asteroids,代码行数:5,代码来源:Physics.cpp


示例15: down


//.........这里部分代码省略.........
    else { // phase 1
	if (isDead() || dying()) {
	    explode(); // shatters the ship into spinning fragments.
	    delete this;
	    return;
	}
	if (rotateSlow_)
	    rotateSlow_--;

	if (rotateLeft_) {
	    angleIndex_ -= rotateSlow_ ? 1 : rotationRate_;
	    if (angleIndex_ < 0)
		angleIndex_ = SHIP_STEPS-1;
	    angle_ = angleIndex_ * PI_X_2 / SHIP_STEPS;
	    cosangle_ = cos(angle_);
	    sinangle_ = sin(angle_);
	}

	if (rotateRight_) {
	    angleIndex_ += rotateSlow_ ? 1 : rotationRate_;
	    if (angleIndex_ >= SHIP_STEPS)
		angleIndex_ = 0;
	    angle_ = angleIndex_ * PI_X_2 / SHIP_STEPS;
	    cosangle_ = cos(angle_);
	    sinangle_ = sin(angle_);
	}

	if (isBraking()) {
	    stopEngine();
	    stopRotation();
	    if ((fabs(dx_) < 2.5) && (fabs(dy_) < 2.5)) {
		dx_ = 0.0;
		dy_ = 0.0;
		setVelocity(dx_,dy_);
		releaseBrakes();
	    }
	    else {
		double motionAngle = atan2(-dy_,-dx_);
		if (angle_ > M_PI)
		    angle_ -= PI_X_2;
		double angleDiff = angle_ - motionAngle;
		if (angleDiff > M_PI)
		    angleDiff = PI_X_2 - angleDiff;
		else if (angleDiff < -M_PI)
		    angleDiff = PI_X_2 + angleDiff;
		double fdiff = fabs(angleDiff);
		if (fdiff > 0.08) {
		    if (angleDiff > 0)
			rotateLeft_ = true;
		    else if (angleDiff < 0)
			rotateRight_ = true;
		    if (fdiff > 0.6)
			rotationRate_ = brakeForce() + 1;
		    else if (fdiff > 0.4)
			rotationRate_ = 2;
		    else
			rotationRate_ = 1;

		    if (rotationRate_ > 5)
			rotationRate_ = 5;
		}
		else if ((fabs(dx_)>1) || (fabs(dy_)>1)) {
		    startEngine();
		    // we'll make braking a bit faster
		    dx_ += cosangle_/6 * (brakeForce() - 1);
		    dy_ += sinangle_/6 * (brakeForce() - 1);
开发者ID:Camelek,项目名称:qtmoko,代码行数:67,代码来源:sprites.cpp


示例16: setVelocity

void Pod::init() {
    setVelocity(0, -1);

}
开发者ID:UMInteractive,项目名称:cinema_game,代码行数:4,代码来源:pod.cpp


示例17: KAgingSprite

/*!
  Create an exhaust sprite at position \a x, \a y with
  velocity \a dx, \a dy.
 */
KExhaust::KExhaust(double x, double y, double dx, double dy)
    : KAgingSprite(1)
{
    setPos(x + 2 - randDouble()*4, y + 2 - randDouble()*4);
    setVelocity(dx,dy);
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:10,代码来源:sprites.cpp


示例18: fall

void SlimePetEntity::animate(float delay)
{
    if (age < 0.0f)
    {
        age += delay;
    }
    else
    {

        attackDelay -= delay;

        if (isJumping)
        {
            hVelocity -= 700.0f * delay;

            h += hVelocity * delay;

            bool firstTimeGround = false;

            if (h <= 0.0f)
            {
                h = 0.0f;
                if (isFalling())
                {
                    fall();
                }
                else
                {
                    if (isFirstJumping)
                    {
                        isFirstJumping = false;
                        firstTimeGround = true;
                        hVelocity = 160.0f;
                        SoundManager::getInstance().playSound(SOUND_SLIME_IMAPCT);
                    }
                    else
                    {
                        jumpingDelay = 0.3f + 0.1f * (rand() % 15);
                        isJumping = false;
                        SoundManager::getInstance().playSound(SOUND_SLIME_IMAPCT_WEAK);
                    }
                }
            }
            if (firstTimeGround) frame = 0;
            else if (hVelocity > -190.0f) frame = 2;
            else frame = 1;
        }
        else if (isFalling())
        {
            fall();
        }
        else
        {
            jumpingDelay -= delay;
            if (jumpingDelay < 0.0f)
            {
                SoundManager::getInstance().playSound(SOUND_SLIME_JUMP);
                hVelocity = 300.0f + rand() % 250;
                isJumping = true;
                isFirstJumping = true;

                float randVel = 250.0f + rand() % 250;

                setVelocity(Vector2D(x, y).vectorTo(game().getPlayerPosition(), randVel ));
            }
            else if (jumpingDelay < 0.1f)
                frame = 1;
            else frame = 0;
        }

        BaseCreatureEntity::animate(delay);
        if (canCollide()) testSpriteCollisions();
    }

    z = y + 14;
}
开发者ID:carriercomm,项目名称:witchblast,代码行数:76,代码来源:SlimePetEntity.cpp


示例19: setId

        void Entity::loadData(TiXmlElement *element)
        {
            PropertyMap::loadData(element);

            /* Get id. */
            if(element->Attribute("id"))
                setId(element->Attribute("id"));

            /* Load basic data. */
            Vector2D position = getPosition();
            Vector2D::fromXML(element->FirstChildElement("position"),
                    &position);
            setPosition(position);

            Vector2D velocity = getVelocity();
            Vector2D::fromXML(element->FirstChildElement("velocity"),
                    &velocity);
            setVelocity(velocity);

            Vector2D::fromXML(element->FirstChildElement("radius"), &radius);

            queryBoolAttribute(element, "collisionchecker", &collisionChecker);

            float speed = getSpeed();;
            element->QueryFloatAttribute("speed", &speed);
            setSpeed(speed);

            /* Load controller. */
            TiXmlElement *controllerElement =
                    element->FirstChildElement("controller");
            if(controllerElement) {
                string type = controllerElement->Attribute("type");
                map<string, AffectorFactory<Controller>*>::iterator
                        controllerFactory = controllerFactories.find(type);
                if(controllerFactory != controllerFactories.end())
                    controller = controllerFactory->second->create(this,
                            controllerElement);
                else
                    LogManager::getInstance()->error("No controller: %s",
                            type.c_str());
            }

            /* Load positioner. */
            TiXmlElement *positionerElement =
                    element->FirstChildElement("positioner");
            if(positionerElement) {
                string type = positionerElement->Attribute("type");
                map<string, AffectorFactory<Positioner>*>::iterator
                        positionerFactory = positionerFactories.find(type);
                if(positionerFactory != positionerFactories.end())
                    positioner = positionerFactory->second->create(this,
                            positionerElement);
                else
                    LogManager::getInstance()->error("No positioner: %s",
                            type.c_str());
            }

            /* Load sprite. */
            TiXmlElement *spriteElement = element->FirstChildElement("sprite");
            sprite = spriteElement ? new Sprite(spriteElement) : sprite;

            /* Load script. */
            script = element->Attribute("script") ?
                    element->Attribute("script") : script;
        }
开发者ID:ELMERzark,项目名称:JVGS,代码行数:65,代码来源:Entity.cpp


示例20: setVelocity

void AudioSource::setVelocity(float x, float y, float z)
{
    setVelocity(Vector3(x, y, z));
}
开发者ID:sharkpp,项目名称:openhsp,代码行数:4,代码来源:AudioSource.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setVersion函数代码示例发布时间:2022-05-30
下一篇:
C++ setVar函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap