Added: Collectibles now rotate, float up before disapeparing after being picked up.
This commit is contained in:
@@ -111,12 +111,14 @@ void Dolphin::onUpdate()
|
|||||||
|
|
||||||
for (int i = 0; i < OYSTERS_COUNT; i++)
|
for (int i = 0; i < OYSTERS_COUNT; i++)
|
||||||
{
|
{
|
||||||
|
oysters[i].update();
|
||||||
Vector3 vecDist = oysters[i].mesh.position - player.mesh.position;
|
Vector3 vecDist = oysters[i].mesh.position - player.mesh.position;
|
||||||
float dist = Math::sqrt(vecDist.x + vecDist.y + vecDist.z);
|
float dist = Math::sqrt(vecDist.x + vecDist.y + vecDist.z);
|
||||||
if (dist < 2.5F && player.getIsJumping() && oysters[i].isActive())
|
if (dist < 2.5F && player.getIsJumping() && oysters[i].isActive())
|
||||||
{
|
{
|
||||||
printf("Pickup %d Dist %d\n", i, dist);
|
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.shouldBeFrustumCulled = false;
|
||||||
mesh.position.set(0.0F, 0.0F, 0.0f);
|
mesh.position.set(0.0F, 0.0F, 0.0f);
|
||||||
bActive = true;
|
bActive = true;
|
||||||
|
bDisappearing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collectible::~Collectible()
|
Collectible::~Collectible()
|
||||||
@@ -33,7 +34,28 @@ void Collectible::setActive(u8 b)
|
|||||||
bActive = b;
|
bActive = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Collectible::disappear()
|
||||||
|
{
|
||||||
|
bDisappearing = true;
|
||||||
|
lift = 10;
|
||||||
|
}
|
||||||
|
|
||||||
u8 Collectible::isActive()
|
u8 Collectible::isActive()
|
||||||
{
|
{
|
||||||
return bActive;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -23,11 +23,13 @@ public:
|
|||||||
Collectible();
|
Collectible();
|
||||||
~Collectible();
|
~Collectible();
|
||||||
void update();
|
void update();
|
||||||
|
void disappear();
|
||||||
void setActive(u8 b);
|
void setActive(u8 b);
|
||||||
u8 isActive();
|
u8 isActive();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u8 bActive;
|
u8 bActive, bDisappearing;
|
||||||
|
u8 lift;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user