Exemplo n.º 1
0
void Particle::MovePosition(const D3DXVECTOR3& position)
{
    if(!m_pinned)
    {
        m_position += position;
        UpdateCollisionPosition();
    }
}
Exemplo n.º 2
0
void Particle::PreCollisionUpdate(float damping, float timestepSqr)
{
    if(!m_pinned && m_collision->IsCollidingWith(Geometry::NONE))
    {
        //verlet integration
        //X(t + ∆t) = 2X(t) - X(t - ∆t) + ∆t^2X▪▪(t)
        //X(t + ∆t) = X(t) + (X(t)-X(t - ∆t)) + ∆t^2X▪▪(t)
        //X(t + ∆t) = X(t) + X▪(t) + ∆t^2X▪▪(t)
        D3DXVECTOR3 update = ((m_position-m_previousPosition)*damping) 
            + (m_acceleration*timestepSqr);

        m_previousPosition = m_position;
        m_position += update;
    }
    else
    {
        m_previousPosition = m_position;
    }

    UpdateCollisionPosition();
    MakeZeroVector(m_acceleration);
}
Exemplo n.º 3
0
void Particle::PostCollisionUpdate()
{
    FilterPosition();
    UpdateCollisionPosition();
    m_collision->UpdateCollision();
}
Exemplo n.º 4
0
void UpdateUpgradeScreenObjects(void)
{
	float camX = GetCameraXPosition();
	char CharTemp[32];

	int worldX, worldY;
	Vec2 MouseClick;
	Vec2 NewPosition;

	FoxInput_GetWorldPosition(&worldX, &worldY);
	Vec2Set(&MouseClick, (float)worldX, (float)worldY);

	//Update the particles
	ParticleSystemUpdate();

	//Check if there are upgrades
	if (!UpgradesToUpgrade)
	{
		if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0)
			UpgradesToUpgrade = TRUE;
		else if (CurrentPlayer.CurrentPlayerStats.Upgrades < 1)
		{
			//No upgrade points, get out
			UpgradeComplete = TRUE;
			return;
		}
	}

	//Title
	if (CurrentPlayer.CurrentPlayerStats.Strength >= UPGRADE_MAX
	 && CurrentPlayer.CurrentPlayerStats.Agility >= UPGRADE_MAX
	 && CurrentPlayer.CurrentPlayerStats.Defense >= UPGRADE_MAX
	 && !allUpgradesFull)
	{
		//If no more upgrades remain, let them know
		allUpgradesFull = TRUE;
		ChangeTextString(UpgradesName, "All Upgrades Complete!");
		ChangeTextZIndex(UpgradesName, 4003);
	}
	Vec2Set(&NewPosition, camX, 470);
	ChangeTextPosition(UpgradesName, NewPosition, Center);

	//Upgrades remaining
	if (lastUpgrades != CurrentPlayer.CurrentPlayerStats.Upgrades)
	{
		//Do some flavor text warnings for differnt UP amounts
		if (allUpgradesFull)
			sprintf(CharTemp, "Good Work! Keep Mashing!");
		else if (CurrentPlayer.CurrentPlayerStats.Upgrades == 1)
			sprintf(CharTemp, "%i Point Remaining!", CurrentPlayer.CurrentPlayerStats.Upgrades);
		else if (CurrentPlayer.CurrentPlayerStats.Upgrades < 1)
			sprintf(CharTemp, "No Points! Level Up More!");
		else
			sprintf(CharTemp, "%i Points to Spend!", CurrentPlayer.CurrentPlayerStats.Upgrades);
		ChangeTextString(UpgradesLeft, CharTemp);
		ChangeTextZIndex(UpgradesLeft, 4003);
		TextAllVisible(UpgradesLeft);
		lastUpgrades = CurrentPlayer.CurrentPlayerStats.Upgrades;
	}
	Vec2Set(&NewPosition, camX, 380);
	ChangeTextPosition(UpgradesLeft, NewPosition, Center);

	//Upgrade buttons, all 3
	UpdateButtonPosition(UpgradeButton1, 545 + camX, 200);
	UpdateCollisionPosition(&UpgradeButton1->ButtonCollider, &UpgradeButton1->ButtonSprite->Position);
	UpdateButtonPosition(UpgradeButton2, 545 + camX, 0);
	UpdateCollisionPosition(&UpgradeButton2->ButtonCollider, &UpgradeButton2->ButtonSprite->Position);
	UpdateButtonPosition(UpgradeButton3, 545 + camX, -200);
	UpdateCollisionPosition(&UpgradeButton3->ButtonCollider, &UpgradeButton3->ButtonSprite->Position);

	//Upgrade bars
	UpgradeBar1->Position.x = camX;
	UpgradeBar1->Position.y = 200;
	UpgradeBar2->Position.x = camX;
	UpgradeBar2->Position.y = 0;
	UpgradeBar3->Position.x = camX;
	UpgradeBar3->Position.y = -200;

	//Particle / Haze back
	HazeBackground->Position.x = camX + 480;
	HazeBackground->Position.y = 0;
	SystemOne->Position.y = 0;
	SystemOne->Position.x = camX;
	SystemOne->amountTotal = -1;

	if (HazeBackground->Alpha < 1)
		HazeBackground->Alpha += 2 * GetDeltaTime();
	else
		HazeBackground->Alpha = 1;

	//Upgrade bar colors
	//Str --
	UpgradeBarColor1->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Strength);
	UpgradeBarColor1->Position.y = 200;
	UpgradeBarColor1->ScaleX     = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Strength / UPGRADE_MAX);
	UpgradeBarColor1->ScaleY     = 1.1f;
	//Agi --
	UpgradeBarColor2->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Agility);
	UpgradeBarColor2->Position.y = 0;
	UpgradeBarColor2->ScaleX     = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Agility / UPGRADE_MAX);
	UpgradeBarColor2->ScaleY     = 1.1f;
	//Def --
	UpgradeBarColor3->Position.x = camX - 61 - 52.0f * (UPGRADE_MAX - CurrentPlayer.CurrentPlayerStats.Defense);
	UpgradeBarColor3->Position.y = -200;
	UpgradeBarColor3->ScaleX     = 1.0f * ((float)CurrentPlayer.CurrentPlayerStats.Defense / UPGRADE_MAX);
	UpgradeBarColor3->ScaleY     = 1.1f;

	//Upgrades used placement
	//Str --
	sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Strength);
	ChangeTextString(UpgradeAmount1, CharTemp);
	ChangeTextZIndex(UpgradeAmount1, 4003);
	TextAllVisible(UpgradeAmount1);
	Vec2Set(&NewPosition, camX - 590, 200);
	ChangeTextPosition(UpgradeAmount1, NewPosition, Center);
	//Agi --
	sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Agility);
	ChangeTextString(UpgradeAmount2, CharTemp);
	ChangeTextZIndex(UpgradeAmount2, 4003);
	TextAllVisible(UpgradeAmount2);
	Vec2Set(&NewPosition, camX - 590, 0);
	ChangeTextPosition(UpgradeAmount2, NewPosition, Center);
	//Def --
	sprintf(CharTemp, "%i", CurrentPlayer.CurrentPlayerStats.Defense);
	ChangeTextString(UpgradeAmount3, CharTemp);
	ChangeTextZIndex(UpgradeAmount3, 4003);
	TextAllVisible(UpgradeAmount3);
	Vec2Set(&NewPosition, camX - 590, -200);
	ChangeTextPosition(UpgradeAmount3, NewPosition, Center);

	//Done upgrading button
	UpdateButtonPosition(MainMapButton, 400 + camX, -400);
	UpdateCollisionPosition(&MainMapButton->ButtonCollider, &MainMapButton->ButtonSprite->Position);

	//STRENGTH (No up allowed if maxed)
	if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton1->ButtonCollider, &MouseClick)
	 && CurrentPlayer.CurrentPlayerStats.Strength < UPGRADE_MAX)
	{
		UpgradeButton1->ButtonSprite->ScaleX = 1.12f;
		UpgradeButton1->ButtonSprite->ScaleY = 1.12f;

		//Make the button react
		if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT))
		{
			CurrentPlayer.CurrentPlayerStats.Upgrades--;
			CurrentPlayer.CurrentPlayerStats.Strength++;

			UpgradeButton1->ButtonSprite->ScaleX = 1.16f;
			UpgradeButton1->ButtonSprite->ScaleY = 1.16f;
			PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp);
		}
	}
	else
	{
		if (UpgradeButton1->ButtonSprite->ScaleX > 1.0f)
		{
			UpgradeButton1->ButtonSprite->ScaleX -= GetDeltaTime() * 2;
			UpgradeButton1->ButtonSprite->ScaleY -= GetDeltaTime() * 2;
		}
	}
	//AGILITY (No up allowed if maxed)
	if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton2->ButtonCollider, &MouseClick)
	 && CurrentPlayer.CurrentPlayerStats.Agility < UPGRADE_MAX)
	{
		UpgradeButton2->ButtonSprite->ScaleX = 1.12f;
		UpgradeButton2->ButtonSprite->ScaleY = 1.12f;

		//Make the button react
		if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT))
		{
			CurrentPlayer.CurrentPlayerStats.Upgrades--;
			CurrentPlayer.CurrentPlayerStats.Agility++;

			UpgradeButton2->ButtonSprite->ScaleX = 1.16f;
			UpgradeButton2->ButtonSprite->ScaleY = 1.16f;
			PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp);
		}
	}
	else
	{
		if (UpgradeButton2->ButtonSprite->ScaleX > 1.0f)
		{
			UpgradeButton2->ButtonSprite->ScaleX -= GetDeltaTime() * 2;
			UpgradeButton2->ButtonSprite->ScaleY -= GetDeltaTime() * 2;
		}
	}
	//DEFENSE (No up allowed if maxed)
	if (CurrentPlayer.CurrentPlayerStats.Upgrades > 0 && PointRectCollision(&UpgradeButton3->ButtonCollider, &MouseClick)
	 && CurrentPlayer.CurrentPlayerStats.Defense < UPGRADE_MAX)
	{
		UpgradeButton3->ButtonSprite->ScaleX = 1.12f;
		UpgradeButton3->ButtonSprite->ScaleY = 1.12f;

		//Make the button react
		if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT))
		{
			CurrentPlayer.CurrentPlayerStats.Upgrades--;
			CurrentPlayer.CurrentPlayerStats.Defense++;

			UpgradeButton3->ButtonSprite->ScaleX = 1.16f;
			UpgradeButton3->ButtonSprite->ScaleY = 1.16f;
			PlayAudio(CurrentPlayer.CurrentPlayerSounds.KeyPickUp);
		}
	}
	else
	{
		if (UpgradeButton3->ButtonSprite->ScaleX > 1.0f)
		{
			UpgradeButton3->ButtonSprite->ScaleX -= GetDeltaTime() * 2;
			UpgradeButton3->ButtonSprite->ScaleY -= GetDeltaTime() * 2;
		}
	}

	//MAIN MENU
	if(PointRectCollision(&MainMapButton->ButtonCollider, &MouseClick))
	{
		MainMapButton->ButtonSprite->ScaleX = 1.2f;
		MainMapButton->ButtonSprite->ScaleY = 1.2f;

		//Make the button react
		if(FoxInput_MouseTriggered(MOUSE_BUTTON_LEFT))
		{
			UpgradeComplete = TRUE;
		}
	}
	else
	{
		MainMapButton->ButtonSprite->ScaleX = 1.0f;
		MainMapButton->ButtonSprite->ScaleY = 1.0f;
	}
}