double Date::getSince(std::string &curr, const char *ref) { // the date for the lag Date lag( curr, currCalendar ); return getSince(lag, ref); }
double Date::getSince(const char *curr, const char *ref) { std::string sCurr(curr); // the date for the lag Date lag( sCurr, currCalendar ); return getSince(lag, ref); }
InputParameters validParams<CoupledScalarAux>() { InputParameters params = validParams<AuxKernel>(); params.addCoupledVar("coupled", 2.71828, "Coupled Scalar Value for Calculation"); params.addParam<unsigned int>( "component", 0, "The individual component of the scalar variable to output"); MooseEnum lag("CURRENT OLD OLDER", "CURRENT", false); params.addParam<MooseEnum>("lag", lag, "Determine the time level of the coupled value"); return params; }
void Game::run() { constexpr std::chrono::nanoseconds timestep(16000000); //Game::init here for now Tamagochi tamagochi; Needs_container needC; Food_need food_need; Entertainment_need entertainment_need; needC.add_need(&food_need); needC.add_need(&entertainment_need); //end of init using clock = std::chrono::high_resolution_clock; std::chrono::nanoseconds lag(0); auto time_start = clock::now(); while(!endGame()) { auto delta_time = clock::now() - time_start; time_start = clock::now(); lag += std::chrono::duration_cast<std::chrono::nanoseconds>(delta_time); //quit_game = handle_events(); // update game logic as lag permits while(lag >= timestep) { lag -= timestep; //previous_state = current_state; //update(); // update at a fixed rate each time } // calculate how close or far we are from the next timestep //render(); } }
//! [readSocket] void TennisClient::readSocket() { if (!socket) return; while (socket->bytesAvailable()) { QString str; *stream >> str; QStringList args = str.split(QChar(' ')); QString s = args.takeFirst(); if (s == "m" && args.count() == 2) { emit moveBall(args.at(0).toInt(), args.at(1).toInt()); } else if (s == "s" && args.count() == 2){ emit score(args.at(0).toInt(), args.at(1).toInt()); } else if (s == "l" && args.count() == 1){ emit moveLeftPaddle(args.at(0).toInt()); } else if (s == "e"){ // echo QByteArray b; QDataStream s(&b, QIODevice::WriteOnly); s << str; socket->write(b); } else if (s == "E"){ lagTimeout = 0; QTime then = QTime::fromString(args.at(0), "hh:mm:ss.zzz"); if (then.isValid()) { emit lag(then.msecsTo(QTime::currentTime())); // qDebug() << "RTT: " << then.msecsTo(QTime::currentTime()) << "ms"; } } else { qDebug() << Q_FUNC_INFO << "Unknown command" << str; } } }
void TennisServer::readSocket() { if (!clientSocket) return; while (clientSocket->bytesAvailable()) { QString str; *stream >> str; QStringList args = str.split(QChar(' ')); QString s = args.takeFirst(); if(s == "r" && args.count() == 1){ emit moveRightPaddle(args.at(0).toInt()); } else if(s == "e" && args.count() == 1){ lagReplyTimeout = 0; QTime then = QTime::fromString(args.at(0), "hh:mm:ss.zzz"); if(then.isValid()) { emit lag(then.msecsTo(QTime::currentTime())); // qDebug() << "RTT: " << then.msecsTo(QTime::currentTime()) << "ms"; } } else if(s == "E"){ QByteArray b; QDataStream st(&b, QIODevice::WriteOnly); st << str; clientSocket->write(b); } else if(s == "D"){ qDebug() << Q_FUNC_INFO << "closing!"; clientSocket->deleteLater(); clientSocket = 0; } else { qDebug() << Q_FUNC_INFO << "Unknown command" << str; } } }
IIntervalPtr lag(float waitTime, const std::vector<IFiniteTimePtr> &tweens) { return std::move(lag(nullptr, waitTime, tweens)); }