Ejemplo n.º 1
0
void cTextBox::Step (uint32_t a_ElapsedMiliSec)
{
   if (GetPosition() != GetPreviousPosition())
   {
      m_Data.setPosition(GetPosition().x + 4, GetPosition().y + 4);
   }
}
Ejemplo n.º 2
0
void cFreePlayMenu::Step (uint32_t a_ElapsedMiliSec)
{
   if (GetPosition() != GetPreviousPosition())
   {
      sf::Vector3<double> l_Position = GetPosition();
      m_Player1Label.setPosition(GetPosition().x, l_Position.y + 4);
      l_Position.y += m_pPlayer1Option->GetBoundingBox().height + 5;
      m_Player2Label.setPosition(GetPosition().x, l_Position.y + 4);
      l_Position.y += m_pPlayer2Option->GetBoundingBox().height + 5;
      m_GameSpeedLabel.setPosition(GetPosition().x, l_Position.y + 4);
   }

   // We can't post a message from inside the MessageReceived function, so it
   // gets deferred to here instead.
   // TODO: This might not actually be true. It might only be registering for
   // messages that is problematic.
   if (m_PostBackMessage)
   {
      sMessage l_Message;
      l_Message.m_From = GetUniqueId();
      l_Message.m_Category = "Button";
      l_Message.m_Key = "Menu Change";
      l_Message.m_Value = "cMainMenu";
      GetResources()->GetMessageDispatcher()->PostMessage(l_Message);
      m_PostBackMessage = false;
   }

   if (GetVelocity().x < 0)
   {
      if (GetPosition().x + m_Player1Label.getLocalBounds().width < GetResources()->GetWindow()->getSize().x / 2)
      {
         SetVelocityX(0, kNormal);
      }
   }
   else if (GetVelocity().x > 0)
   {
      if (GetPosition().x > GetResources()->GetWindow()->getSize().x)
      {
         SetVelocityX(0, kNormal);
      }
   }
}
Ejemplo n.º 3
0
void ControllableObject::Update(float msec, set<Action> actions)
{
	bool moveStatusBg = isMoving;
	Renderer* r = &Renderer::Instance();
	if (actions.find(MOVE_CAM_FORWARD) != actions.end())
	{
		isMoving = true;
		//if (fwDir.Length() == 0)
			fwDir = r->GetCamDirection();
		body->setActivationState(1);
		body->applyCentralForce(btVector3(fwDir.x * 500, fwDir.y * 500, fwDir.z * 500));
	}
	else
	{
		fwDir = Vector3(0, 0, 0);
	}
	if (actions.find(MOVE_CAM_BACKWARD) != actions.end())
	{
		isMoving = true;
		//if (bwDir.Length() == 0)
			bwDir = r->GetCamDirection().Inverse();
		body->setActivationState(1);
		body->applyCentralForce(btVector3(bwDir.x * 500, bwDir.y * 500, bwDir.z * 500));
	}
	else
	{
		bwDir = Vector3(0, 0, 0);
	}
	if (actions.find(MOVE_CAM_LEFT) != actions.end())
	{
		isMoving = true;
		//if (lfDir.Length() == 0)
			lfDir = r->GetCamLeft().Inverse();
		body->setActivationState(1);
		body->applyCentralForce(btVector3(lfDir.x * 500, lfDir.y * 500, lfDir.z * 500));
	}
	else
	{
		lfDir = Vector3(0, 0, 0);
	}
	if (actions.find(MOVE_CAM_RIGHT) != actions.end())
	{
		isMoving = true;
		//if (rtDir.Length() == 0)
			rtDir = r->GetCamLeft();
		body->setActivationState(1);
		body->applyCentralForce(btVector3(rtDir.x * 500, rtDir.y * 500, rtDir.z * 500));
	}
	else
	{
		rtDir = Vector3(0, 0, 0);
	}
	if ((actions.find(JUMP) != actions.end()) && (IsOnGround()))
	{
		isMoving = true;
		if (!Controller::Instance().IsContinuous(JUMP))
		{
			//if (upDir.Length() == 0)
			upDir = r->GetCamUp();
			body->setActivationState(1);
			body->applyCentralForce(btVector3(upDir.x * 20000, upDir.y * 20000, upDir.z * 20000));
			ResourceManager::Instance().GetResource<SoundEffectResource>("jumping.wav")->Play();
		}
	}
	else
	{
		upDir = Vector3(0, 0, 0);
	}

	if (((GetPosition() - GetPreviousPosition()).Length() == 0) && !((moveStatusBg == false) && (isMoving == true)))
	{
		isMoving = false;
	}
	PhysicsObject::Update(msec, actions);
}