예제 #1
0
bool Application::beginFrame()
{
    sf::Event event;
    while( window.pollEvent(event) )
    {
        if( !onEvent(event) )
            return false;
    }
    
    const auto deltaTime = clock.restart();

    world.update(deltaTime.asSeconds());
    
    return true;
}
int main(int /*argc*/, char** /*argv*/)
{
    sf::Vector2i screenSize{800, 600};
    sf::RenderWindow mainWindow(sf::VideoMode(screenSize.x, screenSize.y),
                                "myproject");
    mainWindow.setVerticalSyncEnabled(true);
    // std::stringstream s;
    common::StreamLog slog{std::cout};
    lmg03::World w{slog};

    sf::Clock frameClock;

    constexpr float baseSpeed = 50.f;
    constexpr float frameDuration = 1.f / 60.f;

    while (mainWindow.isOpen())
    {
        sf::Event event;
        while (mainWindow.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                mainWindow.close();
            }
        }

        const auto duration = frameClock.getElapsedTime();
        if (duration.asSeconds() < frameDuration)
            continue;

        frameClock.restart();

        sf::Vector2f movement{processUserInput(baseSpeed, mainWindow)};
        w.advance(duration, movement);

        w.display_on(mainWindow);
        mainWindow.display();
    }
}
예제 #3
0
ZExport (ZDateTime &) ZDateTime::operator+= (long aSeconds)
{
  ZFUNCTRACE_DEVELOP ("ZDateTime::operator+=(long aSeconds)");
  fromSeconds (asSeconds () + aSeconds);
  return *this;
}                               // operator+=
예제 #4
0
ZExport (long) ZDateTime::operator- (const ZDateTime & aDateTime) const
{
  ZFUNCTRACE_DEVELOP
    ("ZDateTime::operator-(const ZDateTime& aDateTime) const");
  return asSeconds () - aDateTime.asSeconds ();
}                               // operator-
예제 #5
0
파일: Duration.cpp 프로젝트: Hapaxia/Kairos
double Duration::asMinutes() const
{
	return asSeconds() / 60.0;
}