From 42e8741703d6c648688f1e334b0d07fe3b03d997 Mon Sep 17 00:00:00 2001 From: jellinki Date: Mon, 23 Oct 2023 14:40:39 -0700 Subject: [PATCH] sped up link movement and less platforms --- _posts/2023-10-12-teamwork.md | 63 +++++------------------------------ 1 file changed, 8 insertions(+), 55 deletions(-) diff --git a/_posts/2023-10-12-teamwork.md b/_posts/2023-10-12-teamwork.md index 2a00862..ca56647 100644 --- a/_posts/2023-10-12-teamwork.md +++ b/_posts/2023-10-12-teamwork.md @@ -37,7 +37,7 @@ courses: { compsci: {week: 7} } const gravity = 0.5; const jumpStrength = -10; - const moveSpeed = 5; + const moveSpeed = 8; // Increase sprite movement speed function updateSpriteAnimation() { if (frameX < maxFrame) { @@ -138,56 +138,12 @@ courses: { compsci: {week: 7} } platforms.push(platform); // Add a trampoline on some platforms randomly - if (Math.random() < 0.2) { // Adjust the probability as needed + if (Math.random() < 0.1) { // Reduce the probability for fewer platforms var trampoline = { - x: platform.x + platform.width / 2 - 10, // Adjust for the trampoline's width - y: platform.y - 10, // Adjust for the trampoline's height - width: 20, // Adjust to match the trampoline's width - height: 5, // Adjust to match the trampoline's height - }; - platforms.push(trampoline); - } - } - - // Function to generate platforms at the top of the screen - function generateTopPlatform() { - var platform = { - width: 150, - height: 20, - x: Math.random() * (canvas.width - 150), - y: -20 // Platforms appear at the top of the screen - }; - platforms.push(platform); - - // Add a trampoline on some platforms randomly - if (Math.random() < 0.2) { // Adjust the probability as needed - var trampoline = { - x: platform.x + platform.width / 2 - 10, // Adjust for the trampoline's width - y: platform.y - 10, // Adjust for the trampoline's height - width: 20, // Adjust to match the trampoline's width - height: 5, // Adjust to match the trampoline's height - }; - platforms.push(trampoline); - } - } - - // function to generate platforms at bottom of screen - function generateBottomPlatform() { - var platform = { - width: 150, - height: 20, - x: Math.random() * (canvas.width - 150), - y: canvas.height + 20 - }; - platforms.push(platform); - - // add trampoline on some platforms randomly - if (Math.random() < 0.2) { // Adjust probability as needed - var trampoline = { - x: platform.x + platform.width / 2 - 10, // Adjust for trampoline width - y: platform.y - 10, // Adjust for trampoline height - width: 20, // Adjust to match trampoline width - height: 5, // Adjust to match trampoline height + x: platform.x + platform.width / 2 - 10, + y: platform.y - 10, + width: 20, + height: 5, }; platforms.push(trampoline); } @@ -196,11 +152,8 @@ courses: { compsci: {week: 7} } // Call the platform generation function initially to ensure a platform is within jumping distance generateRandomPlatform(); - // Call the platform generation function more frequently to have more platforms - setInterval(generateRandomPlatform, 700); // Decreased interval for more platforms - - // Call the top platform generation function at regular intervals - setInterval(generateTopPlatform, 3000); // Platforms at the top every 2 seconds + // Call the platform generation function more slowly for fewer platforms + setInterval(generateRandomPlatform, 1200); // Increase interval for fewer platforms // Main game loop var interval = setInterval(function () {