您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetPosX函数代码示例

51自学网 2021-06-01 21:13:15
  C++
这篇教程C++ GetPosX函数代码示例写得很实用,希望能帮到您。

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

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

示例1: ChangeAIState

void CPatrolEnemy::Update(float fElapsedTime){	CBaseEnemy::Update(fElapsedTime);	if(GetCurrentHP() <= 0)		ChangeAIState(pDead);	else	{		tVector2D Result;		Result.fX = GetTargetPosition().fX - GetPosX();		Result.fY = GetTargetPosition().fY - GetPosY();		float Distance = sqrt(Result.fX*Result.fX + Result.fY*Result.fY);		if(Distance <= GetSightRange())		{			ChangeAIState(pActive);			this->ReturnAIState();		}		else			ChangeAIState(Patrol);		switch(ReturnAIState())		{		case Patrol:			{				SetPosX((GetPosX() + GetBaseVelX() * fElapsedTime));				if(GetPosX() <= 0)				{					SetPosX(0);					SetCurrentDist(0);					SetSpeed(-1*GetSpeed());				}				SetCurrentDist(GetCurrentDist() + (fabs(GetBaseVelX()) * fElapsedTime));				if(GetCurrentDist() >= GetMaxDist())				{					SetCurrentDist(0);					SetSpeed(-1*GetSpeed());				}				SetBaseVelX(GetBaseVelX() + GetSpeed() * fElapsedTime);				if(GetBaseVelX() > 50)					SetBaseVelX(50);				else if(GetBaseVelX() < -50)					SetBaseVelX(-50);			}			break;		case pActive:			{				SetSpeed(-1*GetSpeed());				SetBaseVelX(0);			}			break;		case pDead:			{			}			break;		};	}}
开发者ID:Warbeleth,项目名称:cyberneticwarrior,代码行数:64,


示例2: switch

bool cMinecart::TestBlockCollision(NIBBLETYPE a_RailMeta){	switch (a_RailMeta)	{		case E_META_RAIL_ZM_ZP:		{			if (GetSpeedZ() > 0)			{				BLOCKTYPE Block = m_World->GetBlock(POSX_TOINT, POSY_TOINT, (int)ceil(GetPosZ()));				if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block))				{					// We could try to detect a block in front based purely on coordinates, but xoft made a bounding box system - why not use? :P					cBoundingBox bbBlock(Vector3d(POSX_TOINT, POSY_TOINT, (int)ceil(GetPosZ())), 0.5, 1);					cBoundingBox bbMinecart(Vector3d(GetPosX(), floor(GetPosY()), GetPosZ()), GetWidth() / 2, GetHeight());					if (bbBlock.DoesIntersect(bbMinecart))					{						SetSpeed(0, 0, 0);						SetPosZ(floor(GetPosZ()) + 0.4);						return true;					}				}			}			else if (GetSpeedZ() < 0)			{				BLOCKTYPE Block = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT - 1);				if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block))				{					cBoundingBox bbBlock(Vector3d(POSX_TOINT, POSY_TOINT, POSZ_TOINT - 1), 0.5, 1);					cBoundingBox bbMinecart(Vector3d(GetPosX(), floor(GetPosY()), GetPosZ() - 1), GetWidth() / 2, GetHeight());					if (bbBlock.DoesIntersect(bbMinecart))					{						SetSpeed(0, 0, 0);						SetPosZ(floor(GetPosZ()) + 0.65);						return true;					}				}			}			break;		}		case E_META_RAIL_XM_XP:		{			if (GetSpeedX() > 0)			{				BLOCKTYPE Block = m_World->GetBlock((int)ceil(GetPosX()), POSY_TOINT, POSZ_TOINT);				if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block))				{					cBoundingBox bbBlock(Vector3d((int)ceil(GetPosX()), POSY_TOINT, POSZ_TOINT), 0.5, 1);					cBoundingBox bbMinecart(Vector3d(GetPosX(), floor(GetPosY()), GetPosZ()), GetWidth() / 2, GetHeight());					if (bbBlock.DoesIntersect(bbMinecart))					{						SetSpeed(0, 0, 0);						SetPosX(floor(GetPosX()) + 0.4);						return true;					}				}			}			else if (GetSpeedX() < 0)			{				BLOCKTYPE Block = m_World->GetBlock(POSX_TOINT - 1, POSY_TOINT, POSZ_TOINT);				if (!IsBlockRail(Block) && cBlockInfo::IsSolid(Block))				{					cBoundingBox bbBlock(Vector3d(POSX_TOINT - 1, POSY_TOINT, POSZ_TOINT), 0.5, 1);					cBoundingBox bbMinecart(Vector3d(GetPosX() - 1, floor(GetPosY()), GetPosZ()), GetWidth() / 2, GetHeight());					if (bbBlock.DoesIntersect(bbMinecart))					{						SetSpeed(0, 0, 0);						SetPosX(floor(GetPosX()) + 0.65);						return true;					}				}			}			break;		}		case E_META_RAIL_CURVED_ZM_XM:		case E_META_RAIL_CURVED_ZM_XP:		case E_META_RAIL_CURVED_ZP_XM:		case E_META_RAIL_CURVED_ZP_XP:		{			BLOCKTYPE BlockXM = m_World->GetBlock(POSX_TOINT - 1, POSY_TOINT, POSZ_TOINT);			BLOCKTYPE BlockXP = m_World->GetBlock(POSX_TOINT + 1, POSY_TOINT, POSZ_TOINT);			BLOCKTYPE BlockZM = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT - 1);			BLOCKTYPE BlockZP = m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT + 1);			if (				(!IsBlockRail(BlockXM) && cBlockInfo::IsSolid(BlockXM)) ||				(!IsBlockRail(BlockXP) && cBlockInfo::IsSolid(BlockXP)) ||				(!IsBlockRail(BlockZM) && cBlockInfo::IsSolid(BlockZM)) ||				(!IsBlockRail(BlockZP) && cBlockInfo::IsSolid(BlockZP))				)			{				SetSpeed(0, 0, 0);				SetPosition(POSX_TOINT + 0.5, GetPosY(), POSZ_TOINT + 0.5);				return true;			}			break;		}		default: break;//.........这里部分代码省略.........
开发者ID:w00tc0d3,项目名称:MCServer,代码行数:101,


示例3: Destroy

bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI){	if ((TDI.Attacker != NULL) && TDI.Attacker->IsPlayer() && ((cPlayer *)TDI.Attacker)->IsGameModeCreative())	{		Destroy();		TDI.FinalDamage = GetMaxHealth();  // Instant hit for creative		SetInvulnerableTicks(0);		return super::DoTakeDamage(TDI);  // No drops for creative	}	m_LastDamage = TDI.FinalDamage;	if (!super::DoTakeDamage(TDI))	{		return false;	}	m_World->BroadcastEntityMetadata(*this);	if (GetHealth() <= 0)	{		Destroy();				cItems Drops;		switch (m_Payload)		{			case mpNone:			{				Drops.push_back(cItem(E_ITEM_MINECART, 1, 0));				break;			}			case mpChest:			{				Drops.push_back(cItem(E_ITEM_CHEST_MINECART, 1, 0));				break;			}			case mpFurnace:			{				Drops.push_back(cItem(E_ITEM_FURNACE_MINECART, 1, 0));				break;			}			case mpTNT:			{				Drops.push_back(cItem(E_ITEM_MINECART_WITH_TNT, 1, 0));				break;			}			case mpHopper:			{				Drops.push_back(cItem(E_ITEM_MINECART_WITH_HOPPER, 1, 0));				break;			}			default:			{				ASSERT(!"Unhandled minecart type when spawning pickup!");				return true;			}		}				m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());	}	return true;}
开发者ID:w00tc0d3,项目名称:MCServer,代码行数:61,


示例4: CPickup

CEnemy::~CEnemy( ){	if(m_SpellType == OBJ_WIND)	{		if(dynamic_cast<AIStateWind*>(currState))		{			if(((AIStateWind*)currState)->GetFlock())			{				((AIStateWind*)currState)->GetFlock()->RemoveMember(this);			}		}	}	if( currState ) 		delete currState;	CPickup * newpickup = new CPickup();	newpickup->SetPosX(GetPosX());	newpickup->SetPosY(GetPosY());	newpickup->SetActive(true);	if(!(rand() % 20))	{		newpickup->SetType(OBJ_T3SPELL);		//newpickup->SetImage( CSGD_TextureManager::GetInstance()->LoadTexture("resource/graphics/Lapid_SuperEnergy.png"));		newpickup->SetWidth(32);		newpickup->SetHeight(32);		CEmitter* hahaiworknow = CParticleManager::GetInstance()->LoadEmitter("resource/data/powerSpecial.lapipt",newpickup->GetPosX(),newpickup->GetPosY());		newpickup->SetEmitter(hahaiworknow);		CParticleManager::GetInstance()->AddEmitter(newpickup->GetEmitter());	}	else	{		newpickup->SetType(OBJ_ENERGY);		if(GetEleType() == OBJ_EARTH)		{			newpickup->SetEleType(OBJ_EARTH);			//newpickup->SetImage( CSGD_TextureManager::GetInstance()->LoadTexture("resource/graphics/Lapid_EarthEnergy.png"));			newpickup->SetWidth(64);			newpickup->SetHeight(48);			CEmitter* hahaiworknow = CParticleManager::GetInstance()->LoadEmitter("resource/data/powerEarth.lapipt",newpickup->GetPosX(),newpickup->GetPosY());			newpickup->SetEmitter(hahaiworknow);			CParticleManager::GetInstance()->AddEmitter(newpickup->GetEmitter());		}		else if(GetEleType() == OBJ_FIRE)		{			newpickup->SetEleType(OBJ_FIRE);			//newpickup->SetImage( CSGD_TextureManager::GetInstance()->LoadTexture("resource/graphics/Lapid_FireEnergy.png"));			newpickup->SetWidth(64);			newpickup->SetHeight(48);			CEmitter* hahaiworknow = CParticleManager::GetInstance()->LoadEmitter("resource/data/powerFire.lapipt",newpickup->GetPosX(),newpickup->GetPosY());			newpickup->SetEmitter(hahaiworknow);			CParticleManager::GetInstance()->AddEmitter(newpickup->GetEmitter());		}		else if(GetEleType() == OBJ_ICE)		{			newpickup->SetEleType(OBJ_ICE);			//newpickup->SetImage( CSGD_TextureManager::GetInstance()->LoadTexture("resource/graphics/Lapid_IceEnergy.png"));			newpickup->SetWidth(64);			newpickup->SetHeight(48);			CEmitter* hahaiworknow = CParticleManager::GetInstance()->LoadEmitter("resource/data/powerIce.lapipt",newpickup->GetPosX(),newpickup->GetPosY());			newpickup->SetEmitter(hahaiworknow);			CParticleManager::GetInstance()->AddEmitter(newpickup->GetEmitter());		}		else		{			newpickup->SetEleType(OBJ_WIND);			//newpickup->SetImage( CSGD_TextureManager::GetInstance()->LoadTexture("resource/graphics/Lapid_WindEnergy.png"));			newpickup->SetWidth(64);			newpickup->SetHeight(58);			CEmitter* hahaiworknow = CParticleManager::GetInstance()->LoadEmitter("resource/data/powerWind.lapipt",newpickup->GetPosX(),newpickup->GetPosY());			newpickup->SetEmitter(hahaiworknow);			CParticleManager::GetInstance()->AddEmitter(newpickup->GetEmitter());		}	}	Corona_ObjectManager::GetInstance()->AddObject(newpickup);	newpickup->Release();}
开发者ID:FreeZe5K,项目名称:lapidem,代码行数:79,


示例5: SetHealth

void CEnemy::Update( float fElapsedTime ){	if( ! ( CGameplayState::GetInstance()->GetLevel()->GetTile((int)GetPosX(), (int)GetPosY() ) ) )	{		SetHealth(0);	}	if(m_nHealth >0)	{		Frame * currFrame = (animation->GetAllFrames())[animation->GetFrame()];		if(LastFrame && currAnimation == 2 || currAnimation == 1)		{			float oldheight = m_fLastPosition + (LastFrame->DrawRect.bottom - LastFrame->DrawRect.top) * m_fScale;			while(oldheight < GetPosY() + (currFrame->DrawRect.bottom - currFrame->DrawRect.top) * m_fScale)			{				SetPosY(GetPosY() - 1);			}			while(oldheight > GetPosY() + (currFrame->DrawRect.bottom - currFrame->DrawRect.top) * m_fScale)			{				SetPosY(GetPosY() + 1);			}		}		LastFrame = currFrame;		m_fLastPosition = GetPosY();		if(!m_bKnockBack)		{			m_fShotTimer = m_fShotTimer - fElapsedTime;			if( 0.0f == m_fWaitTimer )			{					if(m_SpellType == OBJ_WIND)				{					CBase::Update( fElapsedTime );				}				else				{					CCharacter::Update( fElapsedTime );				}				m_nAttackWho = currState->Update( fElapsedTime, this );				if( m_nAttackWho && m_fShotTimer < 0 )				{					m_fWaitTimer += fElapsedTime;					m_fShotTimer = 2.0f;					animation->Reset();					SetAnimation(m_nAnimation,2);				}			}			else			{				m_fWaitTimer = m_fWaitTimer + fElapsedTime;				/*if(m_SpellType !=OBJ_WIND)				SetPosY( GetPosY( ) + 150.0f * fElapsedTime );*/				char* pleasework = animation->GetTrigger();				if(strcmp(pleasework, "Done") == 0)				{						if( 1 == m_nAttackWho )					{						currState->Attack( CGameplayState::GetInstance( )->GetPlayerOne( ), this );					}					else if( 2 == m_nAttackWho )					{						currState->Attack( CGameplayState::GetInstance( )->GetPlayerTwo( ), this );					}					animation->Reset();					SetAnimation(m_nAnimation,0);					m_fWaitTimer = 0.0f;				}			}		}		else		{			if(m_fKnockBack < 0)			{				m_bKnockBack = false;			}			else			{				CCharacter::Update(fElapsedTime);				m_fKnockBack-=fElapsedTime * 100;			}		}		if(m_bBurning)		{			m_fBurnTimer -= fElapsedTime;			if(m_fBurnTimer <= 0)			{//.........这里部分代码省略.........
开发者ID:FreeZe5K,项目名称:lapidem,代码行数:101,


示例6: GetSpeed

void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude){	// Process packet sending every two ticks	if (GetWorld()->GetWorldAge() % 2 == 0)	{		double SpeedSqr = GetSpeed().SqrLength();		if (SpeedSqr == 0.0)		{			// Speed is zero, send this to clients once only as well as an absolute position			if (!m_bHasSentNoSpeed)			{				m_World->BroadcastEntityVelocity(*this, a_Exclude);				m_World->BroadcastTeleportEntity(*this, a_Exclude);				m_bHasSentNoSpeed = true;			}		}		else		{			// Movin'			m_World->BroadcastEntityVelocity(*this, a_Exclude);			m_bHasSentNoSpeed = false;		}				// TODO: Pickups move disgracefully if relative move packets are sent as opposed to just velocity. Have a system to send relmove only when SetPosXXX() is called with a large difference in position		int DiffX = (int)(floor(GetPosX() * 32.0) - floor(m_LastPos.x * 32.0));		int DiffY = (int)(floor(GetPosY() * 32.0) - floor(m_LastPos.y * 32.0));		int DiffZ = (int)(floor(GetPosZ() * 32.0) - floor(m_LastPos.z * 32.0));		if ((DiffX != 0) || (DiffY != 0) || (DiffZ != 0)) // Have we moved?		{			if ((abs(DiffX) <= 127) && (abs(DiffY) <= 127) && (abs(DiffZ) <= 127)) // Limitations of a Byte			{				// Difference within Byte limitations, use a relative move packet				if (m_bDirtyOrientation)				{					m_World->BroadcastEntityRelMoveLook(*this, (char)DiffX, (char)DiffY, (char)DiffZ, a_Exclude);					m_bDirtyOrientation = false;				}				else				{					m_World->BroadcastEntityRelMove(*this, (char)DiffX, (char)DiffY, (char)DiffZ, a_Exclude);				}				// Clients seem to store two positions, one for the velocity packet and one for the teleport/relmove packet				// The latter is only changed with a relmove/teleport, and m_LastPos stores this position				m_LastPos = GetPosition();			}			else			{				// Too big a movement, do a teleport				m_World->BroadcastTeleportEntity(*this, a_Exclude);				m_LastPos = GetPosition(); // See above				m_bDirtyOrientation = false;			}		}		if (m_bDirtyHead)		{			m_World->BroadcastEntityHeadLook(*this, a_Exclude);			m_bDirtyHead = false;		}		if (m_bDirtyOrientation)		{			// Send individual update in case above (sending with rel-move packet) wasn't done			GetWorld()->BroadcastEntityLook(*this, a_Exclude);			m_bDirtyOrientation = false;		}	}}
开发者ID:Kortak,项目名称:MCServer,代码行数:68,


示例7: TakeDamage

void cEntity::TickBurning(cChunk & a_Chunk){	// Remember the current burning state:	bool HasBeenBurning = (m_TicksLeftBurning > 0);	if (m_World->IsWeatherWet())	{		if (POSY_TOINT > m_World->GetHeight(POSX_TOINT, POSZ_TOINT))		{			m_TicksLeftBurning = 0;		}			}		// Do the burning damage:	if (m_TicksLeftBurning > 0)	{		m_TicksSinceLastBurnDamage++;		if (m_TicksSinceLastBurnDamage >= BURN_TICKS_PER_DAMAGE)		{			if (!m_IsFireproof)			{				TakeDamage(dtOnFire, NULL, BURN_DAMAGE, 0);			}			m_TicksSinceLastBurnDamage = 0;		}		m_TicksLeftBurning--;	}		// Update the burning times, based on surroundings:	int MinRelX = (int)floor(GetPosX() - m_Width / 2) - a_Chunk.GetPosX() * cChunkDef::Width;	int MaxRelX = (int)floor(GetPosX() + m_Width / 2) - a_Chunk.GetPosX() * cChunkDef::Width;	int MinRelZ = (int)floor(GetPosZ() - m_Width / 2) - a_Chunk.GetPosZ() * cChunkDef::Width;	int MaxRelZ = (int)floor(GetPosZ() + m_Width / 2) - a_Chunk.GetPosZ() * cChunkDef::Width;	int MinY = std::max(0, std::min(cChunkDef::Height - 1, POSY_TOINT));	int MaxY = std::max(0, std::min(cChunkDef::Height - 1, (int)ceil (GetPosY() + m_Height)));	bool HasWater = false;	bool HasLava = false;	bool HasFire = false;		for (int x = MinRelX; x <= MaxRelX; x++)	{		for (int z = MinRelZ; z <= MaxRelZ; z++)		{			int RelX = x;			int RelZ = z;			for (int y = MinY; y <= MaxY; y++)			{				BLOCKTYPE Block;				a_Chunk.UnboundedRelGetBlockType(RelX, y, RelZ, Block);								switch (Block)				{					case E_BLOCK_FIRE:					{						HasFire = true;						break;					}					case E_BLOCK_LAVA:					case E_BLOCK_STATIONARY_LAVA:					{						HasLava = true;						break;					}					case E_BLOCK_STATIONARY_WATER:					case E_BLOCK_WATER:					{						HasWater = true;						break;					}				}  // switch (BlockType)			}  // for y		}  // for z	}  // for x		if (HasWater)	{		// Extinguish the fire		m_TicksLeftBurning = 0;	}		if (HasLava)	{		// Burn:		m_TicksLeftBurning = BURN_TICKS;				// Periodically damage:		m_TicksSinceLastLavaDamage++;		if (m_TicksSinceLastLavaDamage >= LAVA_TICKS_PER_DAMAGE)		{			if (!m_IsFireproof)			{				TakeDamage(dtLavaContact, NULL, LAVA_DAMAGE, 0);			}			m_TicksSinceLastLavaDamage = 0;		}	}	else	{		m_TicksSinceLastLavaDamage = 0;//.........这里部分代码省略.........
开发者ID:Kortak,项目名称:MCServer,代码行数:101,


示例8: DoTakeDamage

void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI){	super::DoTakeDamage(a_TDI);	if((m_SoundHurt != "") && (m_Health > 0)) m_World->BroadcastSoundEffect(m_SoundHurt, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);	if (a_TDI.Attacker != NULL)	{		m_Target = a_TDI.Attacker;		AddReference(m_Target);	}}
开发者ID:Noraaron1,项目名称:MCServer,代码行数:10,


示例9: switch

void cMonster::KilledBy(cEntity * a_Killer){	super::KilledBy(a_Killer);	if (m_SoundHurt != "")	{		m_World->BroadcastSoundEffect(m_SoundDeath, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f);	}	int Reward;	switch (m_MobType)	{		// Animals		case cMonster::mtChicken:		case cMonster::mtCow:		case cMonster::mtHorse:		case cMonster::mtPig:		case cMonster::mtSheep:		case cMonster::mtSquid:		case cMonster::mtMooshroom:		case cMonster::mtOcelot:		case cMonster::mtWolf:		{			Reward = m_World->GetTickRandomNumber(2) + 1;			break;		}		// Monsters		case cMonster::mtCaveSpider:		case cMonster::mtCreeper:		case cMonster::mtEnderman:		case cMonster::mtGhast:		case cMonster::mtSilverfish:		case cMonster::mtSkeleton:		case cMonster::mtSpider:		case cMonster::mtWitch:		case cMonster::mtZombie:		case cMonster::mtZombiePigman:		case cMonster::mtSlime:		case cMonster::mtMagmaCube:		{			Reward = 6 + (m_World->GetTickRandomNumber(2));			break;		}		case cMonster::mtBlaze:		{			Reward = 10;			break;		}		// Bosses		case cMonster::mtEnderDragon:		{			Reward = 12000;			break;		}		case cMonster::mtWither:		{			Reward = 50;			break;		}		default:		{			Reward = 0;			break;		}	}	if ((a_Killer != NULL) && (!IsBaby()))	{		m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);	}	m_DestroyTimer = 0;}
开发者ID:axisd,项目名称:MCServer,代码行数:72,


示例10: ASSERT

//.........这里部分代码省略.........	{		return;	}	if(obj->GetTypeId() == TYPEID_CORPSE)	{		m_corpses.erase(((Corpse*)obj));	}	if(!obj->GetMapCell())	{		/* set the map cell correctly */		if(obj->GetPositionX() >= _maxX || obj->GetPositionX() <= _minY ||			obj->GetPositionY() >= _maxY || obj->GetPositionY() <= _minY)		{			// do nothing		}		else		{			obj->SetMapCell(this->GetCellByCoords(obj->GetPositionX(), obj->GetPositionY()));		}			}	if(obj->GetMapCell())	{		ASSERT(obj->GetMapCell());			// Remove object from cell		obj->GetMapCell()->RemoveObject(obj);			// Unset object's cell		obj->SetMapCell(NULL);	}	// Clear any updates pending	if(obj->GetTypeId() == TYPEID_PLAYER)	{		_processQueue.erase( static_cast< Player* >( obj ) );		static_cast< Player* >( obj )->ClearAllPendingUpdates();	}		// Remove object from all objects 'seeing' him	for (Object::InRangeSet::iterator iter = obj->GetInRangeSetBegin();		iter != obj->GetInRangeSetEnd(); ++iter)	{		if( (*iter) )		{			if( (*iter)->GetTypeId() == TYPEID_PLAYER )			{				if( static_cast< Player* >( *iter )->IsVisible( obj ) && static_cast< Player* >( *iter )->m_TransporterGUID != obj->GetGUID() )					static_cast< Player* >( *iter )->PushOutOfRange(obj->GetNewGUID());			}			(*iter)->RemoveInRangeObject(obj);		}	}		// Clear object's in-range set	obj->ClearInRangeSet();	// If it's a player - update his nearby cells	if(!_shutdown && obj->GetTypeId() == TYPEID_PLAYER)	{		// get x/y		if(obj->GetPositionX() >= _maxX || obj->GetPositionX() <= _minY ||			obj->GetPositionY() >= _maxY || obj->GetPositionY() <= _minY)		{			// do nothing		}		else		{			uint32 x = GetPosX(obj->GetPositionX());			uint32 y = GetPosY(obj->GetPositionY());			UpdateCellActivity(x, y, 2);		}		m_PlayerStorage.erase( static_cast< Player* >( obj )->GetLowGUID() );	}	// Remove the session from our set if it is a player.	if(plObj)	{		for(set<Object*>::iterator itr = _mapWideStaticObjects.begin(); itr != _mapWideStaticObjects.end(); ++itr)		{			plObj->PushOutOfRange((*itr)->GetNewGUID());		}		// Setting an instance ID here will trigger the session to be removed		// by MapMgr::run(). :)		plObj->GetSession()->SetInstance(0);		// Add it to the global session set.		// Don't "re-add" to session if it is being deleted.		if(!plObj->GetSession()->bDeleted)			sWorld.AddGlobalSession(plObj->GetSession());	}	if(!HasPlayers() && !InactiveMoveTime && !forced_expire && GetMapInfo()->type != INSTANCE_NULL)	{		InactiveMoveTime = UNIXTIME + (MAPMGR_INACTIVE_MOVE_TIME * 60);	   // 5 mins -> move to inactive	}}
开发者ID:Chero,项目名称:abcwow,代码行数:101,


示例11: if

//.........这里部分代码省略.........	if(obj->GetMapMgr() != this)	{		/* Something removed us. */		return;	}	if(obj->GetPositionX() >= _maxX || obj->GetPositionX() <= _minX ||		obj->GetPositionY() >= _maxY || obj->GetPositionY() <= _minY)	{		if(obj->IsPlayer())		{			Player* plr = static_cast< Player* >( obj );			if(plr->GetBindMapId() != GetMapId())			{				plr->SafeTeleport(plr->GetBindMapId(),0,plr->GetBindPositionX(),plr->GetBindPositionY(),plr->GetBindPositionZ(),0);				plr->GetSession()->SystemMessage("Teleported you to your hearthstone location as you were out of the map boundaries.");				return;			}			else			{				obj->GetPositionV()->ChangeCoords(plr->GetBindPositionX(),plr->GetBindPositionY(),plr->GetBindPositionZ(),0);				plr->GetSession()->SystemMessage("Teleported you to your hearthstone location as you were out of the map boundaries.");				WorldPacket * data = plr->BuildTeleportAckMsg(plr->GetPosition());				plr->GetSession()->SendPacket(data);				delete data;			}		}		else		{			obj->GetPositionV()->ChangeCoords(0,0,0,0);		}	}	uint32 cellX = GetPosX(obj->GetPositionX());	uint32 cellY = GetPosY(obj->GetPositionY());	if(cellX >= _sizeX || cellY >= _sizeY)	{		return;	}	MapCell *objCell = GetCell(cellX, cellY);	MapCell * pOldCell = obj->GetMapCell();	if (!objCell)	{		objCell = Create(cellX,cellY);		objCell->Init(cellX, cellY, _mapId, this);	}	// If object moved cell	if (objCell != obj->GetMapCell())	{		// THIS IS A HACK!		// Current code, if a creature on a long waypoint path moves from an active		// cell into an inactive one, it will disable itself and will never return.		// This is to prevent cpu leaks. I will think of a better solution very soon :P		if(!objCell->IsActive() && !plObj && obj->Active)			obj->Deactivate(this);		if(obj->GetMapCell())			obj->GetMapCell()->RemoveObject(obj);			objCell->AddObject(obj);		obj->SetMapCell(objCell);
开发者ID:Chero,项目名称:abcwow,代码行数:66,


示例12: sizeof

/** 创建windows窗口 */bool GLWindow::Create(const char * window_title,const char * class_name,bool fullscreen, HINSTANCE h_instance, LPVOID lpParam){	m_IsFullScreen = fullscreen;	int nX=0;	int nY=0;	PIXELFORMATDESCRIPTOR pfd =											/**< 设置像素描述结构 */	{		sizeof(PIXELFORMATDESCRIPTOR),									/**< 像素描述结构的大小 */ 		1,																/**< 版本号 */		PFD_DRAW_TO_WINDOW	|											/**< 缓存区的输出显示在一个窗口中 */		PFD_SUPPORT_OPENGL	|											/**< 缓存区支持OpenGL绘图 */		PFD_STEREO			|											/**< 颜色缓存区是立体缓存 */		PFD_DOUBLEBUFFER,												/**< 颜色缓存区是双缓存 */		PFD_TYPE_RGBA,													/**< 使用RGBA颜色格式 */		m_BitsPerPixel,													/**< 颜色缓存区中颜色值所占的位深 */		0, 0, 0, 0, 0, 0,												/**< 使用默认的颜色设置 */		0,																/**< 无Alpha缓存 */		0,																/**< 颜色缓存区中alpha成分的移位计数 */		0,																/**< 无累计缓存区 */		0, 0, 0, 0,														/**< 累计缓存区无移位 */		32,																/**< 32位深度缓存 */		0,																/**< 无蒙版缓存 */		0,																/**< 无辅助缓存区 */		PFD_MAIN_PLANE,													/**< 必须为PFD_MAIN_PLANE,设置为主绘图层 */		0,																/**< 表示OpenGL实现所支持的上层或下层平面的数量 */		0, 0, 0															/**< 过时,已不再使用 */	};	DWORD windowStyle = WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX &~WS_MINIMIZEBOX;	/**< 定义我们窗口类型,使用常规设定,去掉最大化按钮,并不能改变窗体大小 */	DWORD windowExtendedStyle = WS_EX_APPWINDOW;							if (m_IsFullScreen == true)											/**< 如果为全屏模式,尝试转化为全屏模式 */	{		if (ChangeScreenSetting() == false)		{																/**< 全屏模式转换失败,弹出对话框提示,并尝试窗口模式 */			MessageBox(HWND_DESKTOP, "模式转换失败./n在窗口模式下运行.", "Error", MB_OK | MB_ICONEXCLAMATION);			m_IsFullScreen = false;										/**< 设置为窗口模式 */		}		else															/**< 如果为窗口模式 */		{			//ShowCursor(false);											/**< 隐藏鼠标 */			windowStyle = WS_POPUP;										/**< 设置窗口模式为顶层窗口 */			windowExtendedStyle |= WS_EX_TOPMOST;								}																	}	/// 调整我们窗口的大小,使其客户区的大小为我们设置的大小	RECT windowRect = {GetPosX(), GetPosY(), GetPosX() + GetWidth(), GetPosY() + GetHeight()};	if (m_IsFullScreen == false)										/**< 在窗口模式下使用 */	{			windowExtendedStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;	/**< 使窗口具有3D外观 */		int wid = GetSystemMetrics(SM_CXSCREEN);		/**< 获取当前屏幕宽 */		int hei = GetSystemMetrics(SM_CYSCREEN);		/**< 获取当前屏幕高 */		nX = (wid - GetWidth()) / 2;                    /**< 计算窗口居中用 */		nY = (hei - GetHeight()) / 2;					/// 调整我们窗口的大小,使其客户区的大小为我们设置的大小		AdjustWindowRectEx(&windowRect, windowStyle, 0, windowExtendedStyle);		/// 判断窗口的左上角是否隐藏在桌面外		if (windowRect.left < 0)										/**< 如果窗口X坐标为负,移动坐标到0处,并调整窗口的位置 */		{			windowRect.right -= windowRect.left;									windowRect.left = 0;												}		if (windowRect.top < 0)											/**< 如果窗口Y坐标为负,移动坐标到0处,并调整窗口的位置 */		{			windowRect.bottom -= windowRect.top;									windowRect.top = 0;													}	}	/// 创建窗口	m_hWnd = CreateWindowEx(windowExtendedStyle,						/**< 窗口的扩展风格 */							class_name,									/**< 窗口的类名 */							window_title,								/**< 窗口标题 */							windowStyle,								/**< 窗口的风格 */							nX,nY,                                      /**< 窗口的左上角位置 */							windowRect.right - windowRect.left,			/**< 窗口的宽度 */							windowRect.bottom - windowRect.top,			/**< 窗口的高度 */                            HWND_DESKTOP,								/**< 窗口的父窗口为桌面 */							0,											/**< 无菜单 */							h_instance,									/**< 传入窗口的实例句柄 */							lpParam);									/**< 传入程序类参数 */	while (m_hWnd != 0)													/**< 窗口是否创建成功 */	{		m_hDC = GetDC(m_hWnd);											/**< 返回窗口的设备描述表 */		if (m_hDC == 0)													/**< 如果为空 */		{																/**< 失败 */			break;																}		GLuint PixelFormat = ChoosePixelFormat(m_hDC, &pfd);			/**< 查找一个兼容的像素格式 */		if (PixelFormat == 0)											/**< 如果没找到 */		{																/**< 失败 */			break;																}		if (SetPixelFormat(m_hDC, PixelFormat, &pfd) == false)			/**< 设置像素格式 */		{																/**< 失败 */			break;														//.........这里部分代码省略.........
开发者ID:XJM2013,项目名称:MyGame,代码行数:101,


示例13: GetSpeed

void cProjectileEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk){	if (m_IsInGround)	{		// Already-grounded projectiles don't move at all		return;	}		Vector3d PerTickSpeed = GetSpeed() / 20;	Vector3d Pos = GetPosition();		// Trace the tick's worth of movement as a line:	Vector3d NextPos = Pos + PerTickSpeed;	cProjectileTracerCallback TracerCallback(this);	if (!cLineBlockTracer::Trace(*m_World, TracerCallback, Pos, NextPos))	{		// Something has been hit, abort all other processing		return;	}	// The tracer also checks the blocks for slowdown blocks - water and lava - and stores it for later in its SlowdownCoeff		// Test for entity collisions:	cProjectileEntityCollisionCallback EntityCollisionCallback(this, Pos, NextPos);	a_Chunk.ForEachEntity(EntityCollisionCallback);	if (EntityCollisionCallback.HasHit())	{		// An entity was hit:		Vector3d HitPos = Pos + (NextPos - Pos) * EntityCollisionCallback.GetMinCoeff();		// DEBUG:		LOGD("Projectile %d has hit an entity %d (%s) at {%.02f, %.02f, %.02f} (coeff %.03f)",			m_UniqueID,			EntityCollisionCallback.GetHitEntity()->GetUniqueID(),			EntityCollisionCallback.GetHitEntity()->GetClass(),			HitPos.x, HitPos.y, HitPos.z,			EntityCollisionCallback.GetMinCoeff()		);				OnHitEntity(*(EntityCollisionCallback.GetHitEntity()), HitPos);	}	// TODO: Test the entities in the neighboring chunks, too	// Update the position:	SetPosition(NextPos);		// Add slowdown and gravity effect to the speed:	Vector3d NewSpeed(GetSpeed());	NewSpeed.y += m_Gravity / 20;	NewSpeed *= TracerCallback.GetSlowdownCoeff();	SetSpeed(NewSpeed);	SetRotationFromSpeed();	SetPitchFromSpeed();	// DEBUG:	LOGD("Projectile %d: pos {%.02f, %.02f, %.02f}, speed {%.02f, %.02f, %.02f}, rot {%.02f, %.02f}",		m_UniqueID,		GetPosX(), GetPosY(), GetPosZ(),		GetSpeedX(), GetSpeedY(), GetSpeedZ(),		GetRotation(), GetPitch()	);}
开发者ID:jimfinnis,项目名称:MCServer,代码行数:61,


示例14: SetPosX

void CBase::Update(float fElapsedTime){	SetPosX( GetPosX() + GetVelX() * fElapsedTime );	SetPosY( GetPosY() + GetVelY() * fElapsedTime );}
开发者ID:jakneute,项目名称:Earthworm-Jim-Full-Sail-Game-Project,代码行数:5,


示例15: UNUSED

/// Moves pickups from above this hopper into it. Returns true if the contents have changed.bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick){	UNUSED(a_CurrentTick);	class cHopperPickupSearchCallback :		public cEntityCallback	{	public:		cHopperPickupSearchCallback(const Vector3i & a_Pos, cItemGrid & a_Contents) :			m_Pos(a_Pos),			m_bFoundPickupsAbove(false),			m_Contents(a_Contents)		{		}		virtual bool Item(cEntity * a_Entity) override		{			ASSERT(a_Entity != NULL);			if (!a_Entity->IsPickup() || a_Entity->IsDestroyed())			{				return false;			}			Vector3f EntityPos = a_Entity->GetPosition();			Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f);  // One block above hopper, and search from center outwards			double Distance = (EntityPos - BlockPos).Length();			if (Distance < 0.5)			{				if (TrySuckPickupIn((cPickup *)a_Entity))				{					return false;				}			}			return false;		}		bool TrySuckPickupIn(cPickup * a_Pickup)		{			cItem & Item = a_Pickup->GetItem();			for (int i = 0; i < ContentsWidth * ContentsHeight; i++)			{				if (m_Contents.IsSlotEmpty(i))				{					m_bFoundPickupsAbove = true;					m_Contents.SetSlot(i, Item);					a_Pickup->Destroy();  // Kill pickup					return true;				}				else if (m_Contents.GetSlot(i).IsEqual(Item) && !m_Contents.GetSlot(i).IsFullStack())				{					m_bFoundPickupsAbove = true;					int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;										Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount;  // Set count to however many items were added										if (Item.IsEmpty())					{						a_Pickup->Destroy();  // Kill pickup if all items were added					}					return true;				}			}			return false;		}		bool FoundPickupsAbove(void) const		{			return m_bFoundPickupsAbove;		}	protected:		Vector3i m_Pos;		bool m_bFoundPickupsAbove;		cItemGrid & m_Contents;	};	cHopperPickupSearchCallback HopperPickupSearchCallback(Vector3i(GetPosX(), GetPosY(), GetPosZ()), m_Contents);	a_Chunk.ForEachEntity(HopperPickupSearchCallback);	return HopperPickupSearchCallback.FoundPickupsAbove();}
开发者ID:ChriPiv,项目名称:MCServer,代码行数:88,


示例16: GET_AND_VERIFY_CURRENT_CHUNK

void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk){	int BlockX = POSX_TOINT;	int BlockY = POSY_TOINT;	int BlockZ = POSZ_TOINT;	// Position changed -> super::HandlePhysics() called	GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, BlockX, BlockZ)	// TODO Add collision detection with entities.	a_Dt /= 1000;  // Convert from msec to sec	Vector3d NextPos = Vector3d(GetPosX(), GetPosY(), GetPosZ());	Vector3d NextSpeed = Vector3d(GetSpeedX(), GetSpeedY(), GetSpeedZ());		if ((BlockY >= cChunkDef::Height) || (BlockY < 0))	{		// Outside of the world				AddSpeedY(m_Gravity * a_Dt);		AddPosition(GetSpeed() * a_Dt);		return;	}		int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width);	int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width);	BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );	BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;	if (!cBlockInfo::IsSolid(BlockIn))  // Making sure we are not inside a solid block	{		if (m_bOnGround)  // check if it's still on the ground		{			if (!cBlockInfo::IsSolid(BlockBelow))  // Check if block below is air or water.			{				m_bOnGround = false;			}		}	}	else	{		// Push out entity.		BLOCKTYPE GotBlock;		static const struct		{			int x, y, z;		} gCrossCoords[] =		{			{ 1, 0,  0},			{-1, 0,  0},			{ 0, 0,  1},			{ 0, 0, -1},		} ;		bool IsNoAirSurrounding = true;		for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++)		{			if (!NextChunk->UnboundedRelGetBlockType(RelBlockX + gCrossCoords[i].x, BlockY, RelBlockZ + gCrossCoords[i].z, GotBlock))			{				// The pickup is too close to an unloaded chunk, bail out of any physics handling				return;			}			if (!cBlockInfo::IsSolid(GotBlock))			{				NextPos.x += gCrossCoords[i].x;				NextPos.z += gCrossCoords[i].z;				IsNoAirSurrounding = false;				break;			}		}  // for i - gCrossCoords[]					if (IsNoAirSurrounding)		{			NextPos.y += 0.5;		}		m_bOnGround = true;		/*		// DEBUG:		LOGD("Entity #%d (%s) is inside a block at {%d, %d, %d}",			m_UniqueID, GetClass(), BlockX, BlockY, BlockZ		);		*/	}	if (!m_bOnGround)	{		float fallspeed;		if (IsBlockWater(BlockIn))		{			fallspeed = m_Gravity * a_Dt / 3;  // Fall 3x slower in water.		}		else if (BlockIn == E_BLOCK_COBWEB)		{			NextSpeed.y *= 0.05;  // Reduce overall falling speed			fallspeed = 0;  // No falling.		}		else		{			// Normal gravity			fallspeed = m_Gravity * a_Dt;//.........这里部分代码省略.........
开发者ID:Kortak,项目名称:MCServer,代码行数:101,


示例17: LoadPermissionsFromDisk

bool cPlayer::LoadFromDisk(){    LoadPermissionsFromDisk();    // Log player permissions, cause it's what the cool kids do    LOGINFO("Player %s has permissions:", m_PlayerName.c_str() );    for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr )    {        if( itr->second ) LOGINFO("%s", itr->first.c_str() );    }    AString SourceFile;    Printf(SourceFile, "players/%s.json", m_PlayerName.c_str() );    cFile f;    if (!f.Open(SourceFile, cFile::fmRead))    {        // This is a new player whom we haven't seen yet, bail out, let them have the defaults        return false;    }    AString buffer;    if (f.ReadRestOfFile(buffer) != f.GetSize())    {        LOGWARNING("Cannot read player data from file /"%s/"", SourceFile.c_str());        return false;    }    f.Close(); //cool kids play nice    Json::Value root;    Json::Reader reader;    if (!reader.parse(buffer, root, false))    {        LOGWARNING("Cannot parse player data in file /"%s/", player will be reset", SourceFile.c_str());    }    Json::Value & JSON_PlayerPosition = root["position"];    if (JSON_PlayerPosition.size() == 3)    {        SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble());        SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble());        SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble());        m_LastPosX = GetPosX();        m_LastPosY = GetPosY();        m_LastPosZ = GetPosZ();        m_LastFoodPos = GetPosition();    }    Json::Value & JSON_PlayerRotation = root["rotation"];    if (JSON_PlayerRotation.size() == 3)    {        SetRotation ((float)JSON_PlayerRotation[(unsigned int)0].asDouble());        SetPitch    ((float)JSON_PlayerRotation[(unsigned int)1].asDouble());        SetRoll     ((float)JSON_PlayerRotation[(unsigned int)2].asDouble());    }    m_Health              = root.get("health", 0).asInt();    m_AirLevel            = root.get("air",            MAX_AIR_LEVEL).asInt();    m_FoodLevel           = root.get("food",           MAX_FOOD_LEVEL).asInt();    m_FoodSaturationLevel = root.get("foodSaturation", MAX_FOOD_LEVEL).asDouble();    m_FoodTickTimer       = root.get("foodTickTimer",  0).asInt();    m_FoodExhaustionLevel = root.get("foodExhaustion", 0).asDouble();    m_LifetimeTotalXp     = (short) root.get("xpTotal", 0).asInt();    m_CurrentXp           = (short) root.get("xpCurrent", 0).asInt();    //SetExperience(root.get("experience", 0).asInt());    m_GameMode = (eGameMode) root.get("gamemode", eGameMode_NotSet).asInt();    m_Inventory.LoadFromJson(root["inventory"]);    m_LoadedWorldName = root.get("world", "world").asString();    LOGD("Player /"%s/" was read from file, spawning at {%.2f, %.2f, %.2f} in world /"%s/"",         m_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ(), m_LoadedWorldName.c_str()        );    return true;}
开发者ID:Noraaron1,项目名称:MCServer,代码行数:79,


示例18: Process

void GUIcontrol::Process(){	if(visible)	{		if(GetChildCount() == 0)		{			if(PointInBox(mouseX, mouseY, GetPosX(), GetPosY(), GetPatternWidth(), GetPatternHeight()))			{				GUIMessage temp_message;											if(GetPatternCount() > 1)					SetCurrentPattern(1);				//temp_message.from = GetGID();				//temp_message.a1 = MOUSE_OVER;				//temp_message.a2 = 0;				if(mouse[0])				{					_pressed = true;					//mouse[0] = false;										if(GetPatternCount() > 1)					{						SetCurrentPattern(2);						_pos_dx = 1;						_pos_dy = 1;						if(_caption)						{							_caption_dx = 1;							_caption_dy = 1;						}					}				}				else				{					_pos_dx = 0;					_pos_dy = 0;					if(_caption)					{						_caption_dx = 0;						_caption_dy = 0;					}					if(_pressed)					{						_pressed = false;						temp_message.from = GetGID();						temp_message.a1 = MOUSE_LEFT_CLICKED;						temp_message.a2 = 0;						temp_message.solved = false;						SendMessage(temp_message);					}				}			}			else			{				if(GetCurrentPattern() != 0) SetCurrentPattern(0);			}		}	}}
开发者ID:lightsgoout,项目名称:interview,代码行数:70,


示例19: super

cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)    : super(etPlayer, 0.6, 1.8)    , m_GameMode(eGameMode_NotSet)    , m_IP("")    , m_LastBlockActionTime( 0 )    , m_LastBlockActionCnt( 0 )    , m_AirLevel( MAX_AIR_LEVEL )    , m_AirTickTimer( DROWNING_TICKS )    , m_bVisible( true )    , m_LastGroundHeight( 0 )    , m_bTouchGround( false )    , m_Stance( 0.0 )    , m_Inventory(*this)    , m_CurrentWindow(NULL)    , m_InventoryWindow(NULL)    , m_TimeLastPickupCheck( 0.f )    , m_Color('-')    , m_ClientHandle( a_Client )    , m_FoodLevel(MAX_FOOD_LEVEL)    , m_FoodSaturationLevel(5)    , m_FoodTickTimer(0)    , m_FoodExhaustionLevel(0)    , m_FoodPoisonedTicksRemaining(0)    , m_NormalMaxSpeed(0.1)    , m_SprintingMaxSpeed(0.13)    , m_IsCrouched(false)    , m_IsSprinting(false)    , m_IsSwimming(false)    , m_IsSubmerged(false)    , m_EatingFinishTick(-1)    , m_IsChargingBow(false)    , m_BowCharge(0)    , m_CurrentXp(0)    , m_LifetimeTotalXp(0)    , m_bDirtyExperience(false){    LOGD("Created a player object for /"%s/" @ /"%s/" at %p, ID %d",         a_PlayerName.c_str(), a_Client->GetIPString().c_str(),         this, GetUniqueID()        );    m_InventoryWindow = new cInventoryWindow(*this);    m_CurrentWindow = m_InventoryWindow;    m_InventoryWindow->OpenedByPlayer(*this);    SetMaxHealth(MAX_HEALTH);    m_Health = MAX_HEALTH;    cTimer t1;    m_LastPlayerListTime = t1.GetNowTime();    m_TimeLastTeleportPacket = 0;    m_TimeLastPickupCheck = 0;    m_PlayerName = a_PlayerName;    m_bDirtyPosition = true; // So chunks are streamed to player at spawn    if (!LoadFromDisk())    {        m_Inventory.Clear();        SetPosX(cRoot::Get()->GetDefaultWorld()->GetSpawnX());        SetPosY(cRoot::Get()->GetDefaultWorld()->GetSpawnY());        SetPosZ(cRoot::Get()->GetDefaultWorld()->GetSpawnZ());        LOGD("Player /"%s/" is connecting for the first time, spawning at default world spawn {%.2f, %.2f, %.2f}",             a_PlayerName.c_str(), GetPosX(), GetPosY(), GetPosZ()            );    }    m_LastJumpHeight = (float)(GetPosY());    m_LastGroundHeight = (float)(GetPosY());    m_Stance = GetPosY() + 1.62;    cRoot::Get()->GetServer()->PlayerCreated(this);}
开发者ID:Noraaron1,项目名称:MCServer,代码行数:74,


示例20: switch

CEnemy::CEnemy( EleType ElementToBe, float initx, float inity, int boss, CFlock* Flock ){	m_nType         = OBJ_ENEMY;	m_bIsFrozen     = false;	m_fFrozenSpeed  = 0.5f;	m_fFreezeTimer  = 0.0f;	m_fChangeAnimationTimer = 0.76f;	LastFrame = NULL;	m_fLastPosition = inity;	if(!boss)	{		switch( ElementToBe )		{		case OBJ_EARTH:			{				currState = new AIStateEarth( );				SetHeight( 100 );				SetWidth( 135 );				SetPosX(initx);				SetPosY(inity - GetHeight());				SetVelX(25.0f);				SetVelY(0.0f);				( ( AIStateEarth* )currState )->SetInitPos( int( GetPosX( ) ), int( GetPosY( ) ) );				SetHeight( 80 );				SetWidth( 135 );				m_nHealth      = 80 * CGameplayState::GetInstance()->GetDifficulty() + (CSpellFactory::GetInstance()->GetWindLevel() * 10);				m_SpellType    = OBJ_EARTH;				currDirec      = RIGHT;				m_nAnimation = m_SpellType +1;				m_fScale = .65f;				SetAnimation(OBJ_EARTH +1,0);			} break;		case OBJ_FIRE:			{				currState = new AIStateFire( );				SetPosX(initx);				SetPosY(inity - 55);				SetVelX(75.0f);				SetVelY(0.0f);				SetHeight( 54 );				SetWidth ( 32 );				m_nHealth      = 50 * CGameplayState::GetInstance()->GetDifficulty() + (CSpellFactory::GetInstance()->GetEarthLevel() * 7);				m_SpellType    = OBJ_FIRE;				currDirec      = RIGHT;				m_fScale = 0.5f;				m_nAnimation = m_SpellType +1;				SetAnimation(OBJ_FIRE +1,0);			} break;		case OBJ_ICE:			{				currState = new AIStateIce( );				SetPosX(initx);				SetPosY(inity - 55);				SetVelX(50.0f);				SetVelY(0.0f);				SetHeight( 64 );				SetWidth ( 64 );				SetAnimation(1,0);				m_nHealth      = 50 * CGameplayState::GetInstance()->GetDifficulty() + (CSpellFactory::GetInstance()->GetFireLevel() * 7);				m_SpellType    = OBJ_ICE;				m_fScale = 0.5f;				currDirec      = RIGHT;				m_nAnimation = m_SpellType +1;				SetAnimation(OBJ_ICE +1,0);			} break;		case OBJ_WIND:			{				currState = new AIStateWind();				SetPosX(initx);				SetPosY(inity);				m_fScale = 0.4f;				((AIStateWind*)currState)->SetFlock((CFlock*)Flock);				SetVelX((float)(rand()%150));				SetVelY((float)(rand()%150));				if(rand()%2)				{					SetVelX((float)(rand()%150));					SetVelY((float)(rand()%150));				}				else				{					SetVelX(rand()%150 * -1.0f);					SetVelY(rand()%150 * -1.0f);				}				SetHeight(16);				SetWidth(16);				m_nHealth = 25 * CGameplayState::GetInstance()->GetDifficulty() + CSpellFactory::GetInstance()->GetIceLevel() * 5;				m_SpellType = OBJ_WIND;				currDirec = RIGHT;				m_nAnimation = m_SpellType +1;				SetAnimation(OBJ_WIND +1,0);				currAnimation = NULL;				break;			} 		}//.........这里部分代码省略.........
开发者ID:FreeZe5K,项目名称:lapidem,代码行数:101,


示例21: Vector3d

Vector3d cPlayer::GetEyePosition(void) const{    return Vector3d( GetPosX(), m_Stance, GetPosZ() );}
开发者ID:Noraaron1,项目名称:MCServer,代码行数:4,


示例22: GetPosX

void cMonster::KilledBy(TakeDamageInfo & a_TDI){	super::KilledBy(a_TDI);	if (m_SoundHurt != "")	{		m_World->BroadcastSoundEffect(m_SoundDeath, GetPosX(), GetPosY(), GetPosZ(), 1.0f, 0.8f);	}	int Reward;	switch (m_MobType)	{		// Animals		case mtChicken:		case mtCow:		case mtHorse:		case mtPig:		case mtRabbit:		case mtSheep:		case mtSquid:		case mtMooshroom:		case mtOcelot:		case mtWolf:		{			Reward = m_World->GetTickRandomNumber(2) + 1;			break;		}		// Monsters		case mtCaveSpider:		case mtCreeper:		case mtEnderman:		case mtGhast:		case mtGuardian:		case mtSilverfish:		case mtSkeleton:		case mtSpider:		case mtWitch:		case mtZombie:		case mtZombiePigman:		case mtSlime:		case mtMagmaCube:		{			Reward = 6 + (m_World->GetTickRandomNumber(2));			break;		}		case mtBlaze:		{			Reward = 10;			break;		}		// Bosses		case mtEnderDragon:		{			Reward = 12000;			break;		}		case mtWither:		{			Reward = 50;			break;		}		default:		{			Reward = 0;			break;		}	}	if ((a_TDI.Attacker != nullptr) && (!IsBaby()))	{		m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward);	}	m_DestroyTimer = std::chrono::milliseconds(0);}
开发者ID:gjzskyland,项目名称:cuberite,代码行数:74,


示例23: MinecartCollisionCallback

bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta){	cMinecartCollisionCallback MinecartCollisionCallback(GetPosition(), GetHeight(), GetWidth(), GetUniqueID(), ((m_Attachee == NULL) ? -1 : m_Attachee->GetUniqueID()));	int ChunkX, ChunkZ;	cChunkDef::BlockToChunk(POSX_TOINT, POSZ_TOINT, ChunkX, ChunkZ);	m_World->ForEachEntityInChunk(ChunkX, ChunkZ, MinecartCollisionCallback);	if (!MinecartCollisionCallback.FoundIntersection())	{		return false;	}	switch (a_RailMeta)	{		case E_META_RAIL_ZM_ZP:		{			if (MinecartCollisionCallback.GetCollidedEntityPosition().z >= GetPosZ())			{				if ((-GetSpeedZ() * 0.4) < 0.01)				{					AddSpeedZ(-4);				}				else				{					SetSpeedZ(-GetSpeedZ() * 0.4);				}			}			else			{				if ((GetSpeedZ() * 0.4) < 0.01)				{					AddSpeedZ(4);				}				else				{					SetSpeedZ(GetSpeedZ() * 0.4);				}			}			return true;		}		case E_META_RAIL_XM_XP:		{			if (MinecartCollisionCallback.GetCollidedEntityPosition().x >= GetPosX())			{				if ((-GetSpeedX() * 0.4) < 0.01)				{					AddSpeedX(-4);				}				else				{					SetSpeedX(-GetSpeedX() * 0.4);				}			}			else			{				if ((GetSpeedX() * 0.4) < 0.01)				{					AddSpeedX(4);				}				else				{					SetSpeedX(GetSpeedX() * 0.4);				}			}			return true;		}		case E_META_RAIL_CURVED_ZM_XM:		case E_META_RAIL_CURVED_ZP_XP:		{			Vector3d Distance = MinecartCollisionCallback.GetCollidedEntityPosition() - Vector3d(GetPosX(), 0, GetPosZ());			// Prevent division by small numbers			if (std::abs(Distance.z) < 0.001)			{				Distance.z = 0.001;			}			/* Check to which side the minecart is to be pushed.			Let's consider a z-x-coordinate system where the minecart is the center (0/0).			The minecart moves along the line x = -z, the perpendicular line to this is x = z.			In order to decide to which side the minecart is to be pushed, it must be checked on what side of the perpendicular line the pushing entity is located. */			if (				((Distance.z > 0) && ((Distance.x / Distance.z) >= 1)) ||				((Distance.z < 0) && ((Distance.x / Distance.z) <= 1))			)			{				// Moving -X +Z				if ((-GetSpeedX() * 0.4 / sqrt(2.0)) < 0.01)				{					// ~ SpeedX >= 0 Immobile or not moving in the "right" direction. Give it a bump!					AddSpeedX(-4 / sqrt(2.0));					AddSpeedZ(4 / sqrt(2.0));				}				else				{					// ~ SpeedX < 0 Moving in the "right" direction. Only accelerate it a bit.					SetSpeedX(GetSpeedX() * 0.4 / sqrt(2.0));					SetSpeedZ(GetSpeedZ() * 0.4 / sqrt(2.0));				}			}//.........这里部分代码省略.........
开发者ID:w00tc0d3,项目名称:MCServer,代码行数:101,


示例24: GetPosZ

void CBattleItem::Render(){	CSGD_TextureManager::GetInstance()->DrawWithZSort(GetImageID(), (int)GetPosX(), (int)GetPosY(), GetPosZ());}
开发者ID:marvelman610,项目名称:tmntactis,代码行数:4,


示例25: Render

void CSweepingWind::Render( void ){	CCamera* Game_Camera = CCamera::GetInstance();	AnimationManager::GetInstance()->Render(GetPosX() - Game_Camera->GetPosX(),		GetPosY() - Game_Camera->GetPosY(), CEntity::IsFlipped(), *GetAnimInfo());}
开发者ID:kendellm,项目名称:Trials-of-Mastery,代码行数:6,


示例26: GetPosX

void cPlayer::KilledBy(TakeDamageInfo & a_TDI){	super::KilledBy(a_TDI);	if (m_Health > 0)	{		return;  //  not dead yet =]	}	m_bVisible = false;  // So new clients don't see the player	// Puke out all the items	cItems Pickups;	m_Inventory.CopyToItems(Pickups);	m_Inventory.Clear();	if (GetName() == "Notch")	{		Pickups.Add(cItem(E_ITEM_RED_APPLE));	}	m_Stats.AddValue(statItemsDropped, (StatValue)Pickups.Size());	m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);	SaveToDisk();  // Save it, yeah the world is a tough place !	if ((a_TDI.Attacker == NULL) && m_World->ShouldBroadcastDeathMessages())	{		AString DamageText;		switch (a_TDI.DamageType)		{			case dtRangedAttack: DamageText = "was shot"; break;			case dtLightning: DamageText = "was plasmified by lightining"; break;			case dtFalling: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "fell to death" : "hit the ground too hard"; break;			case dtDrowning: DamageText = "drowned"; break;			case dtSuffocating: DamageText = (GetWorld()->GetTickRandomNumber(10) % 2 == 0) ? "git merge'd into a block" : "fused with a block"; break;			case dtStarving: DamageText = "forgot the importance of food"; break;			case dtCactusContact: DamageText = "was impaled on a cactus"; break;			case dtLavaContact: DamageText = "was melted by lava"; break;			case dtPoisoning: DamageText = "died from septicaemia"; break;			case dtWithering: DamageText = "is a husk of their former selves"; break;			case dtOnFire: DamageText = "forgot to stop, drop, and roll"; break;			case dtFireContact: DamageText = "burnt themselves to death"; break;			case dtInVoid: DamageText = "somehow fell out of the world"; break;			case dtPotionOfHarming: DamageText = "was magicked to death"; break;			case dtEnderPearl: DamageText = "misused an ender pearl"; break;			case dtAdmin: DamageText = "was administrator'd"; break;			case dtExplosion: DamageText = "blew up"; break;			default: DamageText = "died, somehow; we've no idea how though"; break;		}		GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str()));	}	else if (a_TDI.Attacker == NULL)  // && !m_World->ShouldBroadcastDeathMessages() by fallthrough	{		// no-op	}	else if (a_TDI.Attacker->IsPlayer())	{		cPlayer * Killer = (cPlayer *)a_TDI.Attacker;		GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str()));	}	else	{		AString KillerClass = a_TDI.Attacker->GetClass();		KillerClass.erase(KillerClass.begin());  // Erase the 'c' of the class (e.g. "cWitch" -> "Witch")		GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));	}	m_Stats.AddValue(statDeaths);	m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::otDeathCount, 1);}
开发者ID:cedeel,项目名称:MCServer,代码行数:74,



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


C++ GetPositionX函数代码示例
C++ GetPos函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。