当前位置: 首页>>代码示例>>C++>>正文


C++ Time::AsSeconds方法代码示例

本文整理汇总了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();
                }
开发者ID:GibsonT,项目名称:SFML-Tetris,代码行数:67,代码来源:main.cpp

示例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;
}
开发者ID:alexjoverm,项目名称:GaTe,代码行数:9,代码来源:Colisionable.cpp

示例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);
    }
}
开发者ID:FVUA-LosArboles,项目名称:animation_colition,代码行数:62,代码来源:PhysicsState.cpp

示例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())
		);
}
开发者ID:FVUA-LosArboles,项目名称:animation_colition,代码行数:6,代码来源:PhysicsState.cpp

示例5: Seconds

Time operator /(const Time& left, float right)
{
    return Seconds(left.AsSeconds() / right);
}
开发者ID:ChrisJansson,项目名称:Graphics,代码行数:4,代码来源:Time.cpp


注:本文中的Time::AsSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。