void Source::SetVelocity(float x, float y, float z)
	{
	    #ifdef HAS_AUDIO_SOURCE
		impl->SetVelocity(Math::vec3(x, y, z));
		#else
        (void)x; (void)y; (void)z;
		throw System::PunkException(L"Audio source is not available");
		#endif
	}
void Player::Move()
{
	//fprintf(stderr, "Move Forward\n");
	Vector2 rotation = this->GetRotation();
	Vector2 velocity = this->GetVelocity();
	rotation = Vector2(GetRotation().GetX(), GetRotation().GetY());
	velocity = velocity + rotation * 4 * pEngine->GetDeltaTime();
	SetVelocity(velocity);
}
	void Source::SetVelocity(const Math::vec3& value)
	{
	    #ifdef HAS_AUDIO_SOURCE
		impl->SetVelocity(value);
		#else
        (void)value;
		throw System::PunkException(L"Audio source is not available");
		#endif
	}
	void Ball::TouchBoard(BoardSide side) {
		TouchEffects();
		XBOX::Rumble(1, 0.2f, 4000.0f);
		_bounceSound->Play();

		if(!_dying && BOTTOM == side) {
			_dying = true;
			_health = 1.0f;
			_decayRate = 2.0f;
		}

		/*
		this makes the game a little less predictable and prevents the
		ball from bouncing horizontally all the time
		*/
		if(TOP == side || BOTTOM == side) SetVelocity(MATH::Rotate(GetVelocity(), sf::Randomizer::Random(-0.1f, 0.1f)));
		else SetVelocity(MATH::Rotate(GetVelocity(), sf::Randomizer::Random(-0.2f, 0.2f)));
	}
	cSoundSourceFmod(cSoundSystemFmod *soundsystem, const float x, const float y, const float z, const char *filename) : mSoundSystem(soundsystem), mpChannel(0), mb3D(true), mpSound(0), mfMinDistance(100.0f), mfMaxDistance(100000.0f) {
		if(mSoundSystem && mSoundSystem->mpSystem){
			result = FMOD_System_CreateStream(mSoundSystem->mpSystem, filename, (FMOD_MODE)(FMOD_SOFTWARE | FMOD_3D), 0, &mpSound);
			ERRCHECK(result);
			
			SetPosition(x,y,z);
			SetVelocity(0,0,0);
		}
	}
void RigidBody::ApplyImpulse(Vector3 const& impulse, Vector3 const& point)
{
	if(HasInfiniteMass()) return;

	Vector3 deltaVelocity = impulse * GetInverseMass();
	SetVelocity(GetVelocity() + deltaVelocity);

	Vector3 deltaOmega = GetInverseInertialTensor() * (point-GetPosition()).crossProduct(impulse);
	SetAngularVelocity(GetAngularVelocity() + deltaOmega);
}
Exemple #7
0
// calculates velocity for going towards a certain vector
void Sprite::SetVelocityToward(const Vector2D a_rV2)
{
	/*float fAngle = GetPosition().GetAngle(a_rV2);
	Vector2D vect(cos(fAngle), sin(fAngle));
	SetVelocity(vect);*/

	Vector2D direction((m_oPosition.m_fX - a_rV2.m_fX), (m_oPosition.m_fY - a_rV2.m_fY));
	direction.Normalize();
	SetVelocity(direction);
}
Exemple #8
0
Smoke::Smoke(const int type, const float x, const float y)
	:GameObj("smoke", x, y, -1)
{
	fFrame = (float)type;
	iLifeTimer = 60;
	SetVelocity((float)Random::rand.NextDouble()*4-2, -0.125f);
	bTransform = true;
	vScale.x = vScale.y = 0;
	sObject_tag = "smoke";
}
Exemple #9
0
AudioSource::AudioSource(AudioBuffer* buff)
{
	alGenSources(1, &source);	
	SetGain(1);
	SetPitch(1);
	SetLooping(false);
	SetPosition(0,0,0);
	SetVelocity(0,0,0);	

	alSourcei(source, AL_BUFFER, buff->GetBuffer());
}
Exemple #10
0
func Blocked(object clonk)
{
	AddEffect("Blocked", this, 1, 1, this);
	Sound("Ball::ball_blocked", false, 20);
	SetRDir(20);
	var objectangle = Angle(clonk->GetX(), clonk->GetY(), GetX(), GetY());
	
	//var tangle = 2* ( (objectangle + 90)%360 - entryangle) + entryangle;
	SetVelocity(objectangle, Speed);
	Idle();
}
Exemple #11
0
void ZActor::InputBasicInfo(ZBasicInfo* pni, BYTE anistate)
{
	if (!CheckFlag(AF_MY_CONTROL))
	{
		SetPosition(pni->position);
		SetVelocity(pni->velocity);
		SetDirection(pni->direction);
		m_Animation.ForceAniState(anistate);
		m_fLastBasicInfo = g_pGame->GetTime();
	}
}
Exemple #12
0
void VectorPath::Init(Point from, Point to, int velocity) {
    loc.moveto(from);
    float dist = MathUtil::dist(from, to);
    delta.moveto((to.x-from.x)/dist,
                 (to.y-from.y)/dist,
                 (to.z-from.z)/dist);
    step = 1 + (int)roundf(dist);
    accel = 0;
    SetVelocity(velocity);
    //xprintf("VP:["); from.print(); to.print(); xprintf(" steps=%d]\n", step);
}
Exemple #13
0
void Yarn::InitFromShooter( GameObjectPtr inShooter, GameObjectPtr inTarget )
{
	SetPlayerId( inShooter->GetPlayerId() );

	Vector3 forward = inTarget->GetLocation() - inShooter->GetLocation();
	SetVelocity( forward * kMuzzleSpeed );
	SetLocation( inShooter->GetLocation() );

	mShooterCat = inShooter;
	mTargetCat = inTarget;
}
Exemple #14
0
bool CEulerVariable::SetPrimVar_Compressible(CConfig *config) {
	unsigned short iVar;
  bool check_dens = false, check_press = false, check_sos = false, check_temp = false, RightVol = true;
  
  double Gas_Constant = config->GetGas_ConstantND();
	double Gamma = config->GetGamma();
  
  SetVelocity();                                // Computes velocity and velocity^2
  check_dens = SetDensity();                    // Check the density
	check_press = SetPressure(Gamma);							// Requires velocity2 computation.
	check_sos = SetSoundSpeed(Gamma);             // Requires pressure computation.
	check_temp = SetTemperature(Gas_Constant);		// Requires pressure computation.
  
  /*--- Check that the solution has a physical meaning ---*/
  
  if (check_dens || check_press || check_sos || check_temp) {
    
    /*--- Copy the old solution ---*/
    
    for (iVar = 0; iVar < nVar; iVar++)
      Solution[iVar] = Solution_Old[iVar];
    
    /*--- Recompute the primitive variables ---*/
    
    SetVelocity();
    check_dens = SetDensity();
    check_press = SetPressure(Gamma);
    check_sos = SetSoundSpeed(Gamma);
    check_temp = SetTemperature(Gas_Constant);
    
    RightVol = false;
    
  }
  
  /*--- Set enthalpy ---*/
  
  SetEnthalpy();                                // Requires pressure computation.
  
  return RightVol;
  
}
Exemple #15
0
void RandomVelocities(PhysXObject* object, int powerMax, int seedMultiplier)
{
    PxVec3 dir = CreateRandomVector(powerMax, seedMultiplier);

    srand((time(NULL) * seedMultiplier) + time(NULL));

    int power = rand() % powerMax;

    dir.normalize();

    SetVelocity(dir * power, object);
}
Exemple #16
0
void CBuilding::ForcedMove(const float3& newPos) {
	heading = GetHeadingFromFacing(buildFacing);
	frontdir = GetVectorFromHeading(heading);

	SetVelocity(ZeroVector);
	Move(CGameHelper::Pos2BuildPos(BuildInfo(unitDef, newPos, buildFacing), true), false);
	UpdateMidAndAimPos();

	CUnit::ForcedMove(pos);

	unitLoader->FlattenGround(this);
}
	void Ball::Touch(ENT::Block& block, TouchInfo info) {
		TouchEffects();
		XBOX::Rumble(1, 0.2f, 4000.0f);
		_scoreSound->Play(sf::Randomizer::Random(30000.0f, 40000.0f), 0.3f);

		if(_ignited) {
			MATH::Vector2 velocity = GetVelocity();
			if(info.cutX > info.cutY) velocity.y *= -1.0f;
			else velocity.x *= -1.0f;
			SetVelocity(velocity);
		}
	}
Exemple #18
0
// for timestep changes, to stop autopilot overshoot
// either adds half of current accel if decelerating
void Ship::TimeAccelAdjust(const float timeStep)
{
	if (!AIIsActive()) return;
#ifdef DEBUG_AUTOPILOT
	if (this->IsType(Object::PLAYER))
		Output("Time accel adjustment, step = %.1f, decel = %s\n", double(timeStep),
			m_decelerating ? "true" : "false");
#endif
	vector3d vdiff = double(timeStep) * GetLastForce() * (1.0 / GetMass());
	if (!m_decelerating) vdiff = -2.0 * vdiff;
	SetVelocity(GetVelocity() + vdiff);
}
CProjectile::CProjectile( vector3df NewPos, vector3df NewVelocity, PlayerID ownerPID, f32 oneOverMassConst, f32 radiusConst, int aliveTime, f32 power ) : CWorldPart( NewPos, oneOverMassConst, radiusConst, 1.0f, true, aliveTime )
{
    Reset();

    setDebugText( "projectile" );

    SetVelocity( NewVelocity );

    beam = NULL;
    ownerPlayerID = ownerPID;
    fHitPower = power;
}
			void Execute()
			{
				auto projectile = mWeapon->GetProjectile()->Clone();
				projectile->SetPosition(mPosition);
				projectile->SetVelocity(sf::Vector2f(projectile->GetSpeed(), 0.0f));
				projectile->SetRotation(0.0f);
				projectile->SetZOrder(50);
				projectile->SetCurrentAimpoint(mCurrAim);
				projectile->SetFinalAimpoint(mFinalAim);
				projectile->Fire();
				mDrawNode->Add(projectile);
			}
Exemple #21
0
void Body::SwitchToFrame(Frame *newFrame)
{
	vector3d vel = GetVelocityRelTo(newFrame);		// do this first because it uses position
	vector3d fpos = m_frame->GetPositionRelTo(newFrame);
	matrix3x3d forient = m_frame->GetOrientRelTo(newFrame);
	SetPosition(forient * GetPosition() + fpos);
	SetOrient(forient * GetOrient());
	SetVelocity(vel + newFrame->GetStasisVelocity(GetPosition()));
	SetFrame(newFrame);

	LuaEvent::Queue("onFrameChanged", this);
}
Exemple #22
0
void Player::CheckDamage(void)
{
    SGD::AudioManager* pAudio = SGD::AudioManager::GetInstance();
    Game* pGame = Game::GetInstance();


    // dead, !hurt
    if (profile.health <= 0.0f)
    {
        profile.health = 0.0f;

        if (m_hHurt != nullptr && pAudio->IsAudioPlaying(*m_hHurt) == true)
            pAudio->StopAudio(*m_hHurt);

        if (pAudio->IsAudioPlaying(*m_hDeath) == false)
            voice = pAudio->PlayAudio(*m_hDeath, false);
        pAudio->SetVoiceVolume(voice);

        m_bIsAlive = false;

        SetVelocity({ 0, 0 });
    }

    // hurt, !dead
    else
    {
        int sound = rand() % 3;

        switch (sound)
        {
        case 0:
            m_hHurt = &pGame->playerHurt1;
            break;
        case 1:
            m_hHurt = &pGame->playerHurt2;
            break;
        case 2:
            m_hHurt = &pGame->playerHurt3;
            break;
        default:
            break;
        }

        if (pAudio->IsAudioPlaying(pGame->playerHurt1) == false &&
                pAudio->IsAudioPlaying(pGame->playerHurt2) == false &&
                pAudio->IsAudioPlaying(pGame->playerHurt3) == false)
            voice = pAudio->PlayAudio(*m_hHurt, false);
        pAudio->SetVoiceVolume(voice);

        m_hHurt = nullptr;
    }
}
Exemple #23
0
void CBuilding::ForcedMove(const float3& newPos) {
	// heading might have changed if building was dropped from transport
	// (always needs to be axis-aligned because yardmaps are not rotated)
	heading = GetHeadingFromFacing(buildFacing);

	UpdateDirVectors(false);
	SetVelocity(ZeroVector);

	// update quadfield, etc.
	CUnit::ForcedMove(CGameHelper::Pos2BuildPos(BuildInfo(unitDef, newPos, buildFacing), true));

	unitLoader->FlattenGround(this);
}
			shared_ptr<Projectile> Clone()
			{
				auto clone = make_shared<Projectile>(mId, mName, mFilename, mRef, mWpnId, mSpeed, mAimpointUpdateDelayMs, mCurrentAimpoint, mFinalAimpoint);
				clone->SetPosition(this->GetPosition());
				clone->SetVelocity(this->GetVelocity());
				clone->SetAlive(this->IsAlive());
				clone->SetColor(this->GetColor());
				clone->SetOrigin(this->GetOrigin());
				clone->SetRotation(this->GetRotation());
				clone->SetScale(this->GetScale().x, this->GetScale().y);
				clone->SetZOrder(this->GetZOrder());
				return clone;
			}
void CollisionSystem::SlowEntity(std::shared_ptr<Entity> slowingEntity,
    std::shared_ptr<Entity> movingEntity)
{
    auto slowingComponent = std::static_pointer_cast<SlowingComponent>(Engine::GetInstance().GetSingleComponentOfClass(slowingEntity, "SlowingComponent"));
    auto particleComponent = std::static_pointer_cast<ParticleComponent>(Engine::GetInstance().GetSingleComponentOfClass(movingEntity, "ParticleComponent"));

    float magnitude = slowingComponent->GetMagnitude();
    Vector velocity = particleComponent->GetVelocity();

    velocity *= magnitude;

    particleComponent->SetVelocity(velocity);
}
void Projectile::Update(float dt)
{
  if (position_.x < point_attack_.x )
     SetDirection (EActorDirection::EAST);
  if (position_.x > point_attack_.x )
     SetDirection (EActorDirection::WEST);
  if (position_.y < point_attack_.y )
     SetDirection (EActorDirection::NORTH);
  if (position_.y > point_attack_.y )
    SetDirection (EActorDirection::SOUTH);
  SetVelocity (directionToVector[static_cast<unsigned>(GetDirection())]);
  position_ +=  velocity_*dt;
}
void osaODEServoMotor::SetPosition( double qs, double q, double dt ){

  double sign = 1.0;
  if( qs < q ) { sign = -1.0; }  // sign of the motion

  double e = qs-q;
  double qd = e / dt;
  if( vwmax < fabs( qd ) )
    { qd = sign*vwmax; }

  SetVelocity( qd );
  
}
Exemple #28
0
void Player::RespawnFrom(boost::shared_ptr<Player> saved_player) {
    m_state = PS::Stand;
    m_shooting_enabled = saved_player->CanShoot() || saved_player->IsTwinShotEnabled();
    m_twin_shot_enabled = false;
    m_max_x_pos = saved_player->m_max_x_pos;
    SetPosition(saved_player->GetX(), saved_player->GetY());
    SetVelocity(0, 0);
    SetXAcceleration(saved_player->GetXAcceleration());
    SetYAcceleration(saved_player->GetYAcceleration());
    SetDefaultMovement();

    m_should_be_respawned = false;
}
Exemple #29
0
func AttackOrder(x, y)
{
	ClearEffects();

	Sound("Ball::ball_order", false, 20);
		
	var eff = AddEffect("MoveTo", this, 1, 1, this);
	eff.x = master->GetX() + x;
	eff.y = master->GetY() + y;

	var angle = Angle(GetX(), GetY(), eff.x, eff.y, 10);
	SetVelocity(angle, Speed, 10);
}
Exemple #30
0
func HomeCall()
{
	ClearEffects();
	
	Sound("Ball::ball_call", false, 20);
	
	var eff = AddEffect("HomeCall", this, 1, 1, this);
	eff.x = master->GetX();
	eff.y = master->GetY();
	
	var angle = Angle(GetX(), GetY(), eff.x, eff.y, 10);
	SetVelocity(angle, Speed, 10);
}