From d3bd49b8613e7a143e1d20fda20eef2bc8c5df12 Mon Sep 17 00:00:00 2001 From: Mottributo <87079566+Mottributo@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:49:47 +0300 Subject: [PATCH] Fixed canyon animation --- sketch.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sketch.js b/sketch.js index 8a17a38..db8583d 100644 --- a/sketch.js +++ b/sketch.js @@ -527,21 +527,29 @@ function drawCanyon(t_canyon) { push(); fill(palette.canyon_river_color); rect(t_canyon.x - t_canyon.width / 2, floorPos_y, t_canyon.width, height); - if (frameCount % 4 == 0) { + + if ((frameCount % 2) == 0) { PointX = random( - t_canyon.x - t_canyon.width / 2, - t_canyon.x + t_canyon.width / 2 + t_canyon.x - t_canyon.width / 2 + 5, + t_canyon.x + t_canyon.width / 2 - 5 ); PointY = random(floorPos_y, height); - if (t_canyon.points.length > 3) { + if (t_canyon.points.length > 2) { t_canyon.points.shift(); } - t_canyon.points.add((PointX, PointY)); + t_canyon.points.push([PointX, PointY, random(20, 100)]); } - stroke(palette.canyon_river_wave_color); strokeWeight(5); - line(PointX, PointY, PointX, PointY + random(20, 100)); + for (k=0; k < t_canyon.points.length; k++) { + line( + t_canyon.points[k][0], + t_canyon.points[k][1], + t_canyon.points[k][0], + t_canyon.points[k][1] + t_canyon.points[k][2] + ); + } + pop(); } function drawCollectable(t_collectable) {