From f460141ff0a5992abdc072ea58063c31a8e9e8ee Mon Sep 17 00:00:00 2001 From: Mottributo <87079566+Mottributo@users.noreply.github.com> Date: Thu, 23 Mar 2023 16:46:18 +0300 Subject: [PATCH] bugfixes, formatted code --- sketch.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sketch.js b/sketch.js index 7c2eadf..5db0577 100644 --- a/sketch.js +++ b/sketch.js @@ -165,7 +165,7 @@ function startGame(full_start, update_objects) { if (i == 0) { collectables[0] = { x: 600, - y: floorPos_y, + y: gameChar.possibleGroundPosY[0], size: 75, isFound: false, }; @@ -556,9 +556,12 @@ function drawCanyon(t_canyon) { function drawCollectable(t_collectable) { push(); // animating the coin's jiggle - a = 0.1; b = 3; c = 0.2; d = 2; // a - vert. intensity, c - hor. intensity, b - vert. speed, d - hor. speed - t_collectable.y -= sin(frameCount*a)*b; - t_collectable.x += sin(frameCount*c)*d; + a = 0.1; + b = 3; + c = 0.2; + d = 2; // a - vert. intensity, c - hor. intensity, b - vert. speed, d - hor. speed + t_collectable.y -= sin(frameCount * a) * b; + t_collectable.x += sin(frameCount * c) * d; stroke(0.2); fill(palette.coin_outer); ellipse(t_collectable.x, t_collectable.y, 0.7 * t_collectable.size); @@ -567,8 +570,8 @@ function drawCollectable(t_collectable) { fill(palette.coin_inner); ellipse(t_collectable.x, t_collectable.y, 0.5 * t_collectable.size); // restoring coin's coordinates to preserve game logic - t_collectable.y += sin(frameCount*a)*b; - t_collectable.x -= sin(frameCount*c)*d; + t_collectable.y += sin(frameCount * a) * b; + t_collectable.x -= sin(frameCount * c) * d; pop(); } function drawClouds() { @@ -577,7 +580,7 @@ function drawClouds() { translate((frameCount / clouds[i].y) * 20, 0); // imitating clouds movement, upper ones should go faster // Adding counter-translating to implement parallax, the feeling of depth // TODO: fix jitter during movement (possibly by implementing vectorized movement) - translate(cameraPosX/1.1, 0); + translate(cameraPosX / 1.1, 0); noStroke(); fill(palette.cloud0); ellipse( @@ -613,7 +616,7 @@ function drawMountains() { for (i = 0; i < mountains.length; i++) { push(); // slowing down translation to add parallax, the feeling of depth - translate(cameraPosX/8, 0); + translate(cameraPosX / 8, 0); noStroke(); fill(palette.mountain_shadow); triangle(