本文整理汇总了C++中Time::AsSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Time::AsSeconds方法的具体用法?C++ Time::AsSeconds怎么用?C++ Time::AsSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time::AsSeconds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if (linesCleared > 0)
{
if (linesCleared > 1 && linesCleared < 4)
{
score += (linesCleared * MULTI_LINE_CLEAR_SCORE) + BRICK_LOCK_SCORE;
}
else if (linesCleared == 4)
{
score += TETRIS_CLEAR_SCORE + BRICK_LOCK_SCORE;
}
else
{
score += SINGLE_LINE_CLEAR_SCORE + BRICK_LOCK_SCORE;
}
}
else
{
score += BRICK_LOCK_SCORE;
}
activeBrick = previewBrick;
activeBrick.SetActivePosition();
previewBrick = PullBrickFromQueue(&brickQueue);
previewBrick.SetPreviewPosition();
}
else
{
Time fallTimer = brickFallTimer.GetElapsedTime();
Time lockTimer = brickLockTimer.GetElapsedTime();
float dropSpeed = 1 - (float)(level * 0.05f);
if (!IsBottomCollision(activeBrick, gameBoard) && fallTimer.AsSeconds() >= dropSpeed)
{
for (int i = 0; i < SPRITES_IN_BRICK; i++)
{
activeBrick.SetSpriteYPosition(i, 1);
brickFallTimer.Restart();
isCheckingLockTime = false;
}
}
else if (IsBottomCollision(activeBrick, gameBoard))
{
if (!isCheckingLockTime)
{
isCheckingLockTime = true;
brickLockTimer.Restart();
}
else if (lockTimer.AsSeconds() >= 0.5f)
{
activeBrick.LockBrick();
isCheckingLockTime = false;
}
}
}
while (renderWindow.PollEvent(gameEvent))
{
if (gameEvent.Type == Event::Closed || gameEvent.Key.Code == Keyboard::Escape)
{
renderWindow.Close();
}
示例2: CalculateNextRect
Rectangle Colisionable::CalculateNextRect(const Time& elapsedTime, float factor){
Rectangle auxRect = GetRectangleColisionAbsolute();
auxRect.SetX(auxRect.GetTopLeft().GetX() + entity->GetSpeed().GetX() * elapsedTime.AsSeconds() * factor);
auxRect.SetY(auxRect.GetTopLeft().GetY() + entity->GetSpeed().GetY() * elapsedTime.AsSeconds() * factor);
return auxRect;
}
示例3: Update
void PhysicsState::Update(const Time& elapsedTime, bool affectGravity)
{
*speedPrev = *speed;
if(affectGravity)
{
// Limitación de velocidades en X
if(gravity->GetX() > 0){
if(speed->GetX() < maxSpeed->GetX())
speed->SetX(speed->GetX() + gravity->GetX() * elapsedTime.AsSeconds());
}
else if(gravity->GetX() < 0){
if(speed->GetX() > -maxSpeed->GetX())
speed->SetX(speed->GetX() + gravity->GetX() * elapsedTime.AsSeconds());
}
// Limitación de velocidades en Y
if(gravity->GetY() > 0){
if(speed->GetY() < maxSpeed->GetY())
speed->SetY(speed->GetY() + gravity->GetY() * elapsedTime.AsSeconds());
}
else if(gravity->GetY() < 0){
if(speed->GetY() > -maxSpeed->GetY())
speed->SetY(speed->GetY() + gravity->GetY() * elapsedTime.AsSeconds());
}
// Si nos pasamos de velocidades, reigualamos
if(speed->GetX() > maxSpeed->GetX())
speed->SetX(maxSpeed->GetX());
if(speed->GetY() > maxSpeed->GetY())
speed->SetY(maxSpeed->GetY());
}
*posPrev = *posNext;
posNext->SetX(posNext->GetX() + ((speed->GetX() + speedPrev->GetX()) * 0.5f * elapsedTime.AsSeconds()));
posNext->SetY(posNext->GetY() + ((speed->GetY() + speedPrev->GetY()) * 0.5f * elapsedTime.AsSeconds()));
// Limites
if(hasLimitBottom && posNext->GetY() > limitBottom){
posNext->SetY(limitBottom);
posPrev->SetY(limitBottom);
speed->SetY(0.f);
}
if(hasLimitTop && posNext->GetY() < limitTop){
posNext->SetY(limitTop);
posPrev->SetY(limitTop);
speed->SetY(0.f);
}
if(hasLimitRight && posNext->GetX() > limitRight){
posNext->SetX(limitRight);
posPrev->SetX(limitRight);
}
if(hasLimitLeft && posNext->GetX() < limitLeft) {
posNext->SetX(limitLeft);
posPrev->SetX(limitLeft);
}
}
示例4: GetNextPosition
Vector PhysicsState::GetNextPosition(const Time& elapsedTime) const{
return Vector(
posNext->GetX() + ((speedPrev->GetX() + speed->GetX()) * 0.5f * elapsedTime.AsSeconds()) ,
posNext->GetY() + ((speedPrev->GetY() + speed->GetY()) * 0.5f * elapsedTime.AsSeconds())
);
}
示例5: Seconds
Time operator /(const Time& left, float right)
{
return Seconds(left.AsSeconds() / right);
}