diff --git a/src/samples/dolphin/dolphin.cpp b/src/samples/dolphin/dolphin.cpp index bc3f35e..841be31 100755 --- a/src/samples/dolphin/dolphin.cpp +++ b/src/samples/dolphin/dolphin.cpp @@ -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(); } } diff --git a/src/samples/dolphin/objects/collectible.cpp b/src/samples/dolphin/objects/collectible.cpp index 27ffb5c..e1c76a1 100644 --- a/src/samples/dolphin/objects/collectible.cpp +++ b/src/samples/dolphin/objects/collectible.cpp @@ -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; + } + } } \ No newline at end of file diff --git a/src/samples/dolphin/objects/collectible.hpp b/src/samples/dolphin/objects/collectible.hpp index a7adbd1..775eb70 100644 --- a/src/samples/dolphin/objects/collectible.hpp +++ b/src/samples/dolphin/objects/collectible.hpp @@ -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