diff options
author | Matthew Kosarek <mattkae@protonmail.com> | 2021-10-15 07:47:06 -0400 |
---|---|---|
committer | Matthew Kosarek <mattkae@protonmail.com> | 2021-10-15 07:47:06 -0400 |
commit | b425e7577b5ef405db42184911f9234c953030b8 (patch) | |
tree | d2e1fa05f912aaec0f0d61c88db7a2b60f872f98 /themes | |
parent | 9d590665caa9f282e4a7365b10e1ba8a85e384d9 (diff) |
Leaves not fade and reset
Diffstat (limited to 'themes')
-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 |