当前位置: 首页>>代码示例>>C++>>正文


C++ BaseGameEntity::Pos方法代码示例

本文整理汇总了C++中BaseGameEntity::Pos方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseGameEntity::Pos方法的具体用法?C++ BaseGameEntity::Pos怎么用?C++ BaseGameEntity::Pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseGameEntity的用法示例。


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

示例1: me

void
StateZombieChase::Execute(Zombie* pZombie, u32 elapsedTime)
{
    Animate(pZombie, elapsedTime);
    //--------------------------------------------
    //
    // use physics model for executing
    //
    //--------------------------------------------
    // find target object
    ZombiePhysics* pPhysicsModel = pZombie->GetPhysicsModel();

    pPhysicsModel->ResetTarget();

    vector2df me(pZombie->Pos().X,pZombie->Pos().Y);
    std::vector<BaseGameEntity*> enties = EntityMgr.GetEntityListFromGroupID(ENTITY_TYPE_HUMAN);

    bool isTarget = false;
    for (std::vector<BaseGameEntity*>::iterator iter = enties.begin(); iter != enties.end(); iter++)
    {
        // find out close human, but now just get first human....
        BaseGameEntity* pEntity = *iter;
        f32 collisiondistance = me.getDistanceFrom(vector2df(pEntity->Pos().X, pEntity->Pos().Y));
        if(RANGE_ZOMBIE_TARGET_RECOGNITION >= collisiondistance)//ÀÎ½Ä ¹üÀ§ ¾È¿¡¼­ ÀÖ´ÂÁö?
        {
            if(RANGE_ZOMBIE_ATTACKMEELE_RECOGNITION >= collisiondistance)//¸Â ´ê¾Æ¼­ attack mode·Î º¯°æ
            {
                pZombie->GetFSM()->ChangeState(StateZombieAttackBite::Instance());
                isTarget = true;
                break;
            }
            else//¾ÆÁ÷ Á»ºñ°¡ °ø°ÝÇÒ Á¤µµ·Î °¡±õÁö ¾ÊÀ½
            {
                pPhysicsModel->SetTarget(b2Vec2(pEntity->Pos().X, pEntity->Pos().Y));
                isTarget = true;
                break;
            }
        }
    }
    if(!isTarget)//Ÿ°ÙÀ» †õÄ¡¸é ´Ù½Ã roam »óÅ·Î
    {
        //°Ë»ö µÇ¸é ÃßÀû ½ºÅ×ÀÌÆ®·Î º¯½Å
        pZombie->GetPhysicsModel()->GetBody()->m_maxForwardSpeed = ZOMBIE_ROAMSTATE_PHYSICS_MAX_FORWARDSPEED;
        pZombie->GetPhysicsModel()->GetBody()->m_maxDriveForce = ZOMBIE_ROAMSTATE_PHYSICS_MAX_FRONTFORCE;
        //RAN_LOG("Zombie[chase] changestate - Roam");
        pZombie->GetFSM()->ChangeState(StateZombieRoam::Instance());
    }

    pPhysicsModel->Update(elapsedTime);

    //--------------------------------------------
    //
    // apply executed result to object property
    //
    //--------------------------------------------
    b2Vec2 vec = pZombie->GetPhysicsModel()->GetPosition();
    f32 angle = pZombie->GetPhysicsModel()->GetAngle();
    pZombie->SetPos(vector3df(vec.x, vec.y, 0));
    pZombie->SetRotation(vector3df(0.f, 0.f, ANGLE_TO_RADIAN(angle)));
}
开发者ID:ptptomr,项目名称:project_ran,代码行数:60,代码来源:ZombieOwnedStates.cpp

示例2: CohesionPlus

//-------------------------------- Cohesion ------------------------------
//
//  returns a steering force that attempts to move the agent towards the
//  center of mass of the agents in its immediate area
//
//  USES SPACIAL PARTITIONING
//------------------------------------------------------------------------
Vector2D SteeringBehavior::CohesionPlus(const vector<Vehicle*> &neighbors)
{
	//first find the center of mass of all the agents
	Vector2D CenterOfMass, SteeringForce;

	int NeighborCount = 0;

	//iterate through the neighbors and sum up all the position vectors
	for (BaseGameEntity* pV = m_pVehicle->World()->CellSpace()->begin();
		!m_pVehicle->World()->CellSpace()->end();
		pV = m_pVehicle->World()->CellSpace()->next())
	{
		//make sure *this* agent isn't included in the calculations and that
		//the agent being examined is close enough
		if (pV != m_pVehicle)
		{
			CenterOfMass += pV->Pos();

			++NeighborCount;
		}
	}

	if (NeighborCount > 0)
	{
		//the center of mass is the average of the sum of positions
		CenterOfMass /= (double)NeighborCount;

		//now seek towards that position
		SteeringForce = Seek(CenterOfMass);
	}

	//the magnitude of cohesion is usually much larger than separation or
	//allignment so it usually helps to normalize it.
	return Vec2DNormalize(SteeringForce);
}
开发者ID:armagone,项目名称:SteeringBehavior,代码行数:42,代码来源:SteeringBehaviors.cpp

示例3:

//--------------------- GetPosOfClosestSwitch -----------------------------
//
//  returns the position of the closest visible switch that triggers the
//  door of the specified ID
//-----------------------------------------------------------------------------
Vector2D 
Raven_Game::GetPosOfClosestSwitch(Vector2D botPos, unsigned int doorID)const
{
  std::vector<unsigned int> SwitchIDs;
  
  //first we need to get the ids of the switches attached to this door
  std::vector<Raven_Door*>::const_iterator curDoor;
  for (curDoor = m_pMap->GetDoors().begin();
       curDoor != m_pMap->GetDoors().end();
       ++curDoor)
  {
    if ((*curDoor)->ID() == doorID)
    {
       SwitchIDs = (*curDoor)->GetSwitchIDs(); break;
    }
  }

  Vector2D closest;
  double ClosestDist = MaxDouble;
  
  //now test to see which one is closest and visible
  std::vector<unsigned int>::iterator it;
  for (it = SwitchIDs.begin(); it != SwitchIDs.end(); ++it)
  {
    BaseGameEntity* trig = EntityMgr->GetEntityFromID(*it);

    if (isLOSOkay(botPos, trig->Pos()))
    {
      double dist = Vec2DDistanceSq(botPos, trig->Pos());

      if ( dist < ClosestDist)
      {
        ClosestDist = dist;
        closest = trig->Pos();
      }
    }
  }

  return closest;
}
开发者ID:armagone,项目名称:Logique-Floue,代码行数:45,代码来源:Raven_Game.cpp

示例4:

void 
ChaseGroupState::Execute(ChaserPlayer* pPlayer, u32 elapsedTime)
{
	//sk

	//충돌 처리를 여기 넣는게 맞나?? - 현재 정의된 어떤 상태이든 총알에 영향을 받기 때문에
	//충돌 테스트 - 나중에 독립된 함수로 분리
	std::vector<BaseGameEntity*> vec = EntityMgr.GetCollidedEntites(pPlayer);
	if(vec.size() > 0)
	{
		//if there is bullet, chaser state should be changed.
		std::vector<BaseGameEntity*>::iterator iter;
		for (iter = vec.begin(); iter != vec.end(); iter++)
		{
			BaseGameEntity* pEntity = *iter;
			if(pEntity->Name() == "Bullet")
			{  
				pPlayer->GetFSM()->ChangeState(ChaseDeadState::Instance());
				return;
			}
		}
	}
	Animate(pPlayer, elapsedTime);

	//플레이어를 향해 가도록 설정 
	//*/
	//BaseGameEntity* pTargetEntity = EntityMgr.GetEntityFromID(12); 
	//주인공 케릭터를 얻어오는 방식이 수정되어야 함. 현재 id로 얻어 오는 방식은 ID가 계속 변하기 때문에 의미가 없음.
	std::vector<BaseGameEntity*>  fugivevec = EntityMgr.GetEntityListFromGroupID(100);
	BaseGameEntity* pTargetEntity = fugivevec[0];// 

	vector3df forwardobject = pTargetEntity->Pos()-pPlayer->Pos();
	pPlayer->SetPos(pPlayer->m_myAI.ObjectFlokcing(pPlayer->Pos(),pPlayer->Velocity(), pPlayer->MaxSpeed() ,
		elapsedTime,forwardobject.normalize(),pPlayer->m_uGroupID,pPlayer));
	/*/테스트용 patrol
	pPlayer->SetPos(pPlayer->m_myAI.ObjectFlokcing(pPlayer->Pos(),pPlayer->Velocity(), pPlayer->MaxSpeed() ,
		elapsedTime,pPlayer->Heading(),pPlayer->m_uGroupID,pPlayer));
	//*/
	//end sk  
	
}
开发者ID:ptptomr,项目名称:project_ran,代码行数:41,代码来源:ChaserOwnedStates.cpp

示例5: SeparationPlus

//---------------------------- Separation --------------------------------
//
// this calculates a force repelling from the other neighbors
//
//  USES SPACIAL PARTITIONING
//------------------------------------------------------------------------
Vector2D SteeringBehavior::SeparationPlus(const vector<Vehicle*> &neighbors)
{
	Vector2D SteeringForce;

	//iterate through the neighbors and sum up all the position vectors
	for (BaseGameEntity* pV = m_pVehicle->World()->CellSpace()->begin();
		!m_pVehicle->World()->CellSpace()->end();
		pV = m_pVehicle->World()->CellSpace()->next())
	{
		//make sure this agent isn't included in the calculations and that
		//the agent being examined is close enough
		if (pV != m_pVehicle)
		{
			Vector2D ToAgent = m_pVehicle->Pos() - pV->Pos();

			//scale the force inversely proportional to the agents distance  
			//from its neighbor.
			SteeringForce += Vec2DNormalize(ToAgent) / ToAgent.Length();
		}

	}

	return SteeringForce;
}
开发者ID:armagone,项目名称:SteeringBehavior,代码行数:30,代码来源:SteeringBehaviors.cpp

示例6: if

void 
IdleCamera::Execute(BaseCamera* pCamera, u32 elapsedTime)
{
	// follow target
	int id = pCamera->GetTargetEntityID();
	if (id < 0)
	{
		return;
	}

	BaseGameEntity* pTargetEntity = EntityMgr.GetEntityFromID(id);
	vector3df targetPos = pTargetEntity->Pos();	

	vector3df newPos = vector3df(targetPos.X, targetPos.Y, pCamera->Pos().Z);
	static EventReceiver* pEventReceiver = &(EventRcv);
	/*if (pEventReceiver->IsKeyDown(KEY_KEY_W))
	{
		pEventReceiver->SetKeyDown(KEY_KEY_W, false);

		newPos.Z += 10.0f;
		if (0 <= newPos.Z)
		{
			newPos.Z = -10.f;
		}
	}
	else if (pEventReceiver->IsKeyDown(KEY_KEY_S))
	{
		pEventReceiver->SetKeyDown(KEY_KEY_S, false);

		newPos.Z -= 10.0f;		
	}*/
		
	//pCamera->SetDestPos(newPos, true);
	pCamera->SetPos(newPos);
	pCamera->SetLookAt(vector3df(newPos.X, newPos.Y, targetPos.Z));
}
开发者ID:ptptomr,项目名称:project_igf_2013,代码行数:36,代码来源:BaseCameraOwnedStates.cpp

示例7: Render

//------------------------------ Render ----------------------------------
//------------------------------------------------------------------------
void GameWorld::Render()
{
	gdi->TransparentText();

	//render any walls
	gdi->BlackPen();
	for (unsigned int w = 0; w < m_Walls.size(); ++w)
	{
		m_Walls[w].Render(true);  //true flag shows normals
	}

	//render any obstacles
	gdi->BlackPen();

	for (unsigned int ob = 0; ob < m_Obstacles.size(); ++ob)
	{
		gdi->Circle(m_Obstacles[ob]->Pos(), m_Obstacles[ob]->BRadius());
	}

	//render the agents
	for (unsigned int a = 0; a < m_Vehicles.size(); ++a)
	{
		m_Vehicles[a]->Render();

		//render cell partitioning stuff
		if (m_bShowCellSpaceInfo && a == 0)
		{
			gdi->HollowBrush();
			InvertedAABBox2D box(m_Vehicles[a]->Pos() - Vector2D(Prm.ViewDistance, Prm.ViewDistance),
				m_Vehicles[a]->Pos() + Vector2D(Prm.ViewDistance, Prm.ViewDistance));
			box.Render();

			gdi->RedPen();
			CellSpace()->CalculateNeighbors(m_Vehicles[a]->Pos(), Prm.ViewDistance);
			for (BaseGameEntity* pV = CellSpace()->begin(); !CellSpace()->end(); pV = CellSpace()->next())
			{
				gdi->Circle(pV->Pos(), pV->BRadius());
			}

			gdi->GreenPen();
			gdi->Circle(m_Vehicles[a]->Pos(), Prm.ViewDistance);
		}
	}

	//#define CROSSHAIR
#ifdef CROSSHAIR
	//and finally the crosshair
	gdi->RedPen();
	gdi->Circle(m_vCrosshair, 4);
	gdi->Line(m_vCrosshair.x - 8, m_vCrosshair.y, m_vCrosshair.x + 8, m_vCrosshair.y);
	gdi->Line(m_vCrosshair.x, m_vCrosshair.y - 8, m_vCrosshair.x, m_vCrosshair.y + 8);
	gdi->TextAtPos(5, cyClient() - 20, "Click to move crosshair");
#endif


	//gdi->TextAtPos(cxClient() -120, cyClient() - 20, "Press R to reset");

	gdi->TextColor(Cgdi::grey);
	if (RenderPath())
	{
		gdi->TextAtPos((int)(cxClient() / 2.0f - 80), cyClient() - 20, "Press 'U' for random path");

		m_pPath->Render();
	}

	if (RenderFPS())
	{
		gdi->TextColor(Cgdi::grey);
		gdi->TextAtPos(5, cyClient() - 20, ttos(1.0 / m_dAvFrameTime));
	}

	if (m_bShowCellSpaceInfo)
	{
		m_pCellSpace->RenderCells();
	}

}
开发者ID:armagone,项目名称:SteeringBehavior,代码行数:79,代码来源:GameWorld.cpp

示例8: Pos

void
Human::DrawExtraInfo()
{
#ifdef AI_TEST_DISPLAY_HUMAN_STATE
//---------
	//sk test
		
	/*/ //좌표 보정전
	gui::IGUIFont* font2 = IrrDvc.GetDevice()->getGUIEnvironment()->getBuiltInFont();
    u32 time = IrrDvc.GetDevice()->getTimer()->getTime();

    core::stringw temp;
    temp = core::stringw(time).c_str(); //숫자를 stringw로 변환하는 루틴

	u32 coordposX = Pos().X;
	u32 coordposY = Pos().Y;

    if (font2)
		font2->draw(temp,core::rect<s32>(coordposX,coordposY,coordposX+50,coordposY+60), video::SColor(255,time % 255,time % 255,255));
		
	/*/ //좌표 보정 후 
	std::vector<BaseGameEntity*> enties = EntityMgr.GetEntityListFromGroupID(ENTITY_TYPE_VEHICLE);
	std::vector<BaseGameEntity*>::iterator iter = enties.begin();
	// find out close vehicle, but now just get first vehicle....
	BaseGameEntity* pTargetEntity = *iter;

	
	m_uDifferenceXOrgFugtivePlayer = m_uScreenHalfWidth - pTargetEntity->Pos().X * LOCALCOORD_SCREENCOORD_RATIO;//need optimization. change to once call.
	m_uDifferenceYOrgFugtivePlayer = m_uScreenHalfHeight + pTargetEntity->Pos().Y * LOCALCOORD_SCREENCOORD_RATIO;//need optimization. change to once call.

	/*
		m_uDifferenceXOrgFugtivePlayer = m_uScreenHalfWidth - Pos().X * LOCALCOORD_SCREENCOORD_RATIO;//need optimization. change to once call.
	m_uDifferenceYOrgFugtivePlayer = m_uScreenHalfHeight + Pos().Y * LOCALCOORD_SCREENCOORD_RATIO;//need optimization. change to once call.
*/
	gui::IGUIFont* font2 = IrrDvc.GetDevice()->getGUIEnvironment()->getBuiltInFont();
    u32 time = IrrDvc.GetDevice()->getTimer()->getTime();
	core::stringw temp;

	u32 coordposX = m_uDifferenceXOrgFugtivePlayer + Pos().X * LOCALCOORD_SCREENCOORD_RATIO;
	u32 coordposY = m_uDifferenceYOrgFugtivePlayer - Pos().Y * LOCALCOORD_SCREENCOORD_RATIO;

	
	core::stringw prefix;
    if (font2)
	{
		temp = core::stringw(time).c_str(); //숫자를 stringw로 변환하는 루틴
		font2->draw(temp,core::rect<s32>(coordposX,coordposY,coordposX+50,coordposY+60), video::SColor(255,time % 255,time % 255,255));

		temp = GetStateName();
		prefix = "state:";
		font2->draw(prefix+temp,core::rect<s32>(coordposX,coordposY+10,coordposX+50,coordposY+60), video::SColor(255,time % 255,time % 255,255));

		temp = core::stringw(m_fCurrentLifeEnergy).c_str(); //숫자를 stringw로 변환하는 루틴
		prefix = "E:";
		font2->draw(prefix+temp,core::rect<s32>(coordposX,coordposY+20,coordposX+50,coordposY+60), video::SColor(255,time % 255,time % 255,255));
	}
#endif //AI_TEST_DISPLAY_HUMAN_STATE
	
	//*/
//--------
}
开发者ID:ptptomr,项目名称:project_ran,代码行数:61,代码来源:Human.cpp

示例9: me

bool
Human::Update(u32 elapsedTime)
{
	//--------------------------------------------
	//
	// update entity 
	//
	//--------------------------------------------
	MovingEntity::Update(elapsedTime);

#ifdef HUMAN_AILEVEL_STARVATION_SYSTEM
	//effect which are applied independently of state
	if(m_fCurrentLifeEnergy>0)
		m_fCurrentLifeEnergy-= (elapsedTime * HUMAN_ENERGYDECREASE_PER_MILLISECOND);
	else
		m_fCurrentLifeEnergy=0;
	if(m_fCurrentLifeEnergy < HUMAN_THRESHOLD_TO_STARVATION &&
		this-> m_State != HUMAN_STATE_STARVATION &&
		this-> m_State != HUMAN_STATE_DEATH){
		m_State = HUMAN_STATE_STARVATION;
		GetFSM()->ChangeState(StateHumanStarvation::Instance());
	}
#endif
#ifdef HUMAN_AILEVEL_EAT_SYSTEM
	vector2df me(this->Pos().X,this->Pos().Y);
	std::vector<BaseGameEntity*> enties = EntityMgr.GetEntityListFromGroupID(ENTITY_TYPE_ITEM_FOOD);
	
	//bool isTarget = false;
	for (std::vector<BaseGameEntity*>::iterator iter = enties.begin(); iter != enties.end(); iter++)
	{
		// find out close human, but now just get first human....
		BaseGameEntity* pEntity = *iter;
		f32 collisiondistance = me.getDistanceFrom(vector2df(pEntity->Pos().X, pEntity->Pos().Y));
		if(RANGE_HUMAN_EAT_RECOGNITION >= collisiondistance)
		{
			//식량 섭취
			m_fCurrentLifeEnergy = HUMAN_MAX_LIFE_ENERGY_DEFAULT;
			HumanPhysics* pPhysicsModel = this->GetPhysicsModel();
			pPhysicsModel->ResetTarget();
			GetFSM()->ChangeState(StateHumanHide::Instance());	
			//해당 아이템에 소멸 메세지 전달
			int idfood = pEntity->ID();
			Dispatcher->DispatchMsg(SEND_MSG_IMMEDIATELY, // time delay
								ID(),        // ID of sender
								idfood,	  // ID of recipient
								MSG_TYPE_FOOD_DISAPPEAR,	  // the message
								NO_ADDITIONAL_INFO); 

			//((BaseItem*)pEntity)->GetFSM()->ChangeState(StateBaseItemDisappear::Instance());
			break;
		}
	}	
#endif


	if (m_pStateMachine)
	{
		m_pStateMachine->Update(elapsedTime);
	}

	//이전 프레임의 위치가 필요하므로 저장한다.(업데이트 되기전의 이전 좌표)
	m_VecTemporayPos.X = Pos().X;
	m_VecTemporayPos.Y = Pos().Y;

	//--------------------------------------------
	//
	// sync property with scene node
	//
	//--------------------------------------------
	if (m_p2DSprite)
	{
		m_p2DSprite->setPosition(Pos());
	}

	return this->IsAlived();
}
开发者ID:ptptomr,项目名称:project_ran,代码行数:76,代码来源:Human.cpp


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