Skip to content

Commit

Permalink
sped up link movement and less platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
jellinki committed Oct 23, 2023
1 parent 94822e2 commit 42e8741
Showing 1 changed file with 8 additions and 55 deletions.
63 changes: 8 additions & 55 deletions _posts/2023-10-12-teamwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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 () {
Expand Down

0 comments on commit 42e8741

Please sign in to comment.