Exemplo n.º 1
0
void Rocket::Draw(int terrain)//манипул¤ции над
//ракетой: вычисление и установка местаположени¤
//и т.д.
{
const float rocketSpeed = 1.1;//скрость перемещени¤
//ракеты
const int RockToLive = 3000;

if (alive)  { //если ракета активизирована, 
//то показываем еЄ и 
dbShowObject(num);// производим манипул¤ции над ней
dbMoveObject(num, rocketSpeed);

Xpos = dbObjectPositionX(num);
Ypos = dbObjectPositionY(num);
Zpos = dbObjectPositionZ(num);

float ground = dbGetTerrainGroundHeight(terrain, 
		Xpos,// переменна¤, хран¤ща¤ высоту  
		Zpos);// поверхности ландшафта
if (ground >= Ypos) {
	// произошло столкновение с поверхностью
		Die();
	}

	dbPositionObject(num, Xpos,// перемещаем ракету
		Ypos, Zpos);

if ((GetTickCount() - start_time) > RockToLive) 
Die();
} else dbHideObject(num);//иначе скрываем еЄ
}
Exemplo n.º 2
0
void Asteroid::driftRight()
{
	if(dRight == true && dLeft == false)
	{
		float x = dbObjectPositionX(obj);
		float y = dbObjectPositionY(obj);
		float z = dbObjectPositionZ(obj);
		dbPositionObject(obj, x + DRIFT_SPEED_R, y, z );
		dLeft = false;
	}
}
Exemplo n.º 3
0
void Asteroid::reset()
{
	posX = dbObjectPositionX(obj);
	posY = dbObjectPositionY(obj);
	posZ = dbObjectPositionZ(obj);

	if(posY <= -22 || posX  <= -25 || posX >= 25  || posY >= 35)
	{
	totalSpeed = moveSpeed + GAME_SPEED;
	dbPositionObject ( obj, dbRnd(47) -25 , dbRnd(10) +25 , 0);
	}
	return;
}
Exemplo n.º 4
0
void Asteroid::gravity()
{
	dbPositionObject ( obj, dbObjectPositionX(obj), dbObjectPositionY(obj)+ totalSpeed, dbObjectPositionZ(obj));
	return;
}
Exemplo n.º 5
0
	bool PlayerShip::update(double timeDelta, double parentTime){
		mPrimaryWeaponSupply->update(timeDelta, parentTime);
		mSecondaryWeaponSupply->update(timeDelta, parentTime);
		if (mSuperWeapon) mSuperWeaponSupply->update(timeDelta, parentTime);

		/*mEnergy += mLevelSegment->getTimeDelta()*mPlayerDetails.mEnergyRegen;
		if (mEnergy > mPlayerDetails.mEnergy){
			mEnergy = mPlayerDetails.mEnergy;
		}*/
		if (mInvulnerabilityTimer > timeDelta){ //mLevelSegment->getTimeDelta()
			mInvulnerabilityTimer -= timeDelta;//mLevelSegment->getTimeDelta();
		}else{
			mInvulnerabilityTimer = 0;
		}

		for (int i=0;i<3;i++){
			if (mTimeToFire[i] > timeDelta){//mLevelSegment->getTimeDelta()){
				mTimeToFire[i]-=timeDelta;//mLevelSegment->getTimeDelta();
			}else{
				mTimeToFire[i] =0;
			}
		}

		Util::Log("updating PlayerShip...", 6);

		mShield += timeDelta*mPlayerDetails.mShieldRegen; //mLevelSegment->getTimeDelta()
		if (mShield > mPlayerDetails.mShield){
			mShield = mPlayerDetails.mShield;
		}
		

		Parent::update(timeDelta, parentTime);
		Util::Log("...",6);
		//mAnimState[ANGEL_ANIM_LEGSWAVER]->addTime(mLevelSegment->getTimeDelta());
		Util::Log("...",6);
			/*Util::Log("BEF -----");
			Util::Log("Bef  : "+toString(getRX())+"\t\t"+toString(getRY())+"\t\t"+toString(getRZ()));
			Util::Log("Rail : "+toString(getHook()->getRX())+"\t\t"+toString(getHook()->getRY())+"\t\t"+toString(getHook()->getRZ()));
			Util::Log("ObjA : "+
				toString(dbObjectAngleX(objNbGet()))+
				"\t\t"+toString(dbObjectAngleY(objNbGet()))+
				"\t\t"+toString(dbObjectAngleZ(objNbGet())));*/
			
		//Util::Log("Bef : RailY("+toString(getHook()->getRY())+")\tShipY"+toString(getRY()));

		
		    

	//And the final quaternion is obtained by Qx * Qy * Qz.

		//setRot(0,0,0);
		if (mHealth > 0){
			if (mLockLevel == 0){
				if (mLevelSegment->getCurrentHook() == NULL)
					throw("Ship active with no active rail/hook.");

				float mx = mDeltaMovement.x;//0-Core::getSingleton()->getMouse()->getDX()*500;
				float my = mDeltaMovement.y;//Core::getSingleton()->getMouse()->getDY()*500;
				//Util::Log("Mouse : "+ts(mx)+","+ts(my),0);
				switch (mLevelSegment->getRailType()){
					case RAIL_VERTICAL:
						mWanted.x += (float)mx;
						mWanted.z -= (float)my;
						mWanted.y = 0;
						//mTargetSceneNode->setVisible(false);
					break;
					case RAIL_DEPTH:
						mWanted.x += (float)mx;
						mWanted.z = 0;
						mWanted.y -= (float)my;
		//				mTargetSceneNode->setVisible(true);
					break;
					case RAIL_HORIZONTAL:
						mWanted.x = 0;
						mWanted.z -= (float)mx;
						mWanted.y -= (float)my;
		//				mTargetSceneNode->setVisible(false);
					break;
					default:
						throw("Playship active with no plane type defined");
					break;
				}
				
			}else{
				switch (mLevelSegment->getRailType()){
					case RAIL_VERTICAL:
						mWanted.x = 0;
						mWanted.y = 0;
						mWanted.z = 0;//-mLevelSegment->getZoneSize().z/2; WTF?
					break;
					case RAIL_HORIZONTAL:
						mWanted.x = 0;
						mWanted.y = 0;
						mWanted.z = 0;
					break;
					case RAIL_DEPTH:
						mWanted.x = 0;
						mWanted.y = 0;
						mWanted.z = 0;
					break;
					default:
						mWanted.x = 0;
						mWanted.y = 0;
						mWanted.z = 0;
					break;
				}
		//		mTargetSceneNode->setVisible(false);
			}
		}else{
			mTimeToReset -= timeDelta;//mLevelSegment->getTimeDelta();
			if (mTimeToReset < 0){
				Level::getSingleton()->reset();
			}
		}

		switch (mLevelSegment->getRailType()){
			case RAIL_DEPTH:
				if (mWanted.x < -mLevelSegment->getZoneSize().x) mWanted.x = -mLevelSegment->getZoneSize().x;
				if (mWanted.x > mLevelSegment->getZoneSize().x) mWanted.x = mLevelSegment->getZoneSize().x;
				if (mWanted.y < -mLevelSegment->getZoneSize().y) mWanted.y = -mLevelSegment->getZoneSize().y;
				if (mWanted.y > mLevelSegment->getZoneSize().y) mWanted.y = mLevelSegment->getZoneSize().y;
				if (mWanted.z < -mLevelSegment->getZoneSize().y) mWanted.z = -mLevelSegment->getZoneSize().y;
				if (mWanted.z > mLevelSegment->getZoneSize().y) mWanted.z = mLevelSegment->getZoneSize().y;
			break;
			default:
				if (mWanted.x < -mLevelSegment->getZoneSize().x) mWanted.x = -mLevelSegment->getZoneSize().x;
				if (mWanted.x > mLevelSegment->getZoneSize().x) mWanted.x = mLevelSegment->getZoneSize().x;
				if (mWanted.y < -mLevelSegment->getZoneSize().y) mWanted.y = -mLevelSegment->getZoneSize().y;
				if (mWanted.y > mLevelSegment->getZoneSize().y) mWanted.y = mLevelSegment->getZoneSize().y;
				if (mWanted.z < -mLevelSegment->getZoneSize().z) mWanted.z = -mLevelSegment->getZoneSize().z;
				if (mWanted.z > mLevelSegment->getZoneSize().z) mWanted.z = mLevelSegment->getZoneSize().z;
			break;
		}

		switch (mLevelSegment->getRailType()){
			case RAIL_DEPTH:
	//			mTargetSceneNode->setPosition(mWanted.x, mWanted.y, 0-(mWanted.z*2));
			break;
			default:
			break;
		}
		
		//move(mWanted.z, false);
		//move(mRailPos.x, false);
		Vector3 mPos;
		mPos = mSceneNode->getPosition();

		mSpeed.x = axisBehave(mWanted.x, mPos.x, mSpeed.x);
		mSpeed.y = axisBehave(mWanted.y, mPos.y, mSpeed.y);
		mSpeed.z = axisBehave(mWanted.z, mPos.z, mSpeed.z);

		mPos.x += (mSpeed.x*timeDelta);
		mPos.y += (mSpeed.y*timeDelta);
		mPos.z += (mSpeed.z*timeDelta);

		if (mPos.x < -mLevelSegment->getZoneSize().x){
			mPos.x = -mLevelSegment->getZoneSize().x;
			mWanted.x = mPos.x;
			mSpeed.x = 0;
		}
		if (mPos.x > mLevelSegment->getZoneSize().x){
			mPos.x = mLevelSegment->getZoneSize().x;
			mWanted.x = mPos.x;
			mSpeed.x = 0;
		}
		if (mPos.y < -mLevelSegment->getZoneSize().y){
			mPos.y = -mLevelSegment->getZoneSize().y;
			mWanted.y = mPos.y;
			mSpeed.y = 0;
		}
		if (mPos.y > mLevelSegment->getZoneSize().y){
			mPos.y = mLevelSegment->getZoneSize().y;
			mWanted.y = mPos.y;
			mSpeed.y = 0;
		}
		if (mPos.z < -mLevelSegment->getZoneSize().z){
			mPos.z = -mLevelSegment->getZoneSize().z;
			mWanted.z = mPos.z;
			mSpeed.z = 0;
		}
		if (mPos.z > mLevelSegment->getZoneSize().z){
			mPos.z = mLevelSegment->getZoneSize().z;
			mWanted.z = mPos.z;
			mSpeed.z = 0;
		}


		Util::Log("PlayerShip Pos : "+ts(mPos)+"("+ts(mLevelSegment->getRailType())+")",5);
		setPos(mPos.x, mPos.y, mPos.z);
		mSceneNode->setOrientation(Ogre::Quaternion::IDENTITY);

		//();
		ZoneInfo* zoneInfo = mLevelSegment->getZoneInfo();
		Ogre::Vector3 zoneSize = mLevelSegment->getZoneSize();
		switch (mLevelSegment->getRailType()){
			case RAIL_HORIZONTAL:{
				float xPercent = mPos.z / zoneInfo->mSize.current.z;
				float yPercent = mPos.y / zoneInfo->mSize.current.y;

				mLevelSegment->getActiveCamera()->setHardPitch(
					(yPercent*zoneInfo->mCamTilt.current.y)*(Math::PI/180.0f)
				);
				mLevelSegment->getActiveCamera()->setHardYaw(
					0-(xPercent*zoneInfo->mCamTilt.current.x)*(Math::PI/180.0f)
				);


				/*mLevelSegment->getActiveCamera()->setHardPitch(
					((mPos.y/mLevelSegment->getZoneSize().y)/
					(Math::PI*3))//4
				);
				mLevelSegment->getActiveCamera()->setHardYaw(
					0-((mPos.z/mLevelSegment->getZoneSize().z)/
					(Math::PI*2))//3
				);*/


				mLevelSegment->getActiveCamera()->setHardPos(
					xPercent*zoneInfo->mCamRange.current.x, 
					yPercent*zoneInfo->mCamRange.current.y);

				mSceneNode->pitch((Radian)(((mPos.y-mWanted.y)/(mLevelSegment->getZoneSize().y*4))));//(mWanted.x-mRailPos.x)*5);
				{
				Vector3 absPos = mSceneNode->_getDerivedPosition();
				Real h = mLevelSegment->getWorld()->getHeightAt(absPos.x, absPos.z);
				if (absPos.y < (h+10)){
					mSceneNode->translate(Vector3(0,((h+10)-absPos.y),0), Ogre::Node::TS_WORLD);
					
				}
				}
			}break;
			case RAIL_VERTICAL:{
				float xPercent = mPos.x / zoneInfo->mSize.current.x;
				float zPercent = mPos.z / zoneInfo->mSize.current.z;
				
				mLevelSegment->getActiveCamera()->setHardPitch(
					(zPercent*zoneInfo->mCamTilt.current.y)*(Math::PI/180.0f)
				);
				mLevelSegment->getActiveCamera()->setHardYaw(
					(xPercent*zoneInfo->mCamTilt.current.x)*(Math::PI/180.0f)
				);
				mLevelSegment->getActiveCamera()->setHardPos(
					0-xPercent*zoneInfo->mCamRange.current.x, 
					zPercent*zoneInfo->mCamRange.current.y);

				/*mLevelSegment->getActiveCamera()->setHardPitch(
					0-(
					(mPos.z/mLevelSegment->getZoneSize().z)/
					(Math::PI*20)
					)
				);*/
				//mLevelSegment->getActiveCamera()->setHardPos(0, 30-(mPos.z/20));
				/*mLevelSegment->getActiveCamera()->setHardPitch(
					0-((
					(mPos.z-(0-mLevelSegment->getZoneSize().z))/mLevelSegment->getZoneSize().z)/
					(Math::PI*8)
					)
				);*/
				//roll((mWanted.x-mPos.x)*2, false);//(mWanted.x-mRailPos.x)*5);
			}break;
			case RAIL_DEPTH:
	#ifdef DGSDK
				dbPointObject( objNb, dbObjectPositionX(cursor), dbObjectPositionY(cursor), dbObjectPositionZ(cursor) );
	#endif
				//dbRotateLimb(objNb, mLeftLegLimb, 0, 0, 45);
				//dbRotateLimb(objNb, mRightLegLimb, 0, 0, 45);

				//dbSetObjectToObjectOrientation(objNb, mHook->objNbGet());
				
				mSceneNode->resetOrientation();
				if (mLockLevel == 0){
					Ogre::Vector3 tgt = mWanted;
					tgt.z = mLevelSegment->getZoneSize().z;
					mSceneNode->lookAt(tgt, Ogre::Node::TS_PARENT, Vector3::UNIT_Z);
					roll(0-((mWanted.x-mPos.x)/2));
				}
				

				mLevelSegment->getActiveCamera()->setHardPitch(
					((mPos.y/mLevelSegment->getZoneSize().y)/
					(Math::PI*4))//4
				);
				mLevelSegment->getActiveCamera()->setHardYaw(
					((mPos.x/mLevelSegment->getZoneSize().x)/
					(Math::PI*3))//3
				);
				mLevelSegment->getActiveCamera()->setHardPos(0-mPos.x/2.5, mPos.y/2.5);
				
				
				{
				Vector3 absPos = mSceneNode->_getDerivedPosition();
				Real h = mLevelSegment->getWorld()->getHeightAt(absPos.x, absPos.z);
				if (absPos.y < (h+10)){
					mSceneNode->translate(Vector3(0,((h+10)-absPos.y),0), Ogre::Node::TS_WORLD);
				}
					
				}

				
				//roll(1, false);


			break;
		}

		list<Weapon*>::iterator it;

		for (it = mPrimaryWeapon.begin();it != mPrimaryWeapon.end();it++){
			(*it)->ceaseFire();
		}
		for (it = mSecondaryWeapon.begin();it != mSecondaryWeapon.end();it++){
			(*it)->ceaseFire();
		}

		if (mLockLevel == 0 && mHealth > 0){
			if (mPrimaryActivated){
			//if (Core::getSingleton()->getMouse()->isButtonDown(0)){
				fire(0);
			}
			//if (Core::getSingleton()->getMouse()->isButtonDown(1)){
			if (mSecondaryActivated){
				fire(1);
			}
			if (mSuperActivated){
				if (mSuperWeapon){
					if (mSuperWeapon->isReady()){
						mSuperWeapon->fire();
					}
				}
			}
		}
		for (it = mPrimaryWeapon.begin();it!=mPrimaryWeapon.end();it++){
			(*it)->update(timeDelta, parentTime+timeAlive());
		}
		for (it = mSecondaryWeapon.begin();it!=mSecondaryWeapon.end();it++){
			(*it)->update(timeDelta, parentTime+timeAlive());
		}
		if (mSuperWeapon) mSuperWeapon->update(timeDelta, parentTime+timeAlive());
		//mEntity->getSkeleton()->getRootBone()->get
		//mSceneNode->needUpdate();
		
		
		//skeletonRoot->SetBoundingBox (node->getBoundingBox());
		//mSceneNode->showBoundingBox(true);
		//mEntity->getBoundingBox().set
		
		//node->GetBoundingBox().SetNull(); 	
		
		
		/*Ogre::Bone* bone;
		bone = mEntity->getSkeleton()->getBone("root");
		Ogre::AxisAlignedBox ab = mEntity->getBoundingBox();
		mEntity->getBoundingBox()->setMaximum(0,0,0);
		Ogre::Vector3 bbMin = mBBMin+bone->_getDerivedPosition();
		Ogre::Vector3 bbMax = mBBMax+bone->_getDerivedPosition();
		bbMin.x = 0;
		bbMin.y = 0;
		bbMin.z = 0;

		ab.setMinimum(bbMin);
		ab.setMaximum(bbMax);*/
		
		/*Ogre::Bone* bone;
		bone = mEntity->getSkeleton()->getBone("root");
		mEntity->getMesh()->_setBounds(
			Ogre::AxisAlignedBox(
				mBBMin+bone->_getDerivedPosition(),
				mBBMax+bone->_getDerivedPosition()
			));;*/
		
		
		
		return false;
	};