Esempio n. 1
0
  void FpsComponent::Update(const GameTime& gameTime) {
    if (gameTime.TotalGameTime() - mLastTotalElapsedTime >= 1) {
      mLastTotalElapsedTime = gameTime.TotalGameTime();
      mFrameRate = mFrameCount;
      mFrameCount = 0;
    }

    mFrameCount++;
  }
Esempio n. 2
0
	//Go through our queue and publish any expired events
	void EventQueue::Update(const GameTime& curTime)
	{
		SList<std::shared_ptr<EventPublisher>>::Iterator i = mQueue.begin();
		while(i != mQueue.end())
		{
			if ((**i).IsExpired(curTime.TotalGameTime()))
			{
				(**i).Deliver();
				mQueue.Remove(*i);
				i = mQueue.begin();
			}
			else
			{
				i++;
			}
		}
	}
Esempio n. 3
0
    void FpsComponent::Draw(const GameTime& gameTime)
    {
        mSpriteBatch->Begin();
            
        std::wostringstream fpsLabel;
        fpsLabel << std::setprecision(4) << L"Frame Rate: " << mFrameRate << "    Total Elapsed Time: " << gameTime.TotalGameTime();
        mSpriteFont->DrawString(mSpriteBatch, fpsLabel.str().c_str(), mTextPosition);

        mSpriteBatch->End();
    }
Esempio n. 4
0
	//Add a new event publisher to our queue
	void EventQueue::Enqueue(std::shared_ptr<EventPublisher> publisher, const GameTime& curTime, const double& delay)
	{
		(*publisher).SetTime(curTime.TotalGameTime(), delay);
		mQueue.PushBack(publisher);
	}