From b425e7577b5ef405db42184911f9234c953030b8 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Fri, 15 Oct 2021 07:47:06 -0400 Subject: Leaves not fade and reset --- themes/LeafParticleRender.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'themes/LeafParticleRender.cpp') diff --git a/themes/LeafParticleRender.cpp b/themes/LeafParticleRender.cpp index c006c06..fd35888 100644 --- a/themes/LeafParticleRender.cpp +++ b/themes/LeafParticleRender.cpp @@ -86,7 +86,17 @@ void LeafParticleRender::update(float32 dtSeconds) { } if (updateDataItem->onGround) { + updateDataItem->timeFallingSeconds += dtSeconds; + if (updateDataItem->timeFallingSeconds >= updateDataItem->resetTime) { + updateDataItem->onGround = false; + updateDataItem->isFalling = false; + updateDataItem->color.w = 1.f; + } + else { + updateDataItem->color.w = 1.f - (updateDataItem->timeFallingSeconds / updateDataItem->resetTime); + updateLeaf(updateDataItem->vertexPtr, updateDataItem->fallPosition, updateDataItem->color); + } } else if (updateDataItem->isFalling) { updateDataItem->timeFallingSeconds += dtSeconds; @@ -96,6 +106,8 @@ void LeafParticleRender::update(float32 dtSeconds) { if (updateDataItem->fallPosition.y <= 25.f) { // TODO: Hardcoded ground for now updateDataItem->fallPosition.y = 25.f; updateDataItem->onGround = true; + updateDataItem->timeFallingSeconds = 0; + updateDataItem->resetTime = randomFloatBetween(2.f, 5.f); // TODO: Hardcoded reset interval } updateLeaf(updateDataItem->vertexPtr, updateDataItem->fallPosition, updateDataItem->color); } -- cgit v1.2.1