コード例 #1
0
ファイル: Orb.cpp プロジェクト: ppiecuch/Prototype
//================================================================================================//
void Orb::Update()
{
	InWater();

	if(bLockState)//locked mode
	{
		oPos = Pos;
		Pos = *pTarget + mLockOffset;

		for(int n=0;n<6;n++)
		{
			mOChain[n] = mChain[n];
			mChain[n] = *pTarget + mChainOffset[n];
		}
	}
	else//chain mode
	{
		Vec2 r;
		mOChain[0]=mChain[0];
		Vec2 p = *pTarget;
		p += Vec2(32+SCROLL_SPEED,32);
		float d;
		d=mChain[0].Distance(p);
		if(d>10)
		{
			d-=10;
			r = Normalize(mChain[0]-p);
			mChain[0] -= r*(d*0.5f);
		}
		for(int n=1;n<6;n++)
		{
			mOChain[n]=mChain[n];
			mChain[n].x+=SCROLL_SPEED;
			d=mChain[n].Distance(mChain[n-1]);
			if(d>10)
			{
				d-=10;
				r = Normalize(mChain[n]-mChain[n-1]);
				mChain[n] -= r*(d*0.5f);
			}
		}
		Vec2 ray(Normalize(mChain[4]-mChain[5]));
		oPos = mOChain[5] - Vec2(32,32) - ray*16;
		Pos = mChain[5] - Vec2(32,32) - ray*16;
	}
	frame+=0.5f;
	if(frame>15)frame-=15;

	mSphere = Sphere(15,Pos+Vec2(32,32));
	
	fPulsate += 0.15f;
	UTIL_Misc::Clamp(fPulsate,0,360);
	fGlowRotation += 1.5f;
	UTIL_Misc::Wrap(fGlowRotation,360);
}
コード例 #2
0
ファイル: Bug.cpp プロジェクト: RangerKarl/Prototype
//================================================================================================//
void Bug::Update()
{
	iTakeDamageTicks--;
	if(!gpEngine->bRecording || (gpEngine->bRecording && gpEngine->pRecordEnt != this))
		PlayBack();

	oPos = Pos;
	InWater();

	if(KEY_RIGHT.state == PRESSED)
	{
		fRotation += 1.85f;
	}
	if(KEY_LEFT.state == PRESSED)
	{
		fRotation -= 1.85f;
	}

	Vec2 u,r;
	UTIL_Misc::MakeVectors(fRotation,u,r);
	Pos+=u*2.5f;

	fRotation = UTIL_Misc::Wrap(fRotation,360);
	frame<15? frame+=0.75f: frame=0;

	if(RateofFire>0)
	if(gpEngine->mTimer.GetTime()>=fLastFireTime+((float)RateofFire*gpEngine->fGameDifficulty))
	{
		fLastFireTime = gpEngine->mTimer.GetTime();
		Bullet b;
		b.pSpawn = Spawn_BasicBullet;
		b.pUpdate = Update_BasicBullet;
		b.pRender = Render_BasicBullet;
		b.pCollide = Collide_BasicBullet;
		Vec2 v;
		if(FireAtDistantTarget(mSphere.p,gpEngine->mPlayer.mSphere.p,3.5f,v))
		{
			(*b.pSpawn)(b,mSphere.p,v);
			gpEngine->SpawnBullet(b,false);
			SND_LASER2;
		}
	}
}
コード例 #3
0
ファイル: Serpent.cpp プロジェクト: fabiensanglard/Prototype
//================================================================================================//
void Serpent::Update()
{
	iTakeDamageTicks--;
	if(!gpEngine->bRecording || (gpEngine->bRecording && gpEngine->pRecordEnt != this))
		PlayBack();

	if(IsHead)
		InWater();
	oPos = Pos;
	if(IsDead)
		return;

	if(KEY_RIGHT.state == PRESSED)
	{
		fRotation += 1.5f;
		frame+=0.075f;
	}
	if(KEY_LEFT.state == PRESSED)
	{
		fRotation -= 1.5f;
		frame-=0.075f;
	}
	fRotation = UTIL_Misc::Wrap(fRotation,360);

	if(KEY_UP.state == PRESSED)
	{
		Vec2 u,r;
		UTIL_Misc::MakeVectors(fRotation,u,r);
		Pos+=u*2.5f;
	}
	if(frame>15)
		frame-=15;
	else if(frame<0)
		frame+=15;

	vector<Serpent>::iterator iter;
	for(iter = mSections.begin(); iter < mSections.end(); iter++)
	{
		if((*iter).IsActive)
			(*iter).PreUpdate();
	}

	if(gpEngine->bRecording && gpEngine->pRecordEnt == this)
		return;
	iTickSection--;
	if((IsHead && iTickSection == 0) || (IsHead && iTickSection==7 && iCurSection == SERPENT_LENGTH))
	{
		if(iCurSection>0)
		{
			mSections[iCurSection-1].SpawnSection(StartPos);
			iCurSection--;
			iTickSection = 10;
		}
	}

	//kill off each section
	if(IsHead && !IsVisible)
	{
		iTickToDeath--;
		if(iTickToDeath<=0)
		{
			if(iCurSegDeath>=0 && mSections[iCurSegDeath].IsActive)
			{
				mSections[iCurSegDeath].IsVisible = false;
				gpEngine->SpawnExplosion(gpEngine->sprExplosionSmall,mSections[iCurSegDeath].Pos+Vec2(60,10),120,0.75f,(float)(rand()%360),false);
				if(iCurSegDeath>0)
					SND_MEDEXPLODE;
				else
					SND_LARGEEXPLODE2;
				iCurSegDeath--;
			}
			else
				IsActive = false;
			iTickToDeath=5;
		}
	}

	//fire from tail
	if(IsHead && IsVisible)
	if(RateofFire>0)
	{
		if(mSections.front().IsVisible && mSections.front().IsActive)
		if(gpEngine->mTimer.GetTime()>=fLastFireTime+(0.25f*gpEngine->fGameDifficulty))
		{
			fLastFireTime = gpEngine->mTimer.GetTime();
			Bullet b;
			b.pSpawn = Spawn_BasicBullet;
			b.pUpdate = Update_BasicBullet;
			b.pRender = Render_BasicBullet;
			b.pCollide = Collide_BasicBullet;
			Vec2 v = FireAtTarget(mSections.front().Pos+Vec2(48,-16),gpEngine->mPlayer.mSphere.p,3.5f);
			(*b.pSpawn)(b,mSections.front().Pos+Vec2(48,-16),v);
			gpEngine->SpawnBullet(b,false);
			SND_LASER5;
		}
	}
}
コード例 #4
0
ファイル: watermap.cpp プロジェクト: Corysia/Server
bool WaterMap::InLiquid(float y, float x, float z) const {
	if(BSP_Root == nullptr)	//if the water map isn't loaded, this will save ~1 CPU cycle
		return false;
	return (InWater(y, x, z) || InLava(y, x, z));
}
コード例 #5
0
ファイル: water_map_v2.cpp プロジェクト: Leere/Server
bool WaterMapV2::InLiquid(float y, float x, float z) const {
	return InWater(y, x, z) || InLava(y, x, z);
}
コード例 #6
0
ファイル: tf_gamemovement.cpp プロジェクト: Navton/TF2Classic
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFGameMovement::FullWalkMove()
{
	if ( !InWater() ) 
	{
		StartGravity();
	}

	// If we are leaping out of the water, just update the counters.
	if ( player->m_flWaterJumpTime )
	{
		// Try to jump out of the water (and check to see if we still are).
		WaterJump();
		TryPlayerMove();
		CheckWater();
		return;
	}

	// If we are swimming in the water, see if we are nudging against a place we can jump up out
	//  of, and, if so, start out jump.  Otherwise, if we are not moving up, then reset jump timer to 0
	if ( InWater() ) 
	{
		FullWalkMoveUnderwater();
		return;
	}

	if (mv->m_nButtons & IN_JUMP)
	{
		CheckJumpButton();
	}
	else
	{
		mv->m_nOldButtons &= ~IN_JUMP;
	}

	// Make sure velocity is valid.
	CheckVelocity();

	if (player->GetGroundEntity() != NULL)
	{
		mv->m_vecVelocity[2] = 0.0;
		Friction();
		WalkMove();
	}
	else
	{
		AirMove();
	}

	// Set final flags.
	CategorizePosition();

	// Add any remaining gravitational component if we are not in water.
	if ( !InWater() )
	{
		FinishGravity();
	}

	// If we are on ground, no downward velocity.
	if ( player->GetGroundEntity() != NULL )
	{
		mv->m_vecVelocity[2] = 0;
	}

	// Handling falling.
	CheckFalling();

	// Make sure velocity is valid.
	CheckVelocity();
}
コード例 #7
0
ファイル: water_map_v2.cpp プロジェクト: N0ctrnl/VAServer
bool WaterMapV2::InLiquid(const glm::vec3& location) const {
	return InWater(location) || InLava(location) || InVWater(location);
}