コード例 #1
0
ファイル: Projectile.cpp プロジェクト: Thargoid/pioneer
void Projectile::Add(Body *parent, Equip::Type type, const vector3d &pos, const vector3d &baseVel, const vector3d &dirVel)
{
	Projectile *p = new Projectile();
	p->m_parent = parent;
	p->m_type = Equip::types[type].tableIndex;
	p->SetFrame(parent->GetFrame());
	
	parent->GetRotMatrix(p->m_orient);
	p->SetPosition(pos);
	p->m_baseVel = baseVel;
	p->m_dirVel = dirVel;
	p->m_radius = p->GetRadius();
	Pi::game->GetSpace()->AddBody(p);
}
コード例 #2
0
ファイル: Projectile.cpp プロジェクト: suenting/ProjectFairy
void Projectile::Update()
{
	++mTicks;
	if( (mPos.x <0) || 
		(mPos.x>960)||
		(mPos.y<0)||
		(mPos.y>540))
	{
		mbIsDead = true;
	}
	

	switch(mpData->GetType())
	{
	case PT_Vector:
	case PT_VectorGrenade:
		mPos = mPos + mVector*mpData->GetSpeed();
		break;
	case PT_Custom:
		break;
	}

	if(PT_VectorGrenade == mpData->GetType())
	{
		if(mTicks>mpData->GetFuse())
		{
			mbIsDead=true;
			for(int it = 0; it<8;++it)
			{
				Projectile *pProjectile = ModContentManager::Instance().SpawnProjectile(mpData->GetShrapnelName());
				Math::Vector2f refPosition = mPos;
				int vec = 0+45*it;
				refPosition += Math::Vector2f::GetVectorFromDeg(vec)*mpData->GetRadius();
				pProjectile->SetPosition(refPosition);
				pProjectile->SetVector(vec);
				pProjectile->SetOwner(GetOwner());
				if(PO_Enemy==GetOwner())
				{
					Game::Instance().QueueProjectile(pProjectile);
				}
				else if(PO_Player==GetOwner())
				{
					Game::Instance().QueueProjectile(pProjectile);
				}
			}
		}
	}

}
コード例 #3
0
ファイル: Player.cpp プロジェクト: suenting/ProjectFairy
void Player::Update()
{
	mPosition += InputManager::Instance().GetDirection()*mSpeed;
	if(mPosition.x<0){mPosition.x = 0;}
	if(mPosition.y<0){mPosition.y = 0;}
	if(mPosition.x>960){mPosition.x = 960;}
	if(mPosition.y>540){mPosition.y = 540;}

	// shoot
	++ticks;
	if(0==(ticks%rateOfFire))
	{
		Projectile *pProjectile = ModContentManager::Instance().SpawnProjectile("player_bullet");
		Math::Vector2f refPosition = mPosition;
		refPosition.x += 32;
		pProjectile->SetPosition(refPosition);
		pProjectile->SetVector(Math::Vector2f(1.f,0.f));
		pProjectile->SetOwner(PO_Player);
		Game::Instance().AddPlayerProjectile(pProjectile);
	}
}
コード例 #4
0
ファイル: GameServer.cpp プロジェクト: dahin/fefu-mmorpg
//==============================================================================
void GameServer::HandleUseSkill_(const QVariantMap& request, QVariantMap& response)
{
  auto sid = request["sid"].toByteArray();
  Player* p = sidToPlayer_[sid];

  float x = request["x"].toFloat();
  float y = request["y"].toFloat();

  if (!x || !y)
  {
    WriteResult_(response, EFEMPResult::BAD_PLACING);
    return;
  }
  Projectile* project = CreateActor_<Projectile>();
  project->SetPosition (Vector2(p->GetPosition().x, p->GetPosition().y));
  project->SetPoint(Vector2(x, y));
  project->SetPlayer(p);
  project->GetCoord ();
  project->SetDirection (EActorDirection::EAST);
  levelMap_.IndexActor(project);
  WriteResult_(response, EFEMPResult::OK);
  return;
}