Added: Collectibles now rotate, float up before disapeparing after being picked up.

This commit is contained in:
Foxar
2020-12-07 20:08:11 +01:00
parent 6292c27c50
commit 32422b87eb
3 changed files with 28 additions and 2 deletions
+3 -1
View File
@@ -111,12 +111,14 @@ void Dolphin::onUpdate()
for (int i = 0; i < OYSTERS_COUNT; i++)
{
oysters[i].update();
Vector3 vecDist = oysters[i].mesh.position - player.mesh.position;
float dist = Math::sqrt(vecDist.x + vecDist.y + vecDist.z);
if (dist < 2.5F && player.getIsJumping() && oysters[i].isActive())
{
printf("Pickup %d Dist %d\n", i, dist);
oysters[i].setActive(false);
//oysters[i].setActive(false);
oysters[i].disappear();
}
}
@@ -22,6 +22,7 @@ Collectible::Collectible()
mesh.shouldBeFrustumCulled = false;
mesh.position.set(0.0F, 0.0F, 0.0f);
bActive = true;
bDisappearing = false;
}
Collectible::~Collectible()
@@ -33,7 +34,28 @@ void Collectible::setActive(u8 b)
bActive = b;
}
void Collectible::disappear()
{
bDisappearing = true;
lift = 10;
}
u8 Collectible::isActive()
{
return bActive;
}
void Collectible::update()
{
mesh.rotation.y += 0.08F;
if (bDisappearing)
{
mesh.position.y += lift;
lift = lift > 0 ? lift / 2 : 0;
if (lift < 1)
{
setActive(false);
bDisappearing = false;
}
}
}
+3 -1
View File
@@ -23,11 +23,13 @@ public:
Collectible();
~Collectible();
void update();
void disappear();
void setActive(u8 b);
u8 isActive();
private:
u8 bActive;
u8 bActive, bDisappearing;
u8 lift;
};
#endif