Exemplo n.º 1
0
void CSpikefall::OnLoop()
{
	// horizontal distance from player
	float X_dist = (this->X + (this->Width/2) - CEntity::EntityList[0]->X + (CEntity::EntityList[0]->Width/2));
	// vertical distance from player
	float Y_dist = (this->Y - CEntity::EntityList[0]->Y);

	// If player comes within a 64 px "pillar" area, and player is underneath...
	if (X_dist < 64 && Y_dist < 0)
	{
		Flags |= ENTITY_FLAG_GRAVITY;
	}

	if (Flags & ENTITY_FLAG_GRAVITY)
	{
		AccelY = 0.75f;
	}

	SpeedY += AccelY * CFPS::FPSControl.GetSpeedFactor();

	// Make sure we're not overstepping our boundaries,
	// so to speak...
	if (SpeedY > MaxSpeedY) SpeedY = MaxSpeedY;
	if (SpeedY < -MaxSpeedY) SpeedY = -MaxSpeedY;

	OnAnimate();
	if ((Flags & ENTITY_FLAG_GRAVITY) && !OnMove(0.0, SpeedY))
		Dead = true;
}
Exemplo n.º 2
0
void CEntity::OnLoop() {
    //We’re not Moving
    if (MoveLeft == false && MoveRight == false) {
        StopMove();
    }

    if (MoveLeft) {
        AccelX = -0.5;
    } else

        if (MoveRight) {
            AccelX = 0.5;
        }

    if (Flags & ENTITY_FLAG_GRAVITY) {
        AccelY = 0.75f;
    }

    SpeedX += AccelX * CFPS::FPSControl.GetSpeedFactor();
    SpeedY += AccelY * CFPS::FPSControl.GetSpeedFactor();

    if (SpeedX > MaxSpeedX)  SpeedX =  MaxSpeedX;
    if (SpeedX < -MaxSpeedX) SpeedX = -MaxSpeedX;
    if (SpeedY > MaxSpeedY)  SpeedY =  MaxSpeedY;
    if (SpeedY < -MaxSpeedY) SpeedY = -MaxSpeedY;

    OnAnimate();
    OnMove(SpeedX, SpeedY);
}
Exemplo n.º 3
0
void CSceneManager::drawAll()
{
	OnAnimate(0);

	mSolidNodes.clear();
	mActiveShaders.clear();

	OnRegisterSceneNode();

	/* reset all the active shaders. (for per-frame variables optimizations.) */
	for (auto it = mActiveShaders.begin(); it != mActiveShaders.end(); it++)
	{
		(*it)->reset();
	}


	/* sort all the solid nodes according to the sort code. */
	std::sort(mSolidNodes.begin(), mSolidNodes.end(), [](ISceneNode* node1, ISceneNode* node2){
		return node1->getSortCode() < node2->getSortCode();
	});

	/* render all the solid nodes */
	auto it = mSolidNodes.begin();
	for (; it != mSolidNodes.end(); it++)
	{
		(*it)->render();
	}
}
Exemplo n.º 4
0
CRect CXTPTaskPanelGroup::OnReposition(CRect rc, BOOL bRecalcOnly)
{
	if (m_pPanel->IsExplorerBehaviour())
		SetOffsetItem(0, FALSE);

	CXTPTaskPanelPaintManager* pPaintManager = GetPaintManager();
	CRect rcMarginsOuter = pPaintManager->GetGroupOuterMargins(this);

	rc.DeflateRect(rcMarginsOuter);

	m_rcGroupTarget = rc;

	if (!m_pPanel->IsExplorerBehaviour() && (m_pPanel->GetActiveGroup() == this || IsExpanding()))
	{
		CRect rcMarginsInner = pPaintManager->GetGroupInnerMargins(this);
		int nInsideHeight = CalcInsideHeight();
		int nButtonHeight = max(32, GetItemIconSize().cy + rcMarginsInner.bottom);

		int nExpandedClientHeight = max(nButtonHeight + rcMarginsInner.top + 2, nInsideHeight);

		int nMinClientHeight = GetMinimumClientHeight();
		nExpandedClientHeight = max(nMinClientHeight, nExpandedClientHeight);

		if (nExpandedClientHeight > m_nExpandedClientHeight)
		{
			RepositionAutoHeightControls(nExpandedClientHeight - m_nExpandedClientHeight);
		}

		m_nExpandedClientHeight = nExpandedClientHeight;
		RepositionScrollOffset();
	}

	int nClientHeight = IsExpanded() ? m_nExpandedClientHeight : 0;

	m_rcGroupTarget.bottom = m_rcGroupTarget.top + m_nCaptionHeight + nClientHeight;

	m_rcGroupCurrent.left = m_rcGroupTarget.left;
	m_rcGroupCurrent.right = m_rcGroupTarget.right;

	if (!bRecalcOnly || !m_pPanel->m_bAnimation) OnAnimate(0);
	else if (!IsDirty()) OnAnimate(0);


	return m_rcGroupTarget;
}
Exemplo n.º 5
0
void GameObject::Animate( scalar_t deltaTime )
{
	OnAnimate(deltaTime);		// animate this object

	// animate children
	if (HasChild())
		((GameObject*)GetChild())->Animate(deltaTime);

	// animate siblings
	if (HasParent() && !IsLastChild())
		((GameObject*)GetFollowing())->Animate(deltaTime);

	if (toBeDelete)
		delete this;
}
Exemplo n.º 6
0
void CXTPTaskPanelGroup::SetOffsetItem(int nScrollOffset, BOOL bUpdateScrollButtons /*= TRUE*/)
{
	nScrollOffset = nScrollOffset - (nScrollOffset % m_nItemsInRow);

	if (nScrollOffset > GetItemCount() - 1)
		nScrollOffset = GetItemCount() - 1;

	if (nScrollOffset < 0)
		nScrollOffset = 0;

	if (m_nScrollOffset != nScrollOffset)
	{
		m_nScrollOffset = nScrollOffset;

		if (bUpdateScrollButtons)
		{
			OnAnimate(0);
			m_pPanel->UpdateScrollButtons();
		}
		RedrawPanel(FALSE);
	}
}
Exemplo n.º 7
0
//-----------------------------------------------------------------------------
void CPlayer::OnLoop() {
	// If left or right button is not pressed anymore, stop player movement
	if(MoveLeft == false && MoveRight == false) {
		StopMoveX();
	}

	// If up or down button is not pressed anymore, stop player movement
	if(MoveUp == false && MoveDown == false) {
		StopMoveY();
	}

	// Variables that determine if player has reached left or right end
	// of the screen and thus isn't allowed to move farther to same direction
	bool leftScreenCrossed = false;
	bool rightScreenCrossed = false;
	
	// If player is at the left end of the screen. Camera is on the screen 
	// locally at point 0,0 so comparing to player's location is easy
	if (X < CCamera::CameraControl.GetX()) {
		leftScreenCrossed = true;
	} 
	// Same thing here with the right end of the screen with little adjustment
	else if ((X+PLAYER_SPRITE_WIDTH) > (CCamera::CameraControl.GetX()+WWIDTH)) {
		rightScreenCrossed = true;
	}
		
	// Player is not at the left end and can move to left freely
	if(MoveLeft && !leftScreenCrossed) {
		AccelX = PLAYER_ACCEL_LEFT;
	} 
	// Player is not at the right end and can move to right freely
	else if(MoveRight && !rightScreenCrossed) {
		AccelX = PLAYER_ACCEL_RIGHT;
	}

	// Bottom and top sides of the screen are blocked with blocking tiles
	// so there is no need to check if player has vertically crossed the line
	if(MoveUp) {
		AccelY = PLAYER_ACCEL_UP;
	} else if(MoveDown) {
		AccelY = PLAYER_ACCEL_DOWN;
	}

	// Automatic speed adjusting calculations
	SpeedX += AccelX * CFPS::FPSControl.GetSpeedFactor();
	SpeedY += AccelY * CFPS::FPSControl.GetSpeedFactor();

	// Don't let player's speed go over maximum definitions
	if(SpeedX > MaxSpeedX)  SpeedX =  MaxSpeedX;
	if(SpeedX < -MaxSpeedX) SpeedX = -MaxSpeedX;
	if(SpeedY > MaxSpeedY)  SpeedY =  MaxSpeedY;
	if(SpeedY < -MaxSpeedY) SpeedY = -MaxSpeedY;

	// Do player's animations
	OnAnimate();

	/* Move player */
	
	// If player is not touching horizontal borders, move normally
	if (!leftScreenCrossed && !rightScreenCrossed) {
		OnMove(SpeedX, SpeedY);
	} 
	// If player is touching one but his speed is not too slow (left border)
	// or too fast (right border) to go off the screen, move normally
	else if (leftScreenCrossed && SpeedX >= CCamera::CameraControl.speed || 
			 rightScreenCrossed && SpeedX <= CCamera::CameraControl.speed) {
		OnMove(SpeedX, SpeedY);
	} 
	// Otherwise force player to move same speed as the camera (or the
	// rolling play area)
	else {
		// Might also want to check player X won't get off screen (level objects can "push" player)
		OnMove(CCamera::CameraControl.speed, SpeedY);
	}

	/* After has been moved */
	Gun.OnLoop();
	Afterburner.OnLoop();
	Afterburner.X = X-20;
	Afterburner.Y = Y+PLAYER_SPRITE_HEIGHT/2-7;

	// Reset level after death scene is complete
	if ( MakeDeathScene && (SDL_GetTicks() > (unsigned int)(DeathMoment + 3000)) ) {
		MakeDeathScene = false;
		CAppStateGame::Instance.ResetLevelNow();
	}

}