diff options
-rw-r--r-- | themes/LeafParticleRender.cpp | 12 | ||||
-rw-r--r-- | themes/LeafParticleRender.h | 1 | ||||
-rwxr-xr-x | themes/dist/output.wasm | bin | 55929 -> 56705 bytes |
3 files changed, 13 insertions, 0 deletions
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); } diff --git a/themes/LeafParticleRender.h b/themes/LeafParticleRender.h index 0627322..9f5d5f4 100644 --- a/themes/LeafParticleRender.h +++ b/themes/LeafParticleRender.h @@ -24,6 +24,7 @@ struct LeafParticleUpdateData { float32 fallHorizontalFrequency; bool onGround = false; + float32 resetTime = 0.f; Renderer2dVertex* vertexPtr = NULL; }; diff --git a/themes/dist/output.wasm b/themes/dist/output.wasm Binary files differindex d341f4f..f994bca 100755 --- a/themes/dist/output.wasm +++ b/themes/dist/output.wasm |