summaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2022-12-23 12:50:10 -0500
committermattkae <mattkae@protonmail.com>2022-12-23 12:52:02 -0500
commit5667776d9c80f2f2af856da01a14ac20bdf5a3e0 (patch)
tree3f20b2a4569477db34bacda3402f5dfa9d87057e /themes
parent7228b2e1a2d0a8399facce3493d71a3569d250d5 (diff)
Inifinite snow is working again
Diffstat (limited to 'themes')
-rwxr-xr-xthemes/dist/output.wasmbin135480 -> 135775 bytes
-rw-r--r--themes/src/Snowflake.cpp11
2 files changed, 10 insertions, 1 deletions
diff --git a/themes/dist/output.wasm b/themes/dist/output.wasm
index 02f03e6..78fbef4 100755
--- a/themes/dist/output.wasm
+++ b/themes/dist/output.wasm
Binary files differ
diff --git a/themes/src/Snowflake.cpp b/themes/src/Snowflake.cpp
index 7cab8b3..e9f6d5d 100644
--- a/themes/src/Snowflake.cpp
+++ b/themes/src/Snowflake.cpp
@@ -38,7 +38,7 @@ inline void initFlake(SnowflakeParticleRenderer* renderer, SnowflakeUpdateData*
generateSnowflakeShape(&renderer->vertices, randomIntBetween(4, 16), randomFloatBetween(8.f, 16.f), randomFloatBetween(2.f, 6.f));
ud->numVertices = renderer->vertices.numElements - ud->vtxIdx;
ud->velocity = Vector2(randomFloatBetween(-10, 10), randomFloatBetween(-100, -85));
- ud->position = Vector2(randomFloatBetween(0, renderer->xMax), randomFloatBetween(renderer->yMax, -renderer->yMax));
+ ud->position = Vector2(randomFloatBetween(0, renderer->xMax), randomFloatBetween(renderer->yMax, 3 * renderer->yMax));
}
void SnowflakeParticleRenderer::load(SnowflakeLoadParameters params, Renderer2d* renderer) {
@@ -89,6 +89,11 @@ void SnowflakeParticleRenderer::load(SnowflakeLoadParameters params, Renderer2d*
glBindVertexArray(0);
}
+inline void resetFlake(SnowflakeParticleRenderer* renderer, SnowflakeUpdateData* ud) {
+ ud->position.y = 2 * renderer->yMax;
+ ud->velocity = Vector2(randomFloatBetween(-10, 10), randomFloatBetween(-100, -85));
+}
+
inline void updateFlake(SnowflakeParticleRenderer* renderer, SnowflakeUpdateData* ud, i32 s, f32 dtSeconds, bool addWind) {
if (addWind) ud->velocity += renderer->windSpeed;
ud->position += ud->velocity * dtSeconds;
@@ -97,6 +102,10 @@ inline void updateFlake(SnowflakeParticleRenderer* renderer, SnowflakeUpdateData
for (i32 v = ud->vtxIdx; v < (ud->vtxIdx + ud->numVertices); v++) {
renderer->vertices.data[v].vMatrix = m;
}
+
+ if (ud->position.y <= -256) {
+ resetFlake(renderer, ud);
+ }
}
void SnowflakeParticleRenderer::update(f32 dtSeconds) {